Subagents in Claude Code and Codex: what they are and how to make your own
What subagents are in Claude Code and Codex, when they help, how to define your own in .claude/agents or .codex/agents, and how to call one.


The short answer
A subagent is a helper the main agent starts for one side task. It works in its own context, with its own instructions and tools, and hands back only a summary, so search results, logs and long files don't fill up your main conversation. Both Claude Code and Codex have built-in subagents and let you define your own. Each subagent makes its own model calls, so it uses more of your quota than doing the work in one thread.
| Claude Code | Codex | |
|---|---|---|
| Built in | Explore (read-only search), Plan and others | default, worker, explorer |
| Your own, for one project | .claude/agents/<name>.md | .codex/agents/<name>.toml |
| Your own, for every project | The agents folder in the .claude folder in your home folder | The agents folder in your Codex home folder |
| When it delegates | On its own, from each subagent's description, or when you ask | When you ask, or when AGENTS.md or a skill says to |
Claude Code subagents
---
name: code-improver
description: Scans files and suggests improvements for readability, performance, and best practices. Use after writing or modifying code.
tools: Read, Grep, Glob
model: sonnet
---
You are a code improvement specialist. For each issue you find, explain
the problem, show the current code, and provide an improved version.- A subagent is a Markdown file with YAML frontmatter:
name, adescriptionClaude uses to decide when to delegate, thetoolsit may use and themodelit runs on; the body is its system prompt. You can also describe the subagent you want and ask Claude to write the file. - Call one by name (“Use the code-improver agent on this project”), @-mention it from the typeahead, or start a whole session as it with
claude --agent code-improver. - Keep descriptions short: they sit in Claude's context, and Claude Code warns at startup when your subagents' descriptions add up to more than 15,000 tokens.
- To stop delegation entirely, deny the
Agenttool underpermissions.denyin settings.json.
Codex subagents
name = "pr_explorer"
description = "Read-only codebase explorer for gathering evidence before changes are proposed."
model_reasoning_effort = "high"
developer_instructions = """
Stay in exploration mode.
Do not edit files.
"""- Current Codex releases have subagents on. Ask for them directly (“explore these three modules in parallel with subagents”), or write in AGENTS.md or a skill when Codex should delegate. In the CLI,
/subagentslists the agent threads and lets you switch to one while they run. - Each custom agent is one TOML file and must have
name,descriptionanddeveloper_instructions; it can also setmodelandmodel_reasoning_effort. It inherits the parent's permissions, model provider and MCP servers, and can't override them. A custom agent named like a built-in one, such asexplorer, replaces it. - Limits and defaults go under
[agents]in config.toml:max_concurrent_threads_per_session,default_subagent_model, andenabled = falseto turn subagents off. - OpenAI's advice: parallel subagents suit read-heavy work such as exploration, tests and triage. Be careful with several agents editing code at once; they can conflict.
Article · Codex config.toml: where it is, and the settings worth changing → Codex config.toml: where the [agents] settings go.
Subagents in Mirasim
- Settings › Agents › Subagents lists Claude Code's own subagent files with the model, effort and tools each will run with. Create, edit, turn off, duplicate or delete one there, or override a built-in; every change is made to the subagent's file, so Claude Code in your terminal sees the same thing.
- You can pick one subagent as the default, so every Claude Code session in Mirasim runs as it, the same as starting with
--agent. - Type @ in the composer to pick a subagent. While a session runs, each subagent it starts shows as its own block with its task, the steps it took and its result.
- When the work is bigger than a side task, run it as a separate session instead: Mirasim runs sessions side by side, each in its own pane and, if you like, its own worktree.
Article · Running two coding agents in one repository → Running several coding agents on one repository, each in its own worktree.
Questions
- Subagents or agent teams?
- A subagent does one side task and reports back to the agent that started it. In Claude Code's agent teams, a lead session splits the work across Claude teammates, each a Claude Code session of its own.
- Do subagents cost more?
- Yes. Each one makes its own model calls, and in Claude Code they count toward the same usage limits as your main conversation.
- Can a subagent use a cheaper model?
- Yes. Set
modelin a Claude Code subagent's frontmatter, such ashaiku, ormodelin a Codex custom agent's TOML file.
Article · Claude Code agent teams, and teams that mix agents and people → Claude Code agent teams: several sessions working on one task.
Sources
Checked on November 26, 2026 against Anthropic's Claude Code documentation (code.claude.com/docs, Create custom subagents) and OpenAI's Codex documentation (learn.chatgpt.com/docs, Subagents). Both change often, so check those pages for the latest fields and built-in agents.
Keep reading

Code review with Claude Code and Codex: /review, GitHub reviews and a second opinion
Code review with Claude Code and Codex: /review for local changes, automatic GitHub PR reviews, where review rules go, and a second opinion from the other agent.

Hooks in Claude Code and Codex: run your own commands when the agent acts
What hooks are in Claude Code and Codex, where they go, when they fire, and examples: a notification, formatting after edits, blocking edits to protected files.

Claude Code and Codex permission modes: auto, plan, --dangerously-skip-permissions and --yolo
What each Claude Code and Codex permission mode allows without asking, what --dangerously-skip-permissions and --yolo turn off, and safer ways to get fewer prompts.