Subagents are normally something Claude calls. You can also be the one who talks to them.
A subagent is a Markdown file with YAML frontmatter in .claude/agents/, or in ~/.claude/agents/ for all your projects. Only name and description are required.
---
name: code-reviewer
description: Reviews code for quality and security
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer. Give specific, actionable feedback.
Start Claude Code as that agent and the main thread takes on its tool restrictions and model.
claude --agent code-reviewer
To make it the default in a project, set "agent": "code-reviewer" in .claude/settings.json. The flag overrides the setting.
I like this for read-only work. A reviewer with only Read, Glob and Grep cannot edit anything, no matter what I type at it.
A subagent normally works in its own context and reports back to the main conversation. Running the whole session as the agent has no hand-off: you talk to it directly. That suits a role you want for the whole sitting, like a reviewer or a docs writer, with the tools and model that role needs and nothing more.
The caveat: creating the first agent file in a brand new agents directory needs a restart. After that, edits are picked up within seconds.
Further reading: Create custom subagents – Claude Code docs, On this site: name your Claude Code sessions and resume them by name, On this site: claude -w gives every session its own git worktree