Understanding Agents
Module: Agents & Subagents | Lesson: 1 of 4 | Time: ~10 minutes
What You Will Learn
- What the agent paradigm means in AI
- How Claude Code functions as an agent
- The difference between a chatbot and an agent
Prerequisites
- Completed Module 09: Hooks
What Is an Agent?
In the AI world, an agent is a system that can take actions on its own to achieve a goal. It does not just answer questions — it makes decisions, uses tools, checks results, and keeps going until the job is done.
A regular chatbot works like this:
- You ask a question
- It generates a text response
- Done
An agent works like this:
- You describe a goal
- It breaks the goal into steps
- It uses tools to accomplish each step
- It checks whether the result looks right
- It adjusts and continues until the goal is achieved
A chatbot is like asking someone for directions. They tell you the route, and you walk it yourself. An agent is like hiring a driver. You say where you want to go, and they handle the driving, navigation, and parking.
Claude Code IS an Agent
Claude Code is not just a chatbot that knows about programming. It is a full AI agent that can:
- Read files to understand your codebase
- Edit files to make changes
- Run commands in your terminal
- Search through your code for patterns
- Create new files for new features
- Use external tools through MCP servers
When you give Claude Code a task like "add a login page to my app," it does not just tell you how — it actually does the work. It reads your existing code to understand the project structure, creates the necessary files, writes the code, and may even run tests to verify everything works.
The Agent Loop
Claude Code follows a repeating cycle called the agent loop:
1. UNDERSTAND --> Read the request, examine files, gather context
|
2. PLAN --> Decide what tools to use and in what order
|
3. ACT --> Use a tool (read, edit, run command, etc.)
|
4. CHECK --> Look at the result — did it work?
|
5. REPEAT --> If more work is needed, go back to step 2
|
6. DONE --> Report the results to you
This loop is what makes Claude Code an agent rather than a simple chatbot. It does not stop after one action — it keeps going through the loop until the task is complete.
Example: When you ask Claude to "fix the failing test in auth.test.js":
- Understand: Claude reads auth.test.js and the code it tests
- Plan: Claude identifies the failing assertion and what needs to change
- Act: Claude edits the source code to fix the bug
- Check: Claude runs the tests to see if they pass now
- Repeat: If tests still fail, Claude reads the error, adjusts, and tries again
- Done: Claude reports that the tests pass and explains what it changed
Agentic vs Conversational Mode
Claude Code can operate in two modes:
| Mode | Behavior | Best For |
|---|---|---|
| Agentic | Claude takes actions, uses tools, makes changes | Building features, fixing bugs, refactoring |
| Conversational | Claude discusses and explains without taking action | Learning, planning, asking questions |
By default, Claude Code operates in agentic mode — it will read files, make edits, and run commands as needed. But you can steer it toward conversational mode by how you phrase your requests:
- Agentic: "Add error handling to the login function" (Claude will make the change)
- Conversational: "How should I add error handling to the login function?" (Claude will explain the approach)
You do not need to switch a setting to change modes. Claude picks up on the intent of your message. Asking "how" or "what do you think" keeps things conversational. Giving a direct instruction like "add" or "fix" triggers agentic behavior.
Why Understanding Agents Matters
In the next lessons, you will learn about subagents — agents that Claude Code can spawn to handle subtasks. Understanding the agent concept is important because:
- Subagents follow the same agent loop (understand, plan, act, check, repeat)
- Each subagent works independently on its assigned subtask
- The main agent coordinates the subagents and combines their results
Think of it like a manager who delegates work. The manager (main agent) breaks a big task into smaller pieces and assigns each piece to a team member (subagent). Each team member works independently and reports back.
Try It Yourself
Watch the agent loop in action:
-
Start Claude Code in any project with some code
-
Ask Claude to do something that requires multiple steps, like: "Find all TODO comments in this project and create a summary file listing each one with its file location"
-
Watch Claude's process carefully. You should see it:
- Search through files (UNDERSTAND)
- Decide to create a summary file (PLAN)
- Read each file with TODOs (ACT)
- Compile the information (CHECK)
- Write the summary file (ACT again)
- Report what it found (DONE)
-
Notice how Claude used multiple tools in sequence without you telling it which tools to use. That is the agent loop in action.
What You Learned
- An agent is an AI system that takes actions to achieve goals, not just generates text
- Claude Code is an agent — it reads, edits, runs commands, and uses external tools
- The agent loop is: understand, plan, act, check, repeat, done
- Claude operates in agentic mode (takes action) or conversational mode (discusses) based on how you phrase your request
- Understanding agents is the foundation for working with subagents in the next lessons
How was this lesson? Take 2 minutes to share your feedback — it helps us make the tutorials better for everyone.