Scenario: Developer Productivity with the Agent SDK
The full picture
The exam tells one story here. An agent is built on the Claude Agent SDK. It helps engineers explore code they do not know. It explains legacy systems. It writes boilerplate. It automates small jobs.
The cast of this lesson:
- Built-in tools: Read, Write, Bash, Grep, Glob.
- Subagents, which take one focused side question.
- Sessions, which keep what the agent already learned.
- MCP servers, which bring in outside context like Jira.
The exam tests four things. Which tool you pick. How you explore a codebase. When you resume a session. How you use MCP servers.
flowchart TD
A["Engineer asks a question"] --> B{"What does the agent need?"}
B -->|"Find code"| C["Pick the right tool<br/>Grep, Glob, Read, Bash"]
B -->|"Understand a flow"| D["Follow the thread<br/>Grep, Read, imports"]
B -->|"We looked at this before"| E["Resume the session"]
B -->|"Outside data"| F["MCP server<br/>tools and resources"]
C --> G["Answer"]
D --> G
E --> G
F --> G
D -.->|"Too big for one agent"| H["Subagents"]
H --> G- Search inside files → Grep. Find files by name → Glob.
- Explore by following the thread. Grep, then Read, then imports.
- Old analysis plus a new question → resume the session.
1. Pick the right tool
Every other part of this lesson uses these tools. So start here.
| What you need | Tool |
|---|---|
Find text or a pattern inside files, like eval( | Grep |
| Find files by name or path pattern | Glob |
| Understand one file | Read |
| Run commands or tests | Bash |
| Edit fails again and again on one file | Read then Write the whole file |
| Hand off a focused side investigation | Subagent (the Agent/Task tool) |
Simple way to keep it straight:
- Grep looks at what is written in the file.
- Glob looks at the file name and path only.
2. Explore a codebase by following the thread
You know the tools. Now use them in the right order.
flowchart LR
A["Grep for entry point<br/>(error string, function name)"] --> B["Read matching files"]
B --> C["Follow imports and calls"]
C --> D["Map the flow step by step"]Here is how the exam phrases it:
- Runtime error → Grep the distinctive error string. Then Read the matches.
- Auth flow → Grep the entry points. Read them. Follow imports step by step.
- Re-exported function → Read the library and the wrapper first. Find all exposed names. Then Grep each name.
- Whole-repo refactor priorities → Use Glob and Grep to map the structure. Plan by impact. Change the plan as you learn more.
- Deep error path → Let the agent create subtasks as it discovers things.
Never read the main entry file and guess the usages. Grep for them.
3. Session decisions
Exploration takes time. Sessions save that work for the next question.
| Situation | Correct move |
|---|---|
| New question about code analyzed yesterday | Resume the session |
| Resume a session you gave a name | --resume <name> |
| Some files changed since the analysis | Resume. Say which files changed. It re-reads only those |
| A function was renamed (small change) | Resume. Tell it about the rename |
| Compare 2–3 different approaches | Fork the session. One branch per approach. They share the start context |
| Long chat, context is bloated | Summarize old turns. Or save findings to a scratchpad file and point to it |
| Two independent explorations at once | Subagents with focused questions. The main agent coordinates |
| Done with rendering, now the physics topic | Summarize the findings. Spawn a subagent with the summary in its context |
The pattern is easy. Small change means resume and update. A new direction means summarize and hand off.
4. MCP servers
Sessions cover your own code. MCP servers bring in everything outside it.
- Need Jira or ticket context → use the existing Jira MCP server. Do not scrape it. Do not rebuild it.
- Need to expose docs, schemas, or read-only content → use MCP resources. Do not make them tools.
- The agent keeps using Bash or text tricks instead of MCP tools → expand the MCP tool descriptions. Describe what they do, their inputs, their outputs, and when to prefer them.
Discovery, two answers to know:
| Source | What it says |
|---|---|
| Exam answer | All configured servers' tools are discovered at connect time. They are all available at the same time |
| Current docs | Tool names load at start. Full definitions load on demand through tool search. All are still usable |
5. Traps
These wrong answers look right on the exam. Learn to spot them.
- ❌ Using Glob to search file contents.
**/*eval*finds file names, not code. - ❌ Re-reading every file after one small change.
- ❌ Starting a new session when resume plus a short update is enough.
- ❌ Reading the main entry file and guessing the usages instead of using Grep.
Recap
- The story: an Agent SDK agent explores codebases, explains legacy systems, writes boilerplate, and automates tasks.
- It uses Read, Write, Bash, Grep, Glob plus MCP servers.
- Grep searches inside files. Glob matches file names and paths.
- Read understands one file. Bash runs commands and tests.
- Edit fails again and again → Read then Write the whole file.
- Focused side investigation → subagent (Agent/Task tool).
- Exploration order: Grep the entry point, Read the matches, follow imports.
- Runtime error → Grep the distinctive error string, then Read matches.
- Auth flow → Grep entry points, Read, follow imports step by step.
- Re-exported function → Read the library and the wrapper. Find all exposed names. Then Grep each one.
- Refactor priorities → Glob and Grep to map structure. Plan by impact. Revise.
- Deep error path → the agent generates subtasks as it discovers.
- New question about yesterday's work → resume.
- Resume by name →
--resume <name>. - Files changed → resume and name the changed files for a targeted re-read.
- Rename → resume and tell it about the rename.
- Compare 2–3 approaches → fork the session, one branch each, shared context.
- Context bloated → summarize old turns, or use a scratchpad file.
- Two parallel explorations → subagents, main agent coordinates.
- Topic switch → summarize, then spawn a subagent with the summary.
- Jira context → the existing Jira MCP server.
- Docs and schemas → MCP resources, not tools.
- Exam answer: all server tools are discovered at connect time and are available at the same time.
- Current docs: names at start, full definitions on demand via tool search.
- Agent ignores MCP tools → expand the tool descriptions.
- Traps: Glob for contents, re-reading everything, a new session instead of resume, and guessing usages instead of using Grep.