Skip to content
Agents & Orchestration Intermediate

Create a Custom Agent

Define a specialized agent with custom system prompt, tools, model, and permissions

Command

"color:#9CA3AF;font-style:italic"># ."color:#7C5CFC">claude/agents/code-reviewer.md
$ "color:#d97757">---
  name: code-reviewer
  description: Expert code review specialist
  tools: Read, Grep, Glob, Bash
  model: sonnet
  "color:#d97757">---
  
  You are a senior code reviewer.
  
  When invoked:
  1. Run "color:#7C5CFC">git diff to see changes
  2. Focus on modified files
  3. Review "color:#7C5CFC">for quality, security, and style

Response

// Use the agent:
claude --agent code-reviewer

// Or inline for CI:
claude -p "Review code" \
  --agents '{"reviewer":{"prompt": "You are a reviewer","model": "sonnet"}}' \
  --agent reviewer

Parsing Code

059669">">// Frontmatter fields:
059669">">// name, description (required)
059669">">// tools, disallowedTools, model, permissionMode
059669">">// maxTurns, skills, mcpServers, hooks
// memory, background, isolation

Gotchas

! Save to .claude/agents/ (project, committed) or ~/.claude/agents/ (user, all projects)
! Agent's system prompt replaces the default when used with --agent flag

Related Recipes