AI coding tools are paying more attention to subagents. This is not just feature chasing. A single agent eventually hits limits when it has to handle real engineering work.
If one agent reads code, checks logs, edits implementation, runs tests, analyzes failures, and summarizes results at the same time, the main context quickly becomes noisy. Search results, command output, test logs, and intermediate reasoning get mixed together. Later decisions become less reliable. Work also becomes hard to parallelize: exploration, implementation, verification, and review all sit on one main thread.
The purpose of subagents is to reduce that pressure. The main session stops doing everything from start to finish and becomes more like a coordinator: define goals, assign work, receive results, and merge them into the final answer. A subagent handles a local piece of work, such as exploration, implementation, verification, or review, and returns a compressed conclusion.
So a subagent is not “another copy of me.” It is a way to split tangled engineering work into clearer roles.
Shared Foundations
A mature subagent system usually needs four foundations:
- Context isolation.
- Role specialization.
- Project and user-level configuration.
- Tool and permission boundaries.
Context isolation comes first. Real repositories produce a lot of intermediate material: dozens of search hits, hundreds of test log lines, noisy command output. If all of that is poured into the main session, the main thread gets confused. A subagent can digest that local process and bring back only the signals that matter.
Role specialization is just as important. Multi-agent does not mean opening several identical models. Exploration roles should search, read, and summarize. Implementation roles should focus on local code changes. Verification roles should run checks, identify risks, and report clearly.
Tool and permission boundaries determine whether the system can be used safely. A subagent should not automatically inherit every capability of the main session. A read-only explorer does not need write access. A verifier may not need to change implementation. Background tasks and isolated worktrees need visible boundaries.
Codex and Claude Code share these concerns, but they take different routes.
Codex: Explicit Delegation
Codex’s subagent design feels restrained.
It gives you a controlled, lightweight delegation mechanism around the current main session. When to delegate, who receives the task, and when results are collected are all explicit decisions. The control flow stays in the current task.
Its traits are clear:
- The main session explicitly delegates subwork.
- The role set stays small.
- The main session knows which agent is doing what.
- Results return to the main line for final judgment.
- Collaboration boundaries are transparent.
This works well for teams that care about manual orchestration, predictability, and execution determinism. You can ask an explorer to inspect a call chain, ask a worker to make a bounded change, then let the main session merge the result and decide whether to test further.
The tradeoff is that orchestration pressure still sits with the main session. The main thread must decide when to split work, how to split it, who should take it, and how to merge the result. For lightweight collaboration this is pleasant; for long-running engineering workflows it can become tiring.
Claude Code: Agents as Workstations
Claude Code takes a more platform-like route.
It treats agents as describable, selectable, configurable, memorable, isolated, and background-capable objects. A subagent is not just a helper in a conversation. It is closer to a workstation in an engineering system.
The system can expose agent lists, use cases, descriptions, and tool boundaries to the model, allowing the model to decide which role should handle a turn. That makes delegation more automatic.
Several capabilities define this direction.
First, a role system. Explorer, planner, general-purpose, and verifier roles can carry usage descriptions, tool restrictions, default models, and runtime conditions. A read-only explorer can be prevented from editing files. A planner can focus on architecture. A verifier can focus on checks.
Second, inheritance and overrides. A subagent is not completely free. It inherits the larger boundary of the main session by default, but can adjust local behavior within allowed rules. The main session defines the big boundary; the agent performs local assembly inside it.
Third, memory. Memory is not just “remember a few things.” It can have scope. User memory is like long-term preference. Project memory is repository background. Local memory is environment-specific state. This lets some agents avoid relearning the project from scratch.
Fourth, background work and worktree isolation. Some verification tasks can keep running in the background, while the main thread continues. When stronger isolation is needed, an agent can work in a separate worktree, keeping the project connected but the operation space separated.
Fifth, plugin ecosystem. If agents are first-class objects, you have to think about distribution, installation, priority, override rules, and safety. Plugin agents can enter the system, but high-risk fields such as permission mode, hooks, and MCP servers should remain guarded.
This makes Claude Code feel more like an agent runtime than a one-session collaboration tool.
The Difference
Codex is closer to a controlled delegation tool:
- Explicit delegation.
- Lightweight role set.
- Clean control flow.
- Subtasks centered on the current session.
- Good for deterministic, human-orchestrated work.
Claude Code is closer to an engineering workstation system:
- Agents are formally modeled.
- Roles are more systematic.
- Memory, background execution, isolation, and plugins are part of the runtime.
- The model can help choose roles.
- Good for long-term projects and platform-like workflows.
The real question is not which one has more features. It is whether you want a subagent to be “a helper I explicitly call” or “a long-lived workstation in the system.”
How to Choose
Choose the Codex style if you value explicit control, lightweight delegation, and safe parallelism inside the current session. It is good for code review, small changes, clearly scoped implementation tasks, and workflows where a human wants to keep the rhythm.
Choose the Claude Code style if you want systematic roles, long-term memory, background execution, worktree isolation, plugin extension, and a more complete agent runtime.
Ask two questions:
- Are you comfortable with the model choosing who should do the work?
- Do you need a fuller agent runtime?
If the first question makes you uncomfortable, explicit delegation is likely better. If the second answer is yes, a platform-like workstation system may fit better.
Practical Advice
Do not treat subagents as “more models means stronger.” Better practice is:
- Give every role a clear task boundary.
- Limit the tools each role can use.
- Ask subagents to return conclusions, not raw logs.
- Keep final decisions in the main session.
- Make background tasks and worktree isolation visible.
- Set clear safety boundaries for plugin agents.
The value of subagents is not quantity. It is clean division of labor, cleaner context, and more stable main-thread decisions.
Claude Code subagent project fit and implementation
Good Fit 1: Mapping a Large Codebase
When you inherit a large unfamiliar repo, the first problem is not “what code should I change?” It is “where should I even look?”
Subagents help here. The main session can ask questions and merge conclusions while exploration is delegated:
api-reader: routes, controllers, authentication.db-reader: schema, migrations, ORM models.frontend-reader: pages, state management, component entry points.test-reader: test framework, coverage, commands.
Each subagent returns 5 to 10 findings. The main session keeps a map instead of carrying the entire repository in context.
This is useful for monorepos, legacy systems, mixed frontend/backend repos, scattered build scripts, and technical-debt assessment.
If you are designing a Codex and Claude Code handoff, you can put this “read the repo and map the structure” work on the Claude Code subagent side, then give the result to Codex for longer changes. See: Codex and Claude Code Task Handoff Guide: From Implementation and Review to Long-Task Recovery.
Good Fit 2: Splitting Code Review Roles
Subagents fit code review because review naturally splits by concern:
bug-reviewer: logic errors, nulls, edge cases, regressions.security-reviewer: permissions, input validation, secrets, injection, authorization bypass.performance-reviewer: loops, queries, caching, rendering, concurrency.test-reviewer: whether tests cover real risk, not just snapshots.
Each subagent reads the same diff with a different lens.
The boundary is important: review subagents should default to read-only.
A safer flow:
- The main session collects the diff.
- Several read-only subagents review it.
- The main session merges conclusions.
- One explicit implementer applies small fixes.
For a closed review workflow between Claude Code and Codex, see: How to build a Claude Code and Codex code review workflow: from local changes to PR feedback.
Good Fit 3: Test Failures and Noisy Logs
Automated test failures often produce huge output. Frontend E2E, backend integration tests, and CI logs can hide the useful error in hundreds of lines.
A test-runner subagent can:
- run the requested test command;
- extract failing cases;
- summarize the likely reason;
- point to related files;
- avoid fixing code directly.
Useful roles:
| Subagent | Suggested tools | Task |
|---|---|---|
test-runner |
Bash, Read, Grep |
Run tests and explain failures |
log-analyzer |
Read, Grep, Glob |
Analyze logs and stack traces |
coverage-reviewer |
Read, Grep, Glob |
Find missing tests and risky branches |
If you already use Claude Code hooks to run tests automatically, hooks can trigger and subagents can explain failures: .
Good Fit 4: Impact Analysis Before Refactoring
Large refactors should not begin with edits. Subagents are useful for read-only reconnaissance.
For an authentication replacement, database access upgrade, or frontend state refactor, subagents can answer:
- Which files depend on the old interface?
- Which tests cover this logic?
- Which call paths are fragile?
- Do docs, scripts, or configs also need updates?
- Where should tests be added before editing?
The rule is: subagents output impact, not patches.
The main session then decides whether to change everything at once, split phases, or add tests first. This also makes long-task recovery easier because each phase has clear conclusions. See: .
Poor Fits: Do Not Split Everything
Subagents have cost: extra context, waiting time, and coordination.
They are usually not worth it for:
1. Tiny Fixes
Typos, imports, one CSS class, a null check, or a small config change are faster in the main session.
2. Unclear Requirements
“Optimize this project” or “make this page better” should be clarified before delegation. Otherwise subagents will diverge.
3. Tasks That Need Constant Discussion
Subagents are good at independent work, not back-and-forth design negotiation.
4. Multiple Agents Editing the Same Files
Let them review first, then have one implementer land the change.
5. High-Risk External Operations
Production, real accounts, paid APIs, deletion, permissions, emails, and messages should not be handed to background subagents without strict tool and scope limits.
Designing Project-Level Subagents
Claude Code supports Markdown subagent files. Project-level subagents usually live in:
|
|
Global reusable subagents usually live in:
|
|
Project-level agents should capture project-specific rules: test commands, directory structure, review priorities, forbidden files, and output format.
A minimal read-only reviewer:
|
|
The description is especially important because Claude Code uses it to decide when to delegate.
Common Subagent Set
Start with 3 to 5 roles:
| Name | Tools | Purpose |
|---|---|---|
code-reviewer |
Read, Grep, Glob |
Read-only review for bugs and regressions |
test-runner |
Bash, Read, Grep |
Run tests and explain failures |
docs-researcher |
Read, Grep, Glob |
Summarize docs, migration notes, conventions |
security-reviewer |
Read, Grep, Glob |
Review permissions, inputs, secrets, injection risk |
refactor-planner |
Read, Grep, Glob |
Analyze impact before large changes |
If a subagent repeatedly returns generic advice, its role is too broad. Narrow it or add project rules.
How to Call a Subagent
You can call it explicitly:
|
|
You can also name a specific subagent such as @code-reviewer, or start with:
|
|
For critical tasks, explicit calls are more reliable than automatic delegation. Say “read-only,” “do not edit files,” and “return conclusions only.”
A Simple Decision Formula
Ask five questions:
- Can the task be split by module, directory, role, or concern?
- Are subtasks independent enough?
- Can each subtask return a clear conclusion?
- Do different subtasks need different tool permissions?
- Is the context-isolation benefit greater than the extra token and waiting cost?
If three or more answers are yes, try subagents. If only one is yes, probably do not split.
Pitfall Checklist
- Use specific names, not
helper,assistant, orworker. - Write a trigger scenario in
description. - Keep review subagents read-only by default.
- Editing subagents should own one small scope at a time.
- For big refactors, analyze impact first.
- Test subagents should summarize failures, not dump logs.
- The main session merges outputs.
- Limit tools and scope for high-risk actions.
- Put project rules in
.claude/agents/; personal habits in~/.claude/agents/. - Periodically delete low-value or duplicate subagents.
References
Summary
Codex and Claude Code solve the same problem: one agent cannot comfortably carry all real engineering work. Both recognize the importance of context isolation, role specialization, permissions, and local summarization.
Codex is more restrained, emphasizing explicit delegation and main-session control. Claude Code is more systematic, treating agents as configurable, memorable, isolated, background-capable workstations that can also enter a plugin ecosystem.
The choice is not which brand wins. It is whether your workflow needs a controlled collaboration tool or a full agent runtime.