Definition
A Claude Code agent, or custom subagent, is a Markdown file with YAML frontmatter that defines a reusable specialist, such as a code reviewer, that Claude Code can hand work to.
Also called: custom subagent, subagent definition, agent file.
The frontmatter says who the agent is and what it may do; the Markdown below it is the agent's instructions (its system prompt). Only name and description are required. The description matters most, because Claude reads it to decide when to delegate.
---
name: code-reviewer
description: Reviews a diff for bugs and missing tests. Use after changing code.
tools: Read, Grep, Glob
model: sonnet
---
Review the changes. List real problems first, each with file and line.Optional fields include tools and disallowedTools, model, permissionMode, maxTurns, skills, mcpServers, hooks, memory, background, effort and isolation. When two agents share a name, the higher scope wins:
| Scope | Where |
|---|---|
| Organisation (highest) | managed settings |
| One session | the --agents CLI flag |
| Project | .claude/agents/ in the repo, usually committed for the team |
| Personal | ~/.claude/agents/, for all your projects |
| Plugin (lowest) | an installed plugin's agents/ folder |
You can use an agent by naming it in a prompt, @-mentioning it, or running a whole session as it with --agent. When it runs, it works as a subagent.
In Pairbar
The Agents tab lists every personal, project and plugin agent Claude Code would load. New agent, Improve, Turn this chat into an agent and Teach an agent from this chat open a Claude chat that writes or edits the file for you; Edit manually is a form. Add to Codex exports an agent to ~/.codex/agents/<name>.toml, and an optional dock.yaml adds groups, icons and ready-made commands. See Agents.
Frequently asked questions
- Where do I put a Claude Code agent file?
- In
.claude/agents/inside a repo for a project agent, or in~/.claude/agents/for one you want in every project. - Which frontmatter fields are required?
- Only
nameanddescription. Tools, model, permission mode and the rest are optional. - Can Codex use my Claude Code agents?
- Not directly; Codex defines custom agents as TOML files in
~/.codex/agents. Pairbar's Add to Codex exports a Claude agent into that format.
Related
- GuideCreate a Claude Code agent (subagent) with Pairbar or by handMake a Claude Code agent with New agent, refine it with Improve and Teach, or write the Markdown file by hand; then export it to Codex.
- Use caseCreate, improve and manage Claude Code agents without editing Markdown by handThe Agents tab lists every Claude Code agent you have; New agent, Improve, Turn chat into agent and Teach start a Claude chat that writes the file.
- GuideOrganise your Claude Code agents with dock.yamlUse dock.yaml to group agents, set a repo and icon, and add ready-made commands with {input} that appear in Pairbar.
- GlossarySubagentA helper agent a main coding agent starts for one piece of work, with its own context, returning only a summary.
- DocsAgentsYour Claude Code agents: where they come from, the Agents page, creating and improving them with Claude, `dock.yaml`