Tutorials · October 8, 2026
How to Set Up Claude Code Sub-Agents with a Review Loop
Learn how to configure Claude Code sub-agents using Opus and Sonnet in a review loop to improve code quality in the terminal.
If you build software primarily in the terminal using AI coding agents, you may encounter weekly usage limits. A recent r/ClaudeAI thread shows people asking how to handle this, with 13 comments recorded when read. The solution documented for this is using Claude Code sub-agents. By splitting responsibilities between models like Opus and Sonnet, and establishing review loops between agents, you can structure your workflow effectively.

What you need
- A terminal environment running Claude Code.
- Access to multiple models (such as Opus and Sonnet) via your subscription tier.
- Familiarity with delegating tasks in the terminal rather than relying on a single conversational thread.
Before setting this up, check the official Anthropic documentation for the exact commands and controls for spawning different models, as control names and flags can change between updates.
How to set up Claude Code sub-agents
The core strategy is delegation. You use one model to plan and review, and another to execute the actual coding legwork. According to the Claude Code Documentation on sub-agents, you can configure these roles directly in your workflow.
- Define the orchestrator role. Establish that your primary session will act as the orchestrator. The Claude Code Documentation covers setting up different models such as Opus and Sonnet for delegated tasks. Its job is not to write the final code, but to break down the user's request into a clear specification and decide what level of effort the task requires.
- Delegate implementation to a worker agent. Use the sub-agent functionality documented in the Claude Code Documentation to spawn a secondary agent for the heavy lifting. Configure this sub-agent to use Sonnet. Pass the specification generated by your orchestrator to this worker.
- Establish a review loop. The Claude Code Documentation explains how to establish review loops between agents. Once the Sonnet sub-agent finishes the implementation, pass the resulting code back to a separate instance or differently prompted sub-agent to review the work against the original specification.
- Review the spec before implementation. Expand the review loop further by having a separate agent review the orchestrator's specification before any code is written. The Claude Code Documentation explains how to chain these delegated tasks.
- Route based on complexity. Not every prompt needs a multi-agent loop. Use your orchestrator to evaluate the request. If it is a simple one-off question or a short analysis job, handle it directly. Reserve the full pipeline for complex feature builds.
Where this goes wrong
Setting up Claude Code sub-agents introduces friction. The most common failure point is context loss between the orchestrator and the worker. If the orchestrator agent writes a vague specification, the worker agent may hallucinate requirements, and the reviewing agent will approve code that solves the wrong problem. Always ensure the handoff includes explicit constraints, file paths, and expected behaviors.
Another pitfall is over-engineering simple tasks. Spawning sub-agents and running review loops for a minor CSS tweak wastes time. Your orchestrator must be strictly instructed to bypass the loop for trivial requests.
Here is a worked example you can adapt to enforce this structure:
# Agent Workflow Rules
1. When I ask for a new feature, analyze the complexity.
2. If complex:
a. Write a technical specification.
b. Spawn a sub-agent to review this specification for edge cases.
c. Once approved, spawn a Sonnet sub-agent to implement the code based ONLY on the reviewed spec.
d. Spawn a separate review agent to check the implementation against the spec.
3. If simple (e.g., fixing a typo, renaming a variable): Execute immediately without sub-agents.
4. Never allow the implementing agent to review its own code.
By treating your terminal workflow as a managed pipeline rather than a single chat window, you maintain high code quality. Confirm the current syntax for spawning these agents in the official help documentation to ensure your setup matches the latest release.