This blog series focuses on presenting complex DevOps projects as simple and approachable via plain language and lots of pictures. You can do it!
These articles are supported by readers, please consider subscribing to support me writing more of these articles <3 :)
Hey all!
Last article we built the orchestrator pattern, a single CLAUDE.md file that coordinates five agents through a full development pipeline. If you missed it:
That article covered the pipeline flow and how agents hand off work to each other. This one zooms in on how each agent is configured. The file configuration, what’s optional and what’s not, and the design decisions we made to make the autonomous development pipeline reliable.
Now lets talk how we can configure the sub-agents!
Agent Files Are (Just) Markdown
Each agent is defined in a single markdown file inside “.claude/agents/”, one file per agent. The Coder agent lives in “.claude/agents/coder.md”, the CodeReviewer in “.claude/agents/code-reviewer.md”, and so on.
The real config is in the YAML frontmatter block at the top. Here’s what the CodeReviewer’s looks like:
---
name: code-reviewer
description: Code review specialist that reviews all Python and Terraform
changes. Enforces quality standards, catches bugs, and reports issues.
Does NOT fix code - reports findings for the main agent to delegate
to a Coder.
tools: Read, Glob, Grep, Bash
model: opus
---Four required fields do all the work:
“name” is the identifier. When the orchestrator spawns an agent with “subagent_type=”code-reviewer”“, Claude Code looks for the agent file where “name” matches that string.
“description” tells Claude Code when this agent is the right one to use. It’s a hint for the system, not just documentation.
“tools” controls what the agent can do. This is a comma-separated list of Claude Code tools the agent gets access to. If a tool isn’t listed here, the agent can’t use it.
“model” picks which Claude model runs this agent. Sonnet, Opus, or Haiku.
Everything below the yaml frontmatter is the agent’s system prompt, written in plain markdown. You can put anything there: role descriptions, checklists, code examples, output format templates, and the agent will read it as its instructions when it starts up.
Frontmatter is a term from yaml, the required header for the file. Not all attributes in the front-matter are required, but the front-matter itself is required to be recognized as a valid agent.
The agent doesn’t know it’s a subagent, it doesn’t know there’s an orchestrator coordinating a pipeline. It just reads its instructions, does the work, and returns a result. The orchestrator handles all the coordination logic from the outside, which means each agent file can be simple and focused on a single job.
And in case you’ve read about dynamic workflows where agents calls agents, who call agents - this isn’t that. This stub agent is called by the orchestrator, returns a result only to the orchestrator, and dies. It can’t call or speak with any other agent.
Picking the Right Model for Each Job
There are two kinds of work in the pipeline: execution and judgment.
Execution is “implement this feature per the spec” or “check whether all the requirements are met.” The instructions are clear, the scope is defined, and the agent needs to move fast. The Coder and Reviewer both do execution work, so they run on Sonnet. It’s fast, follows instructions well, and costs less per token.
Judgment is “is this code safe to deploy?” or “did the bot actually respond correctly?” These are harder questions with ambiguous answers. The CodeReviewer and User both do judgment work, so they run on Opus. It catches subtler bugs, makes better go/no-go calls, and is worth the extra cost when the decision matters.
There is a cost and speed trade-off. You don’t want Opus grinding through boilerplate Terraform implementations. But you also don’t want Sonnet deciding whether a missing input validation is a blocking security issue or a harmless edge case.
The User agent illustrates an over-ride. Its agent file uses “subagent_type” of “general-purpose” because it doesn’t have a dedicated agent type. But the orchestrator explicitly sets “model” to “opus” in the spawn call:
Agent(
description=”Live bot validation via Slack”,
subagent_type=”general-purpose”,
model=”opus”,
prompt=”You are the User Agent. Read your instructions
from: .claude/agents/user.md ...”
)The “model” override in the spawn call takes precedence over whatever the agent file says. This is useful when you want an agent to use a different model for a specific task without changing the agent definition permanently.
This model split is based on good decisions, but isn’t science - it’s what I thought made sense. I might change these models as they prove to be too costly, or too unintelligent, to do the jobs I need them to do. You might find different breakpoints for your codebase.
Tool Scoping is a Security Boundary
Each agent gets a specific set of tools in its frontmatter “tools:” field. This is the list of Claude Code tools that agent can access during its run. Anything not on the list is off limits.
Claude Code has a long list of tools you can assign to subagents. These are the ones that matter most for agent design:
“Read” - Reads file contents. Also handles images, PDFs, and Jupyter notebooks.
“Write” - Creates new files or overwrites existing ones entirely.
“Edit” - Makes targeted string replacements inside existing files. Safer than Write because it only changes what you specify.
“Glob” - Finds files by pattern. Useful for discovering what exists in the codebase (e.g., all “*.py” files under “worker/src/”).
“Grep” - Searches file contents for patterns. Respects “.gitignore” so it won’t waste time on dependencies.
“Bash” - Runs shell commands. This is how agents run syntax checks, git commands, and anything else that needs a terminal. This is obviously a broad permission.
“WebFetch” - Fetches and extracts content from URLs. Useful if an agent needs to read documentation or API references.
“ToolSearch” - Searches for and loads MCP tools at runtime. This is how the User agent loads Slack tools on the fly.
There are more (task management, scheduling, worktrees) but these are the ones you’ll actually put in a subagent’s tool list.
One tool that subagents explicitly cannot use is “Agent”, the tool that spawns other subagents. Even if you listed it in the frontmatter, Claude Code won’t let a subagent use it. Only the main conversation agent can spawn agents. This is the architectural constraint from article 1 that forces all coordination through the orchestrator.
With those tools defined, here’s how we scoped each agent:
The Coder gets the full set: “Read, Write, Edit, Glob, Grep, Bash”. It needs to read files, write new ones, edit existing ones, search the codebase, and run shell commands to verify its work. It’s the only agent that can change files.
The CodeReviewer gets: “Read, Glob, Grep, Bash”. Same as the Coder minus Write and Edit. It can look at everything, run syntax checks, grep for patterns, but it cannot modify a single file. The Reviewer gets the same read-only set.
The User agent gets “Read, Glob, Grep, Bash” in its agent file, but in practice it only uses Slack MCP tools that it loads at runtime via ToolSearch. It has no reason to touch code files and never does.
The focus here is minimum access. If an agent doesn’t need to write files, don’t give it Write. If it doesn’t need to run shell commands, don’t give it Bash. You can always add tools later if a job requires them.
If you’ve worked with LLMs at all, you know they love to be helpful - sometimes too helpful. Assigning the tools a sub-agent can use helps an AI agents with a “Reviewer” job that want to “just clean it up real quick” and bypass your normal SDLC process. The tool list is a hard boundary that the agent cannot talk its way around, no matter how helpful it’s trying to be.
The “Report Don’t Fix” Pattern
Tool scoping keeps agents from writing files they shouldn’t. But we also need to tell them explicitly, because LLMs will find creative workarounds if they think they’re being helpful.
Both the CodeReviewer and Reviewer have this line in their instructions:
“You are a review-only agent. You cannot spawn other agents or write code. Report your verdict and the main conversation agent will delegate fixes to a Coder if needed.”
Without this, a reviewer that can’t edit files might still try to help. It might output a full code block “for the Coder to copy,” or attempt to write a file and burn through retry attempts when it gets permission errors. The explicit instruction tells the agent what its job boundaries are so it doesn’t waste time trying to work around the tool restrictions.
The separation matters for the same reason it matters on a human team. If the person reviewing code is also the person who wrote it, the review isn’t independent anymore. Our CodeReviewer finds problems and writes specific fix instructions. The orchestrator passes those instructions to the Coder. The Coder implements the fix. Then the CodeReviewer reviews again. Nobody reviews their own work.
The CodeReviewer’s output format makes this concrete. When it finds issues, it doesn’t output code. It outputs fix instructions:
### Instructions for Coder (if changes requested)
1. [Specific fix instruction]
2. [Specific fix instruction]Those instructions are specific enough that the Coder knows exactly what to change, but they’re written in plain language, not code. The CodeReviewer describes the fix. The Coder decides how to implement it. Two different agents, two different perspectives on the same problem.
Output Contracts
The orchestrator makes branching decisions after every phase. APPROVED means proceed to the next phase. CHANGES_REQUESTED means loop back to the Coder. There’s no “mostly approved” or “approved with minor concerns.”
This only works if every agent returns its verdict in a predictable format. So each agent has a structured output section in its instructions that defines exactly what it returns.
The CodeReviewer returns a verdict of “APPROVED” or “CHANGES_REQUESTED”, plus a categorized list of issues sorted by severity:
### Issues Found
#### BLOCKING (must fix)
1. [File:Line] - [Issue description]
- Problem: [what’s wrong]
- Fix: [how to fix it]
#### WARNINGS (should fix)
1. [File:Line] - [Issue description]
#### SUGGESTIONS (optional)
1. [File:Line] - [Suggestion]
### Verdict
APPROVED / CHANGES_REQUESTEDThe Reviewer returns “FEATURE_APPROVED” or “FEATURE_INCOMPLETE”, plus a prioritized list of gaps with acceptance criteria for each.
The User agent returns “UX_APPROVED” or “UX_NEEDS_WORK”, plus a per-test breakdown showing what message was sent, what response came back, and whether it passed.
The Coder returns “TASK_COMPLETED: true/false”, plus a list of files modified, verification results (syntax checks, Terraform validation), and what it added to its notebook.
The severity categories in the CodeReviewer’s output matter too. BLOCKING issues must be fixed before the review can pass. WARNINGS should be fixed but won’t block approval on their own. SUGGESTIONS are optional. This gives the orchestrator (and the human watching) a clear picture of how serious the problems are without having to read every line of feedback and make a judgment call.
Project-Specific Checklists
The CodeReviewer’s agent file includes a review checklist with five categories and about 25 specific items. These aren’t generic “write good code” guidelines. They’re tuned to this project.
The security section checks for things that matter in an AWS Slack bot:
### 2. Security
- No hardcoded secrets, tokens, or API keys
- Secrets retrieved from AWS Secrets Manager
- No hardcoded AWS account IDs or ARNs (use variables)
- Proper input validation at system boundaries
- No command injection vulnerabilities
- IAM policies follow least-privilege principleThe AWS and infrastructure section checks for Terraform patterns specific to this codebase:
### 3. AWS & Infrastructure
- Terraform follows existing patterns
- IAM roles are scoped appropriately
- Resource naming follows project conventions
- Environment-specific values in tfvars, not hardcoded
- No unnecessary permissions in IAM policiesA generic code reviewer wouldn’t know to check for hardcoded AWS account IDs or that this project keeps environment-specific values in tfvars files. This one does because we told it to. The checklist is the agent’s institutional knowledge about what matters in this project, written once and applied on every review.
This is where customization pays off. You could copy this agent file to a different project and swap out the checklist items for whatever matters there. A Rails app might check for N+1 queries and unscoped ActiveRecord calls. A GCP project might check for hardcoded project IDs and missing IAM bindings. The agent structure stays the same, only the checklist changes.
The checklist is static - written by a human, updated when the project’s standards change. But each agent also has a notebook (covered in a later article) that accumulates dynamic learnings the agent discovers on its own. The checklist tells the agent what to look for. The notebook teaches it what to watch out for.
Summary
The full code is open source:
Next up, we’ll look at Claude Code skills, the deployment automation that actually pushes code to AWS. That’s where the orchestrator’s Phase 4 comes to life.
Happy Automating!
kyler



