# Exercise 01: Watch the Loop **Concept:** The Agent Loop (CC-001) **Level:** Basic **Time:** ~10 minutes --- ## Objective Watch Claude Code execute a multi-step task from start to finish. You will see the agent loop in action: Claude reads, thinks, picks a tool, observes the result, and repeats until done. This is your first hands-on contact with the agent loop. No prior experience with Claude Code required beyond having it installed. --- ## Before You Start Confirm you have: - [ ] Claude Code installed (`claude --version` prints a version) - [ ] This repo cloned and open in your terminal - [ ] Started Claude Code in this directory (`claude`) --- ## Instructions **Step 1:** Open Claude Code in this repo directory. ```bash cd claude-code-agent-loop claude ``` **Step 2:** Paste this prompt into Claude Code: ``` Create a file called loop-demo.md that contains: 1. Today's date and time 2. A list of all files in this directory with their sizes 3. The first 5 lines of README.md 4. A summary sentence describing what this repo is about Do not ask me any questions. Just do it. ``` **Step 3:** Watch the terminal output carefully as Claude works. You will see Claude make a series of tool calls. Pay attention to: - Which tools Claude picks (Bash, Read, Write, Glob) - The order it chooses to do things - How it uses the output of one step to inform the next - That you did not tell it which tools to use or what order **Step 4:** Read the generated `loop-demo.md` file. Check that it contains all four items from the prompt. Claude gathered information from multiple sources (system clock, file system, file contents) and synthesized them into one output file. --- ## Expected Output After 15-30 seconds, you should see: - A new file `loop-demo.md` in the repo root - It contains today's date (from a Bash call to `date`) - It lists files with sizes (from `ls -la` or similar) - It includes the first 5 lines of README.md (from Read tool) - It ends with a summary sentence about the repo The exact content varies, but the structure should match. **How you know the agent loop worked:** - Claude made 3-5 tool calls without asking you anything between them - Each tool call built on information from the previous one - The final file synthesizes data from multiple sources --- ## What You Learned - **The loop is autonomous:** Claude decided the order and tools on its own - **Each step informs the next:** The loop observes results before choosing the next action - **The task, not the steps, is what you specify:** You said what you wanted, not how to get it --- ## Clean Up Delete the generated file so the repo stays clean: ```bash rm loop-demo.md ``` --- ## Next Ready to go further? Move to [Exercise 02: Control the Loop](./02-control-the-loop.md).