What is a Claude Code agent?
An agent is a markdown file in .claude/agents/ that gives Claude a specific role, tools, and constraints. Instead of one general-purpose assistant, you get specialized team members: a product manager who plans, a developer who codes, a tester who verifies.
| Solo | Agent Team | |
|---|---|---|
| Planning | Ad-hoc, mixed into conversation | PM breaks into structured tasks |
| Implementation | Generic instructions every time | Developer follows focused rules |
| Review | Self-review (easy to miss things) | Separate reviewer with a checklist |
| Process | Manual — you manage every step | PM delegates and tracks automatically |
| Quality | Inconsistent | Consistent — same checks every time |
Agent file structure
Every agent file has two parts: YAML frontmatter (configuration) and markdown body (instructions).
---
name: product-manager
description: >-
Feature planning orchestrator who breaks requests
into RICE-prioritized tasks and delegates to specialists.
model: opus
tools:
- Read
- Grep
- Glob
- Task
permissionMode: plan
memory: project
---
# Product Manager
You are the product manager for this project.
You plan features, prioritize work, and delegate
to the right agent.
## Responsibilities
1. Break features into prioritized tasks
2. Delegate to developer for implementation
3. Verify outputs meet acceptance criteria
## Rules
- Never implement code yourself
- Use RICE scoring for prioritizationFrontmatter fields explained
| Field | Required | Description |
|---|---|---|
| name | Yes | Kebab-case identifier, must match filename |
| description | Yes | When Claude should use this agent (be specific) |
| model | No | opus, sonnet, or haiku (defaults to inherit) |
| tools | No | Array: Read, Grep, Glob, Edit, Write, Bash, Task, etc. |
| permissionMode | No | default, plan, acceptEdits, dontAsk, or bypassPermissions |
| memory | No | user, project, or local |
Choosing the right model
| Model | Best for | Trade-off |
|---|---|---|
| opus | Planning, architecture, complex reasoning | Slowest, most capable |
| sonnet | Implementation, code generation, reviews | Good balance of speed and quality |
| haiku | Fast lookups, simple checks, research | Fastest, least capable |
Rule of thumb: use opus for agents that orchestrate other agents, sonnet for agents that write code, haiku for agents that gather information.
Permission modes
- default — Standard permission checking with prompts for each action. The safest starting point.
- plan — Read-only exploration mode. Agent can read and search but cannot modify files. Good for PMs and reviewers.
- acceptEdits — Auto-accepts file edits without prompting. Good for developer agents where you trust the changes.
- dontAsk — Auto-denies permission prompts. Explicitly allowed tools still work, but anything requiring approval is silently denied. Use for agents that should only use pre-approved tools.
- bypassPermissions — Skips all permission checks entirely. Use with extreme caution — only for fully trusted agents in controlled environments.
Start with plan and loosen permissions as you build trust in the agent's behavior.
Writing effective agent instructions
The markdown body after frontmatter is your agent's system prompt. Generic instructions produce generic results. Be specific:
"You are a helpful code reviewer. Review code carefully and provide feedback."
"Check that every new function has error handling. Flag any console.log left in production code. Verify API responses match the TypeScript types."
- List responsibilities as numbered items
- State exactly what to check, not "review carefully"
- Add anti-patterns with bad/good examples
- End with a Rules section of hard constraints
Common mistakes
- Using
permissioninstead ofpermissionMode— the correct field name is permissionMode - Nested memory config — use
memory: project, not a nested object - Full model IDs — use
opusnotclaude-opus-4-6 - Filename mismatch — the
namefield must match the filename without .md
Skip the setup
These guides are extracted from production-tested agent configurations. If you want working agents without writing them from scratch: