← Blog

How-to5 min read

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.

Two coding agents running side by side in Mirasim, each in its own paneTwo coding agents running side by side in Mirasim, each in its own pane

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 CodeCodex
Built inExplore (read-only search), Plan and othersdefault, worker, explorer
Your own, for one project.claude/agents/<name>.md.codex/agents/<name>.toml
Your own, for every projectThe agents folder in the .claude folder in your home folderThe agents folder in your Codex home folder
When it delegatesOn its own, from each subagent's description, or when you askWhen you ask, or when AGENTS.md or a skill says to

Claude Code subagents

.claude/agents/code-improver.md
---
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, a description Claude uses to decide when to delegate, the tools it may use and the model it 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 Agent tool under permissions.deny in settings.json.

Codex subagents

.codex/agents/pr-explorer.toml
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, /subagents lists the agent threads and lets you switch to one while they run.
  • Each custom agent is one TOML file and must have name, description and developer_instructions; it can also set model and model_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 as explorer, replaces it.
  • Limits and defaults go under [agents] in config.toml: max_concurrent_threads_per_session, default_subagent_model, and enabled = false to 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.

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.

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 model in a Claude Code subagent's frontmatter, such as haiku, or model in a Codex custom agent's TOML file.

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