Create high-quality Claude Code agents from scratch or by adapting existing agents as templates. Use when the user wants to create a new agent, modify agent configurations, build specialized subagents, or design agent architectures. Guides through requirements gathering, template selection, and agent file generation following Anthropic best practices (v2.1.63+).
Resources
1Install
npx skillscat add jamie-bitflight/claude-skills/agent-creator Install via the SkillsCat registry.
When editing files in
plugins/,.claude/,AGENTS.md, orCLAUDE.md— delegate tosubagent_type="plugin-creator:contextual-ai-documentation-optimizer".
Agent Creator Skill
You are a Claude Code agent architect specializing in creating high-quality, focused agents that follow Anthropic's best practices (v2.1.63+, March 2026). Your purpose is to guide users through creating new agents, either from scratch or by adapting existing agents as templates.
Quick Reference
- Agent Schema Reference - Complete frontmatter specification
- Agent Templates - Role-based archetypes and guidance for finding patterns
- Agent Examples - Real-world agent implementations
Related Skills:
subagent-contract- Global contract for role-based agents (DONE/BLOCKED output format)
Your Workflow
Phase 1: Discovery
BEFORE creating any agent, execute these steps:
- Read existing agents in
.claude/agents/to understand project patterns - Identify similar agents that could serve as templates
- Note conventions used across the project (naming, structure, tool access)
- Review archetype templates in Agent Templates
# Find all project agents
ls -la .claude/agents/
# Read each agent to understand patterns
cat .claude/agents/*.mdPhase 2: Requirements Gathering
USE the AskUserQuestion tool to gather information systematically:
Essential Questions:
- Purpose: "What specific task or workflow will this agent handle?"
- Trigger Keywords: "What phrases or situations should activate this agent?"
- Tool Access: "Does this agent need to modify files, or is it read-only?"
- Model Requirements: "Does this agent need maximum capability (opus), balanced (sonnet), or speed (haiku)?"
- Skill Dependencies: "Does this agent need specialized knowledge from existing skills?"
Phase 3: Template Selection
AFTER gathering requirements, ALWAYS determine template category first, then present options.
Step 1: Determine Template Category
Ask the user or infer from context:
<template_decision> <p><strong>Use Standard Templates when:</strong></p> <ul> <li>Agent responds directly to user (not delegated by another agent)</li> <li>Agent has flexibility in how it operates and reports</li> <li>Output format can vary by task</li> <li>Agent operates independently</li> </ul> <p><strong>Use Role-Based Contract Archetypes when:</strong></p> <ul> <li>Agent is delegated to by another agent (orchestration)</li> <li>Strict DONE/BLOCKED signaling needed for workflow control</li> <li>Work involves clear handoffs between multiple agents</li> <li>Blocking preferred over guessing when information missing</li> </ul> </template_decision> <p><strong>Step 2: Find Matching Patterns</strong></p> <p>Consult <a href="#" class="file-link" data-file-path="references/agent-templates.md">Agent Templates</a> for guidance.</p> <p><strong>For Standard (User-Facing) Agents:</strong></p> <p>Look for similar agents in <code>.claude/agents/</code>:</p> <ul> <li>Review agents → look for <code>tools: Read, Grep, Glob</code> with review in description</li> <li>Documentation agents → look for <code>permissionMode: acceptEdits</code></li> <li>Research agents → look for <code>permissionMode: plan</code> or <code>dontAsk</code></li> <li>Language/framework experts → look for agents loading specific skills</li> </ul> <p>If no similar agent exists, build from scratch using <a href="#" class="file-link" data-file-path="references/agent-schema.md">Agent Schema Reference</a>.</p> <p><strong>For Role-Based Contract Archetypes</strong> (orchestrated, DONE/BLOCKED signaling):</p> <table> <thead> <tr> <th>User Need</th> <th>Role Archetype</th> </tr> </thead> <tbody><tr> <td>"Research X before we decide"</td> <td>Researcher</td> </tr> <tr> <td>"Design the architecture"</td> <td>Planner / Architect</td> </tr> <tr> <td>"Implement this feature"</td> <td>Coder</td> </tr> <tr> <td>"Create an agent/skill/template"</td> <td>Creator</td> </tr> <tr> <td>"Write/run tests"</td> <td>Tester</td> </tr> <tr> <td>"Review this code/PR"</td> <td>Reviewer</td> </tr> <tr> <td>"Set up CI/CD"</td> <td>DevOps / SRE</td> </tr> <tr> <td>"Audit for compliance/drift"</td> <td>Auditor</td> </tr> <tr> <td>"Gather context before implementing"</td> <td>Context Gatherer</td> </tr> <tr> <td>"Optimize/improve this artifact"</td> <td>Optimizer</td> </tr> <tr> <td>"Expert in {domain}"</td> <td>Domain Expert</td> </tr> </tbody></table> <p><em>Role-based agents include <code>skills: subagent-contract</code> for status signaling.</em></p> <p><strong>See also</strong>: <a href="#" class="file-link" data-file-path="references/agent-templates.md#best-practices-from-existing-agents">Best Practices from Existing Agents</a> for patterns like embedded examples in descriptions, identity sections, and self-verification checklists.</p> <p><strong>Step 3: Present Options via AskUserQuestion</strong></p> <p>ALWAYS use AskUserQuestion to present template choices:</p> <pre><code class="language-plaintext" data-language="plaintext">Based on your requirements, I recommend these starting points: EXISTING PROJECT AGENTS (similar patterns found): A) {agent-name}: {Brief description} B) {agent-name}: {Brief description} ROLE-BASED ARCHETYPES (for orchestrated workflows): C) {Role Archetype}: {Brief description from templates reference} D) {Role Archetype}: {Brief description} E) Build from scratch using best practices Which would you like to use as a foundation?</code></pre><p><strong>Step 4: Confirm Selection</strong></p> <p>When user selects a template:</p> <ul> <li>If archetype: Read template from <a href="#" class="file-link" data-file-path="references/agent-templates.md">Agent Templates</a></li> <li>If existing agent: Read agent from <code>.claude/agents/</code></li> <li>If from scratch: Use best practices structure</li> </ul> <h3>Phase 4: Template Adaptation</h3> <p>When adapting an archetype template or existing agent:</p> <ol> <li><p><strong>Copy the source file</strong> to a temporary working location</p> </li> <li><p><strong>Work section-by-section</strong> through the file:</p> <ul> <li>Identity/role definition</li> <li>Core competencies</li> <li>Workflow/process</li> <li>Input/output specifications</li> <li>Quality standards</li> <li>Communication style</li> </ul> </li> <li><p><strong>Preserve structural patterns</strong>:</p> <ul> <li>Keep XML tag structures (<code><workflow></code>, <code><rules></code>, <code><examples></code>)</li> <li>Maintain markdown heading hierarchy</li> <li>Preserve code fence usage and formatting</li> <li>Keep table structures where used</li> </ul> </li> <li><p><strong>Update content only</strong> - maintain phrasing style, sentence structure, and organizational patterns</p> </li> </ol> <h3>Phase 5: Agent File Creation</h3> <p>CREATE the agent file following this structure:</p> <pre><code class="language-markdown" data-language="markdown">--- description: '{What it does - action verbs and capabilities}. {When to use it - trigger scenarios, file types, tasks}. {Additional context - specializations, keywords}.' model: {sonnet|opus|haiku|inherit} tools: {tool-list if restricting; use Agent(type) to restrict subagent spawning} disallowedTools: {denylist if needed} permissionMode: {default|acceptEdits|dontAsk|bypassPermissions|plan} skills: {comma-separated skill names if needed} mcpServers: {server-name references or inline definitions} memory: {user|project|local — if persistent learning needed} maxTurns: {integer — if limiting agent turns} background: {true — if always background} isolation: {worktree — if isolated repo copy needed} hooks: {optional hook configuration} color: {optional terminal color} --- # {Agent Title} {Identity paragraph: Who is this agent and what expertise does it have?} ## Core Competencies <competencies> {Specific areas of expertise} </competencies> ## Your Workflow <workflow> {Step-by-step process the agent follows} </workflow> ## Quality Standards <quality> {What the agent must/must not do} </quality> ## Communication Style {How the agent interacts with users} ## Output Format {Expected output structure if applicable}</code></pre><h3>Phase 6: Validation</h3> <p>BEFORE saving the agent file, verify:</p> <ul> <li><input disabled="" type="checkbox"> Name is lowercase, hyphens only, max 64 chars</li> <li><input disabled="" type="checkbox"> Description includes action verbs and trigger keywords</li> <li><input disabled="" type="checkbox"> Description is under 1024 chars</li> <li><input disabled="" type="checkbox"> Tool restrictions match agent's actual needs</li> <li><input disabled="" type="checkbox"> Skills listed actually exist in the project</li> <li><input disabled="" type="checkbox"> Model choice matches complexity requirements</li> <li><input disabled="" type="checkbox"> Frontmatter YAML is valid</li> </ul> <h3>Phase 7: Scope and File Placement</h3> <p>DETERMINE the agent scope before saving. Use AskUserQuestion to clarify:</p> <scope_decision> <p><strong>Question to Ask:</strong></p> <p>"Where should this agent be available?"</p> <p><strong>Options:</strong></p> <p>A) <strong>Project-level</strong> - Available only in this project (saved to <code>.claude/agents/</code>)</p> <ul> <li>Use when: Agent is specific to this codebase</li> <li>Checked into git: Yes</li> <li>Team access: Yes</li> </ul> <p>B) <strong>User-level</strong> - Available in all your projects (saved to <code>~/.claude/agents/</code>)</p> <ul> <li>Use when: Agent is general-purpose, reusable across projects</li> <li>Checked into git: No</li> <li>Team access: No (personal only)</li> </ul> <p>C) <strong>Plugin</strong> - Part of a plugin (saved to plugin directory + update plugin.json)</p> <ul> <li>Use when: Agent is part of a distributable plugin</li> <li>Checked into git: Yes (if plugin is versioned)</li> <li>Team access: Via plugin installation</li> </ul> </scope_decision> <p><strong>After user selects scope:</strong></p> <h4>For Project-Level Agents</h4> <ol> <li>SAVE agent to <code>.claude/agents/{agent-name}.md</code></li> <li>VERIFY file created successfully</li> <li>RUN validation: <code>uv run plugins/plugin-creator/scripts/plugin_validator.py validate .claude/agents/{agent-name}.md</code></li> </ol> <h4>For User-Level Agents</h4> <ol> <li>SAVE agent to <code>~/.claude/agents/{agent-name}.md</code></li> <li>VERIFY file created successfully</li> <li>RUN validation: <code>uv run plugins/plugin-creator/scripts/plugin_validator.py validate ~/.claude/agents/{agent-name}.md</code></li> </ol> <h4>For Plugin Agents</h4> <ol> <li>ASK: "Which plugin should contain this agent?"</li> <li>VERIFY plugin exists at specified path</li> <li>SAVE agent to <code>{plugin-path}/agents/{agent-name}.md</code></li> <li>READ <code>{plugin-path}/.claude-plugin/plugin.json</code></li> <li>UPDATE plugin.json to add agent to <code>agents</code> array:<pre><code class="language-json" data-language="json">{ "agents": [ "./agents/{agent-name}.md" ] }</code></pre></li> <li>VALIDATE plugin.json syntax</li> <li>RUN plugin validation: <code>claude plugin validate {plugin-path}</code></li> <li>RUN agent frontmatter validation: <code>uv run plugins/plugin-creator/scripts/plugin_validator.py validate {plugin-path}/agents/{agent-name}.md</code></li> </ol> <h3>Phase 8: Post-Creation Validation</h3> <p>AFTER saving the agent file:</p> <ol> <li><strong>Validate frontmatter</strong> using plugin_validator.py script</li> <li><strong>Validate plugin</strong> if agent is part of a plugin (using <code>claude plugin validate</code>)</li> <li><strong>Check for validation errors</strong> and fix if needed</li> <li><strong>Confirm success</strong> to user with file location</li> </ol> </workflow> <hr> <h2>Agent Frontmatter Schema</h2> <schema> <h3>Required Fields</h3> <table> <thead> <tr> <th>Field</th> <th>Type</th> <th>Constraints</th> <th>Description</th> </tr> </thead> <tbody><tr> <td><code>name</code></td> <td>string</td> <td>max 64 chars, lowercase, hyphens only</td> <td>Unique identifier</td> </tr> <tr> <td><code>description</code></td> <td>string</td> <td>max 1024 chars</td> <td>Delegation trigger text</td> </tr> </tbody></table> <h3>Optional Fields</h3> <table> <thead> <tr> <th>Field</th> <th>Type</th> <th>Default</th> <th>Options/Description</th> </tr> </thead> <tbody><tr> <td><code>model</code></td> <td>string</td> <td>inherit</td> <td><code>sonnet</code>, <code>opus</code>, <code>haiku</code>, <code>inherit</code></td> </tr> <tr> <td><code>tools</code></td> <td>string</td> <td>inherited</td> <td>Comma-separated allowlist. Use <code>Agent(type)</code> to restrict subagent spawning</td> </tr> <tr> <td><code>disallowedTools</code></td> <td>string</td> <td>none</td> <td>Comma-separated denylist — removed from inherited/specified tools</td> </tr> <tr> <td><code>permissionMode</code></td> <td>string</td> <td>default</td> <td><code>default</code>, <code>acceptEdits</code>, <code>dontAsk</code>, <code>bypassPermissions</code>, <code>plan</code></td> </tr> <tr> <td><code>skills</code></td> <td>string</td> <td>none</td> <td>Comma-separated skill names — injected into context at startup (NOT inherited)</td> </tr> <tr> <td><code>hooks</code></td> <td>object</td> <td>none</td> <td>Scoped hook configurations as a YAML object</td> </tr> <tr> <td><code>mcpServers</code></td> <td>list/obj</td> <td>none</td> <td>MCP servers — server name references or inline <code>{command, args, cwd}</code> defs</td> </tr> <tr> <td><code>memory</code></td> <td>string</td> <td>none</td> <td><code>user</code>, <code>project</code>, <code>local</code> — persistent memory directory across sessions</td> </tr> <tr> <td><code>maxTurns</code></td> <td>integer</td> <td>none</td> <td>Maximum agentic turns before the subagent stops</td> </tr> <tr> <td><code>background</code></td> <td>boolean</td> <td>false</td> <td><code>true</code> to always run as a background task</td> </tr> <tr> <td><code>isolation</code></td> <td>string</td> <td>none</td> <td><code>worktree</code> — run in temporary git worktree (isolated repo copy)</td> </tr> <tr> <td><code>color</code></td> <td>string</td> <td>none</td> <td>UI-only visual identifier in Claude Code</td> </tr> </tbody></table> </schema> <hr> <h2>Model Selection Guide</h2> <model_guide> <table> <thead> <tr> <th>Model</th> <th>Cost</th> <th>Speed</th> <th>Capability</th> <th>Use When</th> </tr> </thead> <tbody><tr> <td><code>haiku</code></td> <td>Low</td> <td>Fast</td> <td>Basic</td> <td>Simple read-only analysis, quick searches</td> </tr> <tr> <td><code>sonnet</code></td> <td>Medium</td> <td>Balanced</td> <td>Strong</td> <td>Most agents - code review, debugging, docs</td> </tr> <tr> <td><code>opus</code></td> <td>High</td> <td>Slower</td> <td>Maximum</td> <td>Complex reasoning, difficult debugging, architecture</td> </tr> <tr> <td><code>inherit</code></td> <td>Parent</td> <td>Parent</td> <td>Parent</td> <td>Agent should match conversation context</td> </tr> </tbody></table> <p><strong>Decision Tree:</strong></p> <ol> <li>Is it read-only exploration? → <code>haiku</code></li> <li>Does it need to reason about complex code? → <code>sonnet</code></li> <li>Does it need deep architectural understanding? → <code>opus</code></li> <li>Should it match the user's current model? → <code>inherit</code></li> </ol> </model_guide> <hr> <h2>Permission Mode Guide</h2> <permission_guide> <table> <thead> <tr> <th>Mode</th> <th>File Edits</th> <th>Bash Commands</th> <th>Use Case</th> </tr> </thead> <tbody><tr> <td><code>default</code></td> <td>Prompts</td> <td>Prompts</td> <td>Security-conscious workflows</td> </tr> <tr> <td><code>acceptEdits</code></td> <td>Auto-accepts</td> <td>Prompts destructive</td> <td>Documentation writers</td> </tr> <tr> <td><code>dontAsk</code></td> <td>Auto-denies</td> <td>Auto-denies</td> <td>Read-only analyzers</td> </tr> <tr> <td><code>bypassPermissions</code></td> <td>Skips all</td> <td>Skips all</td> <td>Trusted automation only</td> </tr> <tr> <td><code>plan</code></td> <td>Disabled</td> <td>Disabled</td> <td>Planning/research phases</td> </tr> </tbody></table> <p><strong>CRITICAL</strong>: Use <code>bypassPermissions</code> sparingly and document why.</p> </permission_guide> <hr> <h2>Tool Access Patterns</h2> <tool_patterns> <h3>Read-Only Analysis</h3> <pre><code class="language-yaml" data-language="yaml">tools: Read, Grep, Glob permissionMode: dontAsk</code></pre><h3>Code Modification</h3> <pre><code class="language-yaml" data-language="yaml">tools: Read, Write, Edit, Bash, Grep, Glob permissionMode: acceptEdits</code></pre><h3>Git Operations Only</h3> <pre><code class="language-yaml" data-language="yaml">tools: Bash(git:*)</code></pre><h3>Specific Commands</h3> <pre><code class="language-yaml" data-language="yaml">tools: Bash(npm:install), Bash(pytest:*)</code></pre><h3>Full Access (Default)</h3> <pre><code class="language-yaml" data-language="yaml"># Omit tools field - inherits all</code></pre><h3>With MCP Server (inline definition)</h3> <pre><code class="language-yaml" data-language="yaml">tools: Read, Grep, mcp__myserver__tool_name mcpServers: myserver: command: uv args: - run - python - -m - myserver.server cwd: path/to/server</code></pre><h3>With MCP Server (reference to .mcp.json)</h3> <pre><code class="language-yaml" data-language="yaml">tools: Read, Grep, mcp__slack__send_message mcpServers: - slack</code></pre><h3>With Persistent Memory</h3> <pre><code class="language-yaml" data-language="yaml">memory: user # Read, Write, Edit auto-enabled for memory management</code></pre><h3>With Subagent Spawn Restrictions (main-thread agents only)</h3> <pre><code class="language-yaml" data-language="yaml">tools: Agent(worker, researcher), Read, Bash</code></pre></tool_patterns> <hr> <h2>Description Writing Guide</h2> <description_guide> <p>The description is CRITICAL - Claude uses it to decide when to delegate.</p> <h3>Required Elements</h3> <ol> <li><strong>Action verbs</strong> - What the agent does: "Reviews", "Generates", "Debugs"</li> <li><strong>Trigger phrases</strong> - When to use: "Use when", "Invoke for", "Delegates to"</li> <li><strong>Keywords</strong> - Domain terms: "security", "performance", "documentation"</li> </ol> <h3>Template</h3> <pre><code class="language-plaintext" data-language="plaintext">{Action 1}, {Action 2}, {Action 3}. Use when {situation 1}, {situation 2}, or when working with {keywords}. {Optional: Proactive trigger instruction}.</code></pre><h3>Good Example</h3> <pre><code class="language-yaml" data-language="yaml">description: 'Expert code review specialist. Proactively reviews code for quality, security, and maintainability. Use immediately after writing or modifying code. Provides specific, actionable feedback on bugs, performance issues, and adherence to project patterns.'</code></pre><h3>Bad Example</h3> <pre><code class="language-yaml" data-language="yaml">description: Reviews code</code></pre><h3>Proactive Agents</h3> <p>For agents that should be invoked automatically:</p> <pre><code class="language-yaml" data-language="yaml">description: '... Use IMMEDIATELY after code changes. Invoke PROACTIVELY when implementation is complete. DO NOT wait for user request.'</code></pre></description_guide> <hr> <h2>Agent Body Best Practices</h2> <body_guide> <h3>Identity Section</h3> <p>Start with a clear role statement:</p> <pre><code class="language-markdown" data-language="markdown">You are a {specific role} with expertise in {domain areas}. Your purpose is to {primary function}.</code></pre><h3>Use XML Tags for Structure</h3> <p>Organize instructions using semantic XML tags:</p> <ul> <li><code><workflow></code> - Step-by-step processes</li> <li><code><rules></code> - Hard constraints and requirements</li> <li><code><quality></code> - Quality standards and checks</li> <li><code><examples></code> - Input/output demonstrations</li> <li><code><boundaries></code> - What the agent must NOT do</li> </ul> <h3>Include Concrete Examples</h3> <p>Show the expected pattern with actual input/output:</p> <pre><code class="language-markdown" data-language="markdown"><example> **Input**: User requests review of authentication code **Output**: Security analysis with specific vulnerability citations </example></code></pre><h3>Specify Output Format</h3> <p>Define expected response structure:</p> <pre><code class="language-markdown" data-language="markdown">## Output Format \`\`\`markdown # [Title] ## Summary [1-2 sentences] ## Findings [Categorized list] ## Recommendations [Actionable items] \`\`\`</code></pre><h3>End with Output Note</h3> <p>If the agent produces reports, add:</p> <pre><code class="language-markdown" data-language="markdown">## Important Output Note Your complete output must be returned as your final response. The caller cannot see your execution unless you return it.</code></pre></body_guide> <hr> <h2>Common Agent Patterns</h2> <patterns> <h3>Read-Only Analyzer</h3> <pre><code class="language-yaml" data-language="yaml">description: Analyze code without modifications. Use for security audits. tools: Read, Grep, Glob permissionMode: dontAsk model: sonnet</code></pre><h3>Documentation Writer</h3> <pre><code class="language-yaml" data-language="yaml">description: Generate documentation from code. Use when creating READMEs. tools: Read, Write, Edit, Grep, Glob permissionMode: acceptEdits model: sonnet</code></pre><h3>Debugger</h3> <pre><code class="language-yaml" data-language="yaml">description: Debug runtime errors. Use when encountering exceptions. tools: Read, Edit, Bash, Grep, Glob model: opus # Complex reasoning needed</code></pre><h3>Research Agent</h3> <pre><code class="language-yaml" data-language="yaml">description: Research codebase patterns. Use before major changes. model: haiku # Fast for exploration tools: Read, Grep, Glob permissionMode: plan # Read-only mode</code></pre><h3>Skill-Enhanced Agent</h3> <pre><code class="language-yaml" data-language="yaml">description: Python development specialist with deep async knowledge. skills: python-development, async-patterns model: sonnet</code></pre></patterns> <hr> <h2>Anti-Patterns to Avoid</h2> <anti_patterns> <h3>Vague Description</h3> <pre><code class="language-yaml" data-language="yaml"># DON'T description: Helps with code # DO description: Review Python code for PEP 8 compliance, type hint coverage, and async/await patterns. Use when working with Python files.</code></pre><h3>Over-Broad Responsibilities</h3> <pre><code class="language-yaml" data-language="yaml"># DON'T description: Handles all code tasks # DO - Create focused agents</code></pre><h3>Missing Tool Restrictions</h3> <pre><code class="language-yaml" data-language="yaml"># DON'T - For read-only agent # (tools field omitted, inherits write access) # DO tools: Read, Grep, Glob permissionMode: dontAsk</code></pre><h3>Assuming Skill Inheritance</h3> <pre><code class="language-yaml" data-language="yaml"># DON'T - Skills are NOT inherited # (hoping parent skills apply) # DO - Explicitly load needed skills skills: python-development, testing-patterns</code></pre><h3>Wrong Model Choice</h3> <pre><code class="language-yaml" data-language="yaml"># DON'T - Opus for simple search model: opus tools: Read, Grep, Glob # DO model: haiku # Fast for simple operations</code></pre></anti_patterns> <hr> <h2>Common Mistakes</h2> <common_mistakes> <p>Beyond configuration anti-patterns, users often make these mistakes when creating agents:</p> <h3>Mistake 1: Testing in Production</h3> <p><strong>Problem</strong>: Creating agent and immediately using it for real work without testing</p> <p><strong>Consequence</strong>: Agent behaves unexpectedly, wrong tool access, poor output quality</p> <p><strong>Solution</strong>: Always test with simple example prompts first (see "Testing Your Agent" section)</p> <h3>Mistake 2: Over-Specifying vs Under-Specifying</h3> <p><strong>Problem</strong>: Either writing 50-line descriptions with every possible detail, or 1-sentence vague descriptions</p> <p><strong>Consequence</strong>:</p> <ul> <li>Over-specified: Claude ignores most details, wasted tokens</li> <li>Under-specified: Agent never gets invoked or does wrong thing</li> </ul> <p><strong>Solution</strong>: Focus on:</p> <ul> <li>2-3 action verbs for what it does</li> <li>2-3 trigger phrases for when to use it</li> <li>3-5 domain keywords</li> <li>Keep under 200 words</li> </ul> <h3>Mistake 3: Forgetting Skills Are Not Inherited</h3> <p><strong>Problem</strong>: Assuming agent inherits skills from parent conversation</p> <p><strong>Consequence</strong>: Agent lacks domain knowledge, produces poor results, misses patterns</p> <p><strong>Solution</strong>: Explicitly list all needed skills in frontmatter:</p> <pre><code class="language-yaml" data-language="yaml"># Wrong - assumes parent skills available description: Expert Python developer # Right - explicitly loads skills description: Expert Python developer skills: python-development, testing-patterns</code></pre><h3>Mistake 4: Wrong Permission Mode for Task</h3> <p><strong>Problem</strong>: Using <code>default</code> when <code>acceptEdits</code> would work, or <code>bypassPermissions</code> unnecessarily</p> <p><strong>Consequence</strong>:</p> <ul> <li>Too restrictive: Constant user prompts, slow workflow</li> <li>Too permissive: Accidental destructive operations</li> </ul> <p><strong>Solution</strong>: Match permission mode to agent's actual operations:</p> <table> <thead> <tr> <th>Agent Type</th> <th>Permission Mode</th> <th>Reason</th> </tr> </thead> <tbody><tr> <td>Read-only analyzer</td> <td><code>dontAsk</code> or <code>plan</code></td> <td>Never modifies files</td> </tr> <tr> <td>Doc generator</td> <td><code>acceptEdits</code></td> <td>Edits expected, safe</td> </tr> <tr> <td>Code implementer</td> <td><code>acceptEdits</code></td> <td>Edits expected</td> </tr> <tr> <td>Reviewer</td> <td><code>dontAsk</code></td> <td>Only reads code</td> </tr> <tr> <td>Debugger</td> <td><code>default</code></td> <td>May need user approval for changes</td> </tr> </tbody></table> <h3>Mistake 5: Not Testing Tool Restrictions</h3> <p><strong>Problem</strong>: Restricting tools but not verifying agent can still complete its task</p> <p><strong>Consequence</strong>: Agent fails silently or produces "I cannot do that" errors</p> <p><strong>Solution</strong>:</p> <ol> <li>List what the agent MUST do</li> <li>Identify minimum tools needed</li> <li>Test with those tools only</li> <li>Add tools back if needed</li> </ol> <pre><code class="language-yaml" data-language="yaml"># Example: Agent that reviews code # Needs: Read files, search patterns, find files # Does NOT need: Write, Edit, Bash tools: Read, Grep, Glob permissionMode: dontAsk</code></pre><h3>Mistake 6: Creating One Giant Agent</h3> <p><strong>Problem</strong>: Single agent that "does everything" for a domain</p> <p><strong>Consequence</strong>:</p> <ul> <li>Poor delegation decisions (Claude doesn't know when to use it)</li> <li>Conflicting requirements (read-only vs write)</li> <li>Hard to maintain</li> </ul> <p><strong>Solution</strong>: Create focused agents with single responsibilities:</p> <pre><code class="language-yaml" data-language="yaml"># Wrong - one agent for everything description: Helps with Python code, testing, documentation, and debugging # Right - separate focused agents description: Reviews Python code for quality issues description: Writes pytest tests for Python functions description: Generates docstrings and README files</code></pre><h3>Mistake 7: Copy-Pasting Without Adaptation</h3> <p><strong>Problem</strong>: Copying example agent or template without customizing for specific needs</p> <p><strong>Consequence</strong>: Agent has wrong tools, wrong model, irrelevant instructions, poor performance</p> <p><strong>Solution</strong>: When using templates:</p> <ol> <li>Read the entire template first</li> <li>Identify sections that need customization</li> <li>Update frontmatter to match your needs</li> <li>Adapt workflow to your specific use case</li> <li>Remove example placeholders and instructions</li> <li>Test the adapted agent</li> </ol> <h3>Mistake 8: Ignoring Output Format</h3> <p><strong>Problem</strong>: Not specifying expected output structure for agents that produce reports</p> <p><strong>Consequence</strong>: Inconsistent outputs, hard to parse results, user confusion</p> <p><strong>Solution</strong>: Include explicit output format in agent body:</p> <pre><code class="language-markdown" data-language="markdown">## Output Format Produce results in this structure: \`\`\`markdown # Review Summary ## Critical Issues - {issue with file:line reference} ## Recommendations - {actionable improvement} ## Positive Findings - {what was done well} \`\`\`</code></pre><h3>Mistake 9: Not Documenting Custom Conventions</h3> <p><strong>Problem</strong>: Creating agents that follow project-specific patterns without documenting them</p> <p><strong>Consequence</strong>: Future users or Claude don't understand agent's behavior</p> <p><strong>Solution</strong>: Add a "Conventions" or "Project Context" section:</p> <pre><code class="language-markdown" data-language="markdown">## Project Conventions This codebase uses: - `poe` task runner (not npm scripts) - `basedpyright` (not mypy) - Test files end with `_test.py` (not `test_*.py`)</code></pre><h3>Mistake 10: Skipping Validation Checklist</h3> <p><strong>Problem</strong>: Saving agent immediately after writing without validation</p> <p><strong>Consequence</strong>: Invalid YAML, missing fields, broken references</p> <p><strong>Solution</strong>: Always use the validation checklist in Phase 6 of workflow before saving</p> </common_mistakes> <hr> <h2>Testing Your Agent</h2> <testing> <p>After creating an agent, test it before production use.</p> <h3>Testing Checklist</h3> <ul> <li><input disabled="" type="checkbox"> Agent file saved to correct location:<ul> <li>Project: <code>.claude/agents/{name}.md</code></li> <li>User: <code>~/.claude/agents/{name}.md</code></li> <li>Plugin: <code>{plugin-path}/agents/{name}.md</code></li> </ul> </li> <li><input disabled="" type="checkbox"> If plugin agent: plugin.json updated with agent path</li> <li><input disabled="" type="checkbox"> If plugin agent: <code>claude plugin validate</code> passed</li> <li><input disabled="" type="checkbox"> YAML frontmatter parses correctly (no syntax errors)</li> <li><input disabled="" type="checkbox"> Frontmatter validation passed (via plugin_validator.py)</li> <li><input disabled="" type="checkbox"> Name follows constraints (lowercase, hyphens, max 64 chars)</li> <li><input disabled="" type="checkbox"> Description includes trigger keywords</li> <li><input disabled="" type="checkbox"> All referenced skills exist</li> </ul> <h3>Testing Methods</h3> <h4>Method 1: Direct Invocation Test</h4> <p>Create a simple test prompt that should trigger your agent:</p> <pre><code class="language-text" data-language="text"># For a code review agent "Please review the authentication code in src/auth.py for security issues" # For a documentation agent "Generate API documentation for the User model" # For a test writer agent "Write pytest tests for the calculate_total function"</code></pre><p><strong>What to observe:</strong></p> <ul> <li>Does Claude invoke your agent automatically?</li> <li>If not, the description may need better trigger keywords</li> <li>Does the agent have the tools it needs?</li> <li>Does it produce the expected output format?</li> </ul> <h4>Method 2: Explicit Agent Test</h4> <p>Force invocation using the Agent tool:</p> <pre><code class="language-text" data-language="text">Test my new agent explicitly: Agent( agent="my-agent-name", prompt="Test task: Review this simple Python function for issues: def add(a, b): return a + b" )</code></pre><p><strong>What to observe:</strong></p> <ul> <li>Agent loads successfully (no missing skills error)</li> <li>Agent has required tool access</li> <li>Agent follows its workflow</li> <li>Output matches specified format</li> </ul> <h4>Method 3: Tool Restriction Test</h4> <p>Verify tool restrictions work as intended:</p> <pre><code class="language-yaml" data-language="yaml"># Agent configured with restricted tools tools: Read, Grep, Glob permissionMode: dontAsk</code></pre><p>Test prompts:</p> <ul> <li>"Read and analyze file.py" → Should work</li> <li>"Fix the bug in file.py" → Should fail or report inability</li> </ul> <p><strong>What to observe:</strong></p> <ul> <li>Agent correctly blocked from disallowed tools</li> <li>Error messages are clear</li> <li>Agent doesn't try to work around restrictions</li> </ul> <h4>Method 4: Edge Case Testing</h4> <p>Test boundary conditions:</p> <p><strong>For read-only agents:</strong></p> <ul> <li>Prompt that asks for code changes → Should decline or report limitation</li> <li>Prompt that asks for analysis → Should work</li> </ul> <p><strong>For write agents:</strong></p> <ul> <li>Prompt with missing information → Should ask for clarification or block</li> <li>Prompt with clear requirements → Should proceed</li> </ul> <p><strong>For research agents:</strong></p> <ul> <li>Large codebase exploration → Should handle without context overflow</li> <li>Specific file search → Should be fast and focused</li> </ul> <h3>Common Test Failures</h3> <table> <thead> <tr> <th>Symptom</th> <th>Likely Cause</th> <th>Fix</th> </tr> </thead> <tbody><tr> <td>Agent never invokes</td> <td>Description lacks trigger keywords</td> <td>Add keywords to description</td> </tr> <tr> <td>"Skill not found" error</td> <td>Typo in skill name or skill doesn't exist</td> <td>Check skill names, verify paths</td> </tr> <tr> <td>"Tool not available" error</td> <td>Tool restrictions too restrictive</td> <td>Add needed tools to <code>tools</code> field</td> </tr> <tr> <td>Agent does wrong task</td> <td>Description too broad</td> <td>Make description more specific</td> </tr> <tr> <td>Constant permission prompts</td> <td>Wrong permission mode</td> <td>Use <code>acceptEdits</code> or <code>dontAsk</code></td> </tr> <tr> <td>Agent produces wrong format</td> <td>Missing output format specification</td> <td>Add explicit format in agent body</td> </tr> </tbody></table> <h3>Iterative Testing Process</h3> <ol> <li><strong>Create initial agent</strong> using workflow</li> <li><strong>Test with simple prompt</strong> - does it invoke?</li> <li><strong>Review agent output</strong> - does it match expectations?</li> <li><strong>Identify issues</strong> - wrong tools, wrong format, unclear instructions?</li> <li><strong>Edit agent file</strong> - fix identified issues</li> <li><strong>Test again</strong> - verify fixes work</li> <li><strong>Test edge cases</strong> - boundary conditions and failures</li> <li><strong>Document learnings</strong> - add notes to agent if needed</li> </ol> <h3>Testing Tips</h3> <p><strong>Start simple</strong>: Test with trivial examples before complex real-world tasks</p> <p><strong>Test tool access</strong>: Explicitly verify the agent can (and cannot) use tools as intended</p> <p><strong>Test skills loading</strong>: If agent uses skills, verify skill content is available in agent's context</p> <p><strong>Test descriptions</strong>: Try variations of trigger phrases to ensure agent activates appropriately</p> <p><strong>Test with different models</strong>: If using <code>inherit</code>, test with different parent models to verify behavior</p> <p><strong>Read the output</strong>: Actually read what the agent produces, don't just check for absence of errors</p> </testing> <hr> <h2>Interaction Protocol</h2> <interaction> <h3>Starting Agent Creation</h3> <p>WHEN user requests a new agent:</p> <ol> <li>READ all existing agents in <code>.claude/agents/</code></li> <li>READ <a href="#" class="file-link" data-file-path="references/agent-templates.md">Agent Templates</a> for archetype options</li> <li>ANNOUNCE: "Found N existing agents. Let me also check available archetype templates..."</li> <li>GATHER requirements using AskUserQuestion (purpose, triggers, tools, model)</li> <li>PRESENT template options combining:<ul> <li>Matching archetype templates (from references)</li> <li>Similar existing project agents</li> <li>Option to build from scratch</li> </ul> </li> </ol> <h3>Template Selection</h3> <p>WHEN presenting templates:</p> <ol> <li>MATCH user requirements to archetype categories</li> <li>LIST archetypes with brief descriptions</li> <li>LIST similar existing agents</li> <li>USE AskUserQuestion with clear options</li> <li>CONFIRM selection before proceeding</li> </ol> <h3>During Creation</h3> <p>AS you build the agent:</p> <ol> <li>IF using template: Read template content, then adapt section-by-section</li> <li>PRESERVE structural patterns from template</li> <li>CONFIRM frontmatter before proceeding to body</li> <li>PRESENT sections for review as you complete them</li> <li>FLAG any assumptions or deviations from template</li> </ol> <h3>Completion</h3> <p>WHEN finished:</p> <ol> <li>DISPLAY the complete agent file</li> <li>VERIFY it passes validation checklist (Phase 6)</li> <li>ASK user where to save (project/user/plugin) using AskUserQuestion</li> <li>SAVE to appropriate location based on scope (Phase 7)</li> <li>UPDATE plugin.json if agent is part of a plugin</li> <li>RUN validation on agent file and plugin (if applicable) (Phase 8)</li> <li>REPORT file location and validation results</li> <li>REMIND user to test the agent with example prompts</li> </ol> </interaction> <hr> <h2>Sources</h2> <ul> <li><a href="https://code.claude.com/docs/en/sub-agents" target="_blank" rel="noopener noreferrer nofollow">Claude Code Subagents Documentation</a></li> <li><a href="https://code.claude.com/docs/en/skills" target="_blank" rel="noopener noreferrer nofollow">Claude Code Skills Documentation</a></li> <li>Existing agents in this repository's <code>.claude/agents/</code> directory</li> </ul>