Agent Creator Skill
Purpose: Guide creation of Claude Code agents following Anthropic official best practices.
When to use: Creating new agents, refactoring existing agents, validating agent structure.
🎯 Core Principles
Agent Structure Philosophy
- Minimal agents (~150 lines): Only identity, role, boundaries, and skill invocation
- Comprehensive skills: All technical procedures, workflows, and references
- Progressive disclosure: Metadata → Agent .md → SKILL.md → References (on demand)
- Mandatory skill invocation: Agents MUST invoke their skill before work
Separation of Concerns
Agent .md (150 lines) Skill SKILL.md (varies)
├─ YAML frontmatter ├─ Technical workflows
├─ Identity & role ├─ Context7 checkpoints
├─ Authority & boundaries ├─ MCP integrations
├─ Workspace isolation ├─ Best practices
├─ Mandatory skill call ├─ Code patterns
└─ Quick reference └─ References/ (on demand)
📋 6-PHASE WORKFLOW
PHASE 1: Discovery & Analysis
Objective: Understand the agent's purpose and role in the system.
Steps:
- Identify the agent's primary responsibility
- Determine where it fits in the workflow (Architect → Test → Implementer → Supabase → UI/UX)
- Define clear trigger scenarios (when should this agent activate?)
- List exclusive authorizations (what ONLY this agent can do)
- Define strict prohibitions (what this agent must NEVER do)
Questions to answer:
- What problem does this agent solve?
- What are its inputs and outputs?
- Which other agents does it interact with?
- What are its success criteria?
Deliverable: Written notes on agent's role, triggers, and boundaries
PHASE 2: Context7 Research (MANDATORY)
Objective: Consult official Anthropic documentation for latest best practices.
⚠️ CRITICAL: You MUST query Context7 before creating or refactoring agents.
Required queries:
bash
1# Query 1: General agent best practices
2mcp__context7__resolve-library-id "claude code"
3mcp__context7__get-library-docs "/anthropics/claude-code" topic="custom agents creation best practices"
4
5# Query 2: Agent templates and examples
6mcp__context7__resolve-library-id "claude code templates"
7mcp__context7__get-library-docs "/davila7/claude-code-templates" topic="agent creation yaml structure examples"
8
9# Query 3: YAML frontmatter validation (if uncertain)
10mcp__context7__get-library-docs "/anthropics/claude-code" topic="yaml frontmatter agent configuration"
What to look for:
- ✅ Latest YAML frontmatter requirements
- ✅ Agent file structure changes
- ✅ Description formatting patterns
- ✅ Example agent implementations
- ✅ Validation rules and common mistakes
Reference documents (consult if Context7 unavailable):
references/context7-queries.md - Pre-built query patterns
references/yaml-frontmatter-guide.md - YAML validation rules
Deliverable: Notes on any differences from existing patterns, new requirements
PHASE 3: YAML Frontmatter Design
Objective: Create valid, descriptive YAML frontmatter for the agent.
Required fields:
yaml
1---
2name: {agent-name} # kebab-case REQUIRED
3description: ... # Trigger + examples REQUIRED
4model: sonnet # Default REQUIRED
5color: {color} # Visual ID REQUIRED
6---
Description structure (CRITICAL):
Use this agent when {trigger scenario}. Specializes in {expertise}.
Examples:
<example>
Context: {situation}
user: '{request}'
assistant: '{response}'
<commentary>{reasoning}</commentary>
</example>
<example>
Context: {another situation}
user: '{another request}'
assistant: '{another response}'
<commentary>{more reasoning}</commentary>
</example>
Naming conventions:
- Name: kebab-case (test-architect, ui-ux-expert, supabase-data-specialist)
- Color: Match role type (see
references/color-conventions.md)
- red = Architect/Chief
- blue = Testing/QA
- yellow = Implementation
- green = Data/Database
- pink = UI/UX
- purple = Security/Review
- orange = DevOps/Infrastructure
Examples reference: assets/yaml-examples.yml
Validation checklist:
Deliverable: Complete YAML frontmatter block
PHASE 4: Agent Body Structure
Objective: Create the minimal ~150 line agent body following standard structure.
Template: Use assets/agent-minimal-template.md as base.
Required sections (in order):
1. IDENTITY & ROLE
markdown
1# IDENTITY & ROLE
2
3You are the **{Agent Title}**—{one-sentence mission}.
4
5## Core Mission
6
7{2-3 paragraphs explaining:
8 - What this agent does
9 - Why it exists
10 - How it fits in the system}
11
12## Authority & Boundaries
13
14**YOU ARE THE ONLY AGENT AUTHORIZED TO**:
15- {Specific responsibility 1}
16- {Specific responsibility 2}
17- {Specific responsibility 3}
18
19**YOU ARE STRICTLY PROHIBITED FROM**:
20- {Specific prohibition 1}
21- {Specific prohibition 2}
22- {Specific prohibition 3}
Tips:
- Be SPECIFIC, not vague (❌ "handle data" → ✅ "implement Supabase RLS policies")
- Use active voice and imperative mood
- Clearly separate what this agent CAN vs CANNOT do
2. ITERATIVE WORKFLOW v2.0
markdown
1# ITERATIVE WORKFLOW v2.0
2
3## Your Workspace
4
5**Isolated folder**: `PRDs/{domain}/{feature}/{agent-name}/`
6
7**Files YOU read**:
8- ✅ `{agent-name}/00-request.md` (Architect writes)
9- ✅ `architect/00-master-prd.md` (reference)
10- ✅ `{previous-agent}/handoff-XXX.md` (if enabled)
11
12**Files you CANNOT read**:
13- ❌ Other agent folders (Architect coordinates information)
Purpose: Establish workspace isolation and file access boundaries.
3. MANDATORY SKILL INVOCATION
markdown
1# 🎯 MANDATORY SKILL INVOCATION
2
3**CRITICAL**: Before ANY work, invoke your technical skill:
4
5\```
6Skill: {agent-name}-skill
7\```
8
9**The skill provides**:
10- ✅ Step-by-step technical procedures
11- ✅ Context7 consultation checkpoints (MANDATORY phases)
12- ✅ MCP integration workflows
13- ✅ Technology-specific references (loaded on demand)
14- ✅ Code patterns and best practices
15
16**This skill is NOT optional—it is your complete technical manual.**
Purpose: Force agent to use its comprehensive skill before starting work.
4. QUICK REFERENCE
markdown
1# QUICK REFERENCE
2
3**Triggers**: {When to use this agent - 1-2 sentences}
4**Deliverables**: {What this agent produces - bulleted list}
5**Success metrics**: {How to measure completion - 2-3 criteria}
6
7---
8
9**Complete technical guide**: `.claude/skills/{agent-name}-skill/SKILL.md`
Purpose: Fast lookup for triggers and expected outputs.
Validation checklist:
Deliverable: Complete agent .md file
PHASE 5: Validation & Testing
Objective: Verify the agent file is valid and follows best practices.
Automated validation:
bash
1# Run validation script
2./scripts/validate-agent.sh .claude/agents/{agent-name}.md
The script checks:
- ✅ YAML frontmatter exists and is valid
- ✅ Required YAML fields (name, description, model, color)
- ✅ Name is kebab-case
- ✅ Description has examples and commentary
- ✅ Color is valid
- ✅ All required sections present
- ✅ File length is reasonable (~80-250 lines)
Manual validation checklist:
Common mistakes to avoid:
- ❌ Generic triggers ("Use when needed")
- ❌ Vague boundaries ("Handle database stuff")
- ❌ Missing examples in description
- ❌ Non-kebab-case name (TestArchitect, test_architect)
- ❌ Invalid color
- ❌ Missing skill invocation section
- ❌ Agent is >300 lines (move content to skill)
Reference documents:
references/agent-structure.md - Complete structure guide
references/yaml-frontmatter-guide.md - YAML validation details
Deliverable: Validated agent file passing all checks
PHASE 6: Skill Scaffold Creation
Objective: Create the companion skill structure for this agent.
⚠️ NOTE: This phase creates the STRUCTURE only. The skill content is created separately using the skill-creator skill.
Directory structure to create:
.claude/skills/{agent-name}-skill/
├── SKILL.md # Main skill file (create with skill-creator)
├── metadata.json # Skill metadata
├── references/ # Reference documents (loaded on demand)
│ └── README.md # Index of references
├── scripts/ # Automation scripts
│ └── README.md # Script documentation
└── assets/ # Templates, examples, diagrams
└── README.md # Asset catalog
Metadata template (metadata.json):
json
1{
2 "name": "{agent-name}-skill",
3 "version": "1.0.0",
4 "description": "Technical workflow and best practices for {agent-name} agent",
5 "agent": "{agent-name}",
6 "technologies": ["list", "of", "technologies"],
7 "mcps_required": ["context7", "supabase", "chrome-devtools"],
8 "references_count": 0,
9 "last_updated": "2025-10-24"
10}
Reference README template (references/README.md):
markdown
1# {Agent Name} Skill References
2
3References are loaded **on demand** when specific technical guidance is needed.
4
5## Available References
6
71. **{reference-name}.md** - {Brief description}
8 - When to consult: {Trigger}
9 - Context7 equivalent: {Query if applicable}
10
11## Update Policy
12
13References should be refreshed when:
14- Context7 documentation changes
15- New best practices emerge
16- Technology versions change
17- Common mistakes are identified
Validation checklist:
Deliverable: Skill directory structure ready for content population
🎯 AUTOMATIC HANDOFF TO SKILL-CREATOR
⚠️ CRITICAL: Agent creation is NOT complete until the skill is populated with technical content.
Now invoke the skill-creator to complete the skill:
Skill: skill-creator
Provide the skill-creator with this information:
markdown
1Agent: {agent-name}
2Color: {color}
3Role: {role from agent mission}
4
5Primary Responsibilities (from agent authorities):
6- {Authority 1}
7- {Authority 2}
8- {Authority 3}
9
10Technologies Involved:
11- {List technologies this agent works with}
12- {e.g., Vitest, Playwright for test-architect}
13- {e.g., Supabase, PostgreSQL, RLS for supabase-agent}
14
15Required MCP Integrations:
16- context7 (MANDATORY for all agents)
17- {Other MCPs: supabase, chrome-devtools, etc.}
18
19Skill Content to Include:
20- 6-phase workflow specific to this agent's role
21- Context7 checkpoints (mandatory consultation phases)
22- Technology-specific references (loaded on demand)
23- Code pattern examples and best practices
24- Common mistakes and troubleshooting guides
25- Automation scripts (if applicable)
26
27Reference the existing agent structure for consistency.
Expected skill-creator deliverables:
- ✅ SKILL.md with complete 6-phase workflow
- ✅ references/ with technology-specific best practices
- ✅ scripts/ with automation tools (if applicable)
- ✅ assets/ with templates and examples
- ✅ Updated metadata.json with accurate counts
Once skill-creator completes:
- Validate the complete agent + skill package
- Test agent invocation in Claude Code
- Verify skill invocation from agent works
- Update project documentation
Phase 6 Complete ✅
Next: Invoke Skill: skill-creator to populate the skill with technical content
🛠️ UTILITIES & HELPERS
Quick Start: New Agent from Scratch
Use the initialization script:
bash
1./scripts/init-agent.sh <agent-name> <color> "<role-description>"
2
3# Example:
4./scripts/init-agent.sh security-auditor purple "Security review and vulnerability scanning"
What it does:
- ✅ Creates agent file from template
- ✅ Validates naming conventions
- ✅ Replaces basic placeholders
- ✅ Guides you through next steps
Then:
- Edit the created file to fill in FILL_THIS placeholders
- Add 2-3 examples to YAML description
- Complete Core Mission section
- Define Authority & Boundaries
- Run validation:
./scripts/validate-agent.sh .claude/agents/{agent-name}.md
- Create skill structure (Phase 6)
Quick Start: Refactor Existing Agent
Steps:
- Backup the current agent file
- Extract identity information:
- Who is this agent? (title, mission)
- What can it do exclusively? (authorities)
- What must it never do? (prohibitions)
- Extract technical content:
- Workflows and procedures → Move to SKILL.md
- Technology references → Move to references/
- Code examples → Move to assets/
- Create minimal agent using
assets/agent-minimal-template.md
- Validate new structure:
./scripts/validate-agent.sh
- Create skill with extracted technical content
Before/After example:
BEFORE:
- architect-agent.md: 2078 lines (identity + workflows + examples + references)
AFTER:
- architect-agent.md: 150 lines (identity + skill invocation only)
- .claude/skills/architect-agent-skill/
├── SKILL.md: Workflows and procedures
├── references/: Best practices documents
└── assets/: Templates and examples
Reference Documents (Load on Demand)
Available references:
-
references/agent-structure.md
- When to use: Creating or refactoring agent structure
- Contains: Complete section-by-section breakdown, common mistakes, validation tips
-
references/yaml-frontmatter-guide.md
- When to use: Writing or debugging YAML frontmatter
- Contains: Field specifications, validation rules, error examples, testing methods
-
references/context7-queries.md
- When to use: Need to verify latest Anthropic best practices
- Contains: Pre-built queries, when to consult Context7, refresh workflows
-
references/color-conventions.md
- When to use: Choosing agent color
- Contains: Color mapping by role, visual organization principles, validation checklist
Loading pattern:
- Don't load all references upfront
- Reference them by name in SKILL.md
- Agent loads specific reference when needed
- Example: "See
references/color-conventions.md for color selection guide"
✅ SUCCESS CRITERIA
Agent creation is complete when:
📚 ADDITIONAL RESOURCES
Official Documentation (via Context7)
- Anthropic Claude Code docs:
/anthropics/claude-code
- Community templates:
/davila7/claude-code-templates
Project-Specific
- Iterative workflow:
.claude/agents/README-ITERATIVE-V2.md
- Agent examples:
.claude/agents/ (architect-agent, test-architect, etc.)
- PRD system:
PRDs/WORKFLOW-ITERATIVO.md
Scripts
scripts/init-agent.sh - Initialize new agent from template
scripts/validate-agent.sh - Validate agent structure and YAML
Templates
assets/agent-minimal-template.md - Complete agent template
assets/yaml-examples.yml - Working YAML frontmatter examples
Last Updated: 2025-10-24
Maintained by: Agent Creator Skill (self-referential)