Claude-skill-registry claude-subagent-development
This skill should be used when the user asks to "create a subagent", "validate a subagent", "generate subagent schema", "check subagent configuration", "write subagent specification", or mentions subagent development, validation, or protocol documentation for Claude Code.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/claude-subagent-development" ~/.claude/skills/majiayu000-claude-skill-registry-claude-subagent-development-eb119e && rm -rf "$T"
skills/data/claude-subagent-development/SKILL.mdClaude Code Subagent Development
Comprehensive guidance for creating, validating, and documenting Claude Code subagents with schemas and protocol specifications.
Purpose
This skill provides structured workflows for developing production-ready Claude Code subagents. Use when creating new subagents, validating existing configurations, generating JSON schemas for validation, or writing technical specifications for subagent protocols.
When to Use
This skill should be used when:
- Creating new subagent configurations
- Validating subagent YAML frontmatter and structure
- Generating JSON schemas for subagent validation
- Writing protocol specifications and technical documentation
- Reviewing subagent configurations for best practices
- Debugging subagent loading or invocation issues
Core Concepts
Subagent Structure
Subagents are Markdown files with YAML frontmatter:
--- name: subagent-identifier description: When and how to use this subagent tools: Tool1, Tool2 model: sonnet permissionMode: default skills: skill1, skill2 --- System prompt content in Markdown format.
Required Fields
- name: Lowercase identifier with hyphens (pattern:
)^[a-z0-9-]+$ - description: 10-2000 characters describing purpose and usage triggers
- content: Markdown body below frontmatter (implicit, not in frontmatter)
Optional Fields
- tools: Comma-separated list of allowed tools (inherits all if omitted)
- model:
,sonnet
,opus
, orhaikuinherit - permissionMode:
,default
,acceptEdits
,bypassPermissions
,planignore - skills: Comma-separated skill names to auto-load
Workflows
Create a New Subagent
-
Define purpose and scope:
- Identify the specific task or domain
- List concrete usage examples
- Determine required tools and permissions
-
Use the subagent template:
cp assets/template.md .claude/agents/your-subagent.md -
Configure frontmatter:
- Set unique
(lowercase, hyphens)name - Write specific
with trigger phrasesdescription - Specify minimal
needed (or omit for all)tools - Choose appropriate
andmodelpermissionMode
- Set unique
-
Write system prompt:
- Clear role definition
- Step-by-step procedures
- Expected behaviors and constraints
- Output format guidance
-
Validate configuration:
scripts/validate-subagent.sh .claude/agents/your-subagent.md
Validate Existing Subagent
Use the validation script to check:
- YAML frontmatter syntax
- Required fields present
- Field value formats (name pattern, model alias, etc.)
- Tool names validity
- Description quality
scripts/validate-subagent.sh path/to/subagent.md
The script validates against the JSON schema in
assets/subagent-schema.json.
Generate JSON Schema
When needing a validation schema for tooling:
- Use the existing schema in
assets/subagent-schema.json - Customize if needed for specific validation requirements
- Integrate with CI/CD for automated validation
The schema includes:
- Field types and patterns
- Required vs optional fields
- Value constraints (enums, lengths, patterns)
- Examples and descriptions
Write Protocol Specification
For technical documentation:
-
Reference the protocol spec:
references/protocol-specification.md -
Include key sections:
- Architecture overview
- File format specification
- Configuration schema
- Lifecycle management
- Security considerations
- Examples
-
Adapt for your needs:
- Extract relevant sections
- Add project-specific details
- Include team conventions
Tools and Resources
Validation Script
scripts/validate-subagent.sh checks:
- File exists and is readable
- Valid YAML frontmatter
- Required fields present
- Name pattern compliance
- Model alias validity
- Tool name validation (optional check)
Usage:
scripts/validate-subagent.sh <subagent-file>
Exit codes:
- 0: Valid configuration
- 1: Validation errors found
Creation Script
scripts/create-subagent.sh scaffolds a new subagent:
scripts/create-subagent.sh <name> <scope>
Arguments:
: Subagent identifier (lowercase, hyphens)name
:scope
(.claude/agents/) orproject
(~/.claude/agents/)user
Creates file from template and opens in editor.
JSON Schema
assets/subagent-schema.json provides:
- Complete field definitions
- Validation rules
- Type constraints
- Pattern matching
- Example configurations
Use with validation tools:
# With ajv-cli ajv validate -s assets/subagent-schema.json -d your-subagent.json # With Python jsonschema python -c "import json, jsonschema; \ jsonschema.validate( \ json.load(open('subagent.json')), \ json.load(open('assets/subagent-schema.json')))"
Best Practices
Strong Descriptions
Include specific trigger phrases:
Good:
description: Expert code reviewer. Use PROACTIVELY after code changes to review quality, security, and best practices. Checks for vulnerabilities, performance issues, style violations.
Poor:
description: Helps with code
Minimal Tool Permissions
Grant only necessary tools:
# Read-only analysis tools: Read, Grep, Glob # Code modification tools: Read, Edit, Write # Full workflow tools: Read, Edit, Write, Bash
Clear System Prompts
Structure prompts with:
- Role definition
- When invoked actions
- Methodology/checklist
- Output format
- Examples
Model Selection
Choose appropriate model:
- haiku: Fast searches, simple tasks
- sonnet: General purpose, complex reasoning (default)
- opus: Maximum capability, critical tasks
- inherit: Match main conversation's model
Additional Resources
Reference Files
Comprehensive documentation in
references/:
-
: Complete subagent protocol spec (20,000+ words)protocol-specification.md- Architecture and data flow
- File format specification
- All configuration fields detailed
- Lifecycle management
- Security considerations
- Built-in subagents reference
-
: Detailed field-by-field referencefield-reference.md- Each field's purpose, format, constraints
- Examples and anti-patterns
- Common mistakes to avoid
-
: Advanced best practicesbest-practices.md- Design patterns for subagents
- Tool permission strategies
- Context management
- Team collaboration workflows
Example Files
Production-ready examples in
examples/:
-
: Comprehensive code review subagentcode-reviewer.md- Security, quality, performance checks
- Structured feedback format
- Tool usage: Read, Grep, Glob, Bash
-
: Systematic debugging specialistdebugger.md- Root cause analysis methodology
- Strategic debugging techniques
- Common issue patterns
-
: Test automation experttest-runner.md- Auto-detect test frameworks
- Failure analysis and fixing
- Fast execution with Haiku
Asset Files
Templates and schemas in
assets/:
: Complete JSON Schema for validationsubagent-schema.json
: Base template for new subagentstemplate.md
Quick Reference
Subagent File Locations
- Project scope:
.claude/agents/name.md - User scope:
~/.claude/agents/name.md - Plugin scope:
plugin-dir/agents/name.md
Precedence Order
When names conflict:
- Project-level (highest)
- User-level
- CLI-defined
- Built-in (lowest)
Available Tools
Common tools for subagents:
- Delegate to subagentsTask
- Execute shell commandsBash
- File operationsRead, Edit, Write
- Search operationsGrep, Glob
- Web operationsWebFetch, WebSearch
- Task managementTodoWrite- MCP tools:
mcp__<server>__<tool>
Permission Modes
: Standard permission flow (recommended)default
: Auto-approve edit operationsacceptEdits
: Skip all permissions (use cautiously)bypassPermissions
: Read-only explorationplan
: Ignore permission dialogsignore
Troubleshooting
Subagent Not Loading
Check:
- File exists in correct location
- Valid YAML frontmatter syntax
- Required fields present (name, description)
- Name follows pattern:
^[a-z0-9-]+$
Run validation:
scripts/validate-subagent.sh path/to/subagent.md
Subagent Not Triggering
Improve description:
- Add specific trigger phrases users would say
- Include concrete scenarios
- Use emphatic language ("PROACTIVELY", "MUST BE USED")
Example:
description: Security auditor. Use PROACTIVELY when reviewing code, checking for vulnerabilities, or analyzing security. Checks OWASP Top 10, injection attacks, authentication issues.
Tool Not Available
Verify:
- Tool name spelled correctly (case-sensitive)
- Tool in allowed list if
specifiedtools - MCP tool format:
mcp__server__tool
Check available tools:
Task, Bash, Glob, Grep, Read, Edit, Write, NotebookEdit, WebFetch, WebSearch, BashOutput, KillShell, AskUserQuestion, TodoWrite, Skill, SlashCommand
Permission Denied
Adjust
permissionMode:
: User approves operationsdefault
: Auto-approve edits onlyacceptEdits
: Auto-approve all (use carefully)bypassPermissions
Or grant specific tools in
tools field.
Implementation Checklist
Before deploying a subagent:
Structure:
- Valid YAML frontmatter
- Required fields present (name, description)
- Markdown body substantial (50+ characters)
- File in correct location
Configuration:
- Name follows pattern
^[a-z0-9-]+$ - Description includes specific triggers
- Tools minimal but sufficient
- Model appropriate for task
- Permission mode suitable for automation level
Content Quality:
- Clear role definition
- Step-by-step procedures
- Concrete examples
- Expected output format
- Constraints and boundaries
Validation:
- Passes schema validation
- No YAML syntax errors
- Tool names valid
- Model alias correct
Testing:
- Triggers on expected queries
- Uses correct tools
- Produces quality output
- Respects permissions
Version History
- 1.0.0 (2025-12-03): Initial release
- Complete protocol specification
- JSON schema validation
- Validation and creation scripts
- Three production-ready examples
- Comprehensive reference documentation