| description | Create a new Claude Agent Skill following Anthropic's best practices with prompt engineering guidance |
Create Agent Skill
Create a new Claude Agent Skill following Anthropic's best practices for progressive disclosure, token optimization, and effective skill design.
Overview
This command guides you through creating a production-quality Agent Skill based on:
- Anthropic's Agent Skills architecture (progressive disclosure, hybrid knowledge+code)
- Real-world examples from Claude Cookbooks (financial analyzer, brand guidelines, financial modeling)
- Token optimization patterns (75-80% reduction strategies)
- Security best practices and development workflow
Skill to create: ${1:-my-skill}
Purpose: ${2:-Describe what this skill does}
Location: ${3:-project} (Options: project, user)
Workflow
Phase 1: Skill Requirements Analysis
Before creating any files, use the prompt-engineering agent to design the skill:
Design an Agent Skill with the following requirements:
Skill Name: ${1:-my-skill}
Purpose: ${2:-Describe what this skill does}
Design Requirements:
-
Name and Description Optimization
- Skill names MUST follow the
{group}-{name} prefix convention matching the existing library
- Standard groups:
code, github, git, infra, ui, pm, meta, knowledge, db, jj โ use a new group only if none fit
- Examples from the live library:
python-development, github-pr, github-org-team-activity, infra-homebrew, ui-playwright, pm-product-management, meta-prompt-engineering
- Validate full name follows format: lowercase-alphanumeric-with-hyphens (max 64 chars)
- Craft description that clearly conveys WHEN to use this skill (max 1024 chars)
- Think from Claude's perspective: what helps triggering decisions?
- Examples:
- โ
Good:
github-org-team-activity, python-development, infra-homebrew
- โ Bad:
activity (missing group prefix), github (no descriptive suffix), comprehensive-github-org-activity-tracker (too long)
-
Progressive Disclosure Architecture
- Design 3-level content hierarchy:
- Level 1 (Metadata): Name + description in YAML frontmatter
- Level 2 (Core Instructions): Main SKILL.md body (target <5,000 tokens)
- Level 3+ (Contextual): Additional files loaded only when needed
- Identify what content belongs at each level
- Keep mutually exclusive contexts in separate files
-
Hybrid Knowledge + Code Strategy
- Determine what should be declarative instructions vs. executable code
- Plan bundled scripts for deterministic operations (parsing, calculations, transformations)
- Design scripts to serve dual purpose: executable tool + reference documentation
- Consider: Python for data processing, JavaScript for web operations, shell for system tasks
-
Token Optimization
- Apply patterns from financial applications:
- Structure over text: Use JSON/CSV/structured formats vs. natural language
- Focus over comprehensiveness: Multiple focused files vs. monolithic docs
- Pipeline over monolith: Sequential generation allowing earlier outputs to inform later steps
- Separation over inclusion: Keep mutually exclusive contexts separate
- Estimate token budget for each component
-
Security Considerations
- Never hardcode API keys or sensitive data
- Plan input sanitization for bundled scripts
- Identify external network connections requiring audit
- Consider access control needs
-
Directory Structure
- Plan required files:
${1:-my-skill}/
โโโ SKILL.md # REQUIRED
โโโ reference.md # Optional: technical documentation
โโโ examples.md # Optional: usage examples
โโโ scripts/ # Optional: executable code
โ โโโ process.py
โ โโโ utils.js
โโโ resources/ # Optional: templates, data files
โโโ template.xlsx
Deliverables:
- Optimized skill name and description
- Content hierarchy design (what goes in each level)
- List of files to create with purpose for each
- Script specifications (if needed): language, purpose, key functions
- Token budget estimate
- Security considerations checklist
- Complete SKILL.md template with YAML frontmatter and markdown body
Phase 2: Create Skill Directory Structure
Based on the prompt-engineering agent's design, create the skill directory:
Location determination:
- Project skill:
.claude/skills/${1:-my-skill}/ (visible to all project users)
- User skill:
~/.claude/skills/${1:-my-skill}/ (personal, available across all projects)
Create directories:
mkdir -p .claude/skills/${1:-my-skill}/{scripts,resources}
mkdir -p ~/.claude/skills/${1:-my-skill}/{scripts,resources}
Phase 3: Create SKILL.md (Core Instructions)
File: SKILL.md in the skill directory
Template structure (use the prompt-engineering agent's output):
---
name: ${1:-my-skill}
description: [Use the optimized description from prompt-engineering agent]
---
# ${1:-My Skill Title}
[Brief introduction explaining what this skill does and when to use it]
## Core Instructions
### When to Use This Skill
- Use case 1: [specific scenario]
- Use case 2: [specific scenario]
- Use case 3: [specific scenario]
### Main Workflow
1. **Step 1**: [First major step]
- Substep details
- Considerations
2. **Step 2**: [Second major step]
- Substep details
- Considerations
3. **Step 3**: [Third major step]
- Substep details
- Considerations
### Key Principles
- **Principle 1**: Explanation
- **Principle 2**: Explanation
- **Principle 3**: Explanation
### Best Practices
- Practice 1
- Practice 2
- Practice 3
### Common Pitfalls
- โ **Pitfall 1**: What to avoid and why
- โ **Pitfall 2**: What to avoid and why
### Progressive Context Loading
- For detailed technical reference, see: `reference.md`
- For code examples, see: `examples.md`
- For executable scripts, see: `scripts/` directory
### Security Notes
[If applicable: input validation, API key handling, data sanitization]
## Token Budget
Estimated tokens: [from prompt-engineering agent analysis]
Quality standards:
- Keep SKILL.md body under 5,000 tokens
- Use clear, imperative instructions
- Reference additional files for detailed content
- Think from Claude's execution perspective
Phase 4: Create Supporting Files
Based on the prompt-engineering agent's design, create additional files:
Optional: reference.md
Purpose: Technical documentation, API references, detailed specifications
Load trigger: When Claude needs deep technical details
Content: Comprehensive reference material that would bloat SKILL.md
Optional: examples.md
Purpose: Code examples, sample outputs, usage demonstrations
Load trigger: When Claude needs concrete examples
Content: Working examples showing skill usage patterns
Optional: scripts/
Purpose: Executable code for deterministic operations
Design principles:
- Comprehensive type hints
- Error handling with graceful fallbacks
- Clear separation of concerns
- Dual-purpose: executable + documentation
- Security: input sanitization, no hardcoded secrets
Example Python script structure:
"""
Brief description of what this script does.
This script serves dual purposes:
1. Executable tool Claude can run directly
2. Reference documentation Claude can read for understanding
"""
from typing import Dict, List, Optional
import json
import sys
def safe_operation(value: float, divisor: float) -> Optional[float]:
"""
Safely perform operation with error handling.
Args:
value: Input value
divisor: Divisor value
Returns:
Result or None if error
"""
try:
if divisor == 0:
return None
return value / divisor
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
return None
def main():
"""Main entry point for script execution."""
pass
if __name__ == "__main__":
main()
Optional: resources/
Purpose: Templates, data files, configuration files
Examples: Excel templates, JSON schemas, sample datasets
Phase 5: Evaluation and Testing
Create test cases to validate the skill:
-
Representative Tasks
- List 3-5 tasks this skill should handle
- Run Claude with the skill on these tasks
- Observe skill loading patterns (is it triggered appropriately?)
-
Token Usage Analysis
- Measure actual tokens used for typical operations
- Compare to token budget estimate
- Identify optimization opportunities
-
Error Scenarios
- Test with invalid inputs
- Test edge cases
- Verify error handling in scripts
-
Security Audit
- Review for hardcoded secrets
- Check input sanitization
- Verify external network access is documented
Phase 6: Iteration Based on Usage
Monitor and refine:
-
Usage Patterns
- Is Claude loading the skill at appropriate times?
- Are there false positives (loaded unnecessarily)?
- Are there false negatives (not loaded when needed)?
-
Token Optimization
- Are all files being used efficiently?
- Can mutually exclusive content be separated further?
- Can structured formats replace natural language?
-
Collaborative Refinement
- Ask Claude to capture successful approaches into skill context
- When Claude goes off-track, ask for self-reflection on what went wrong
- Let Claude help evolve its own skill based on experience
Phase 7: Documentation and Sharing
Create skill documentation:
README.md in skill directory:
# ${1:-My Skill}
${2:-Brief description}
## Installation
**Project-wide** (shared with team):
\`\`\`bash
cp -r ${1:-my-skill} /path/to/project/.claude/skills/
\`\`\`
**Personal** (available across all projects):
\`\`\`bash
cp -r ${1:-my-skill} ~/.claude/skills/
\`\`\`
## Usage
This skill is automatically discovered by Claude when relevant.
**Triggers**: [Description of when Claude should use this skill]
**Example tasks**:
- Task example 1
- Task example 2
- Task example 3
## Structure
- \`SKILL.md\`: Core instructions (loaded when skill is relevant)
- \`reference.md\`: Technical documentation (loaded for detailed queries)
- \`scripts/\`: Executable code for deterministic operations
- \`resources/\`: Templates and data files
## Security
- โ
No hardcoded secrets
- โ
Input sanitization in scripts
- โ
External connections documented
## Version History
- v1.0.0 (YYYY-MM-DD): Initial release
## Contributing
[Instructions for contributing improvements]
Best Practices Summary
Naming and Discovery
- โ
Use descriptive, specific names (not too generic, not too long)
- โ
Write descriptions that answer "when should this be used?"
- โ
Think from Claude's perspective for triggering decisions
Progressive Disclosure
- โ
Keep SKILL.md under 5,000 tokens
- โ
Split large content into separate referenced files
- โ
Keep mutually exclusive contexts separate
Token Optimization
- โ
Prefer structured formats over natural language
- โ
Create focused files rather than monolithic documents
- โ
Use pipelines where earlier outputs inform later steps
Code Quality
- โ
Comprehensive type hints and error handling
- โ
Design scripts for dual purpose (executable + documentation)
- โ
Clear separation of concerns
Security
- โ
Never hardcode API keys or sensitive data
- โ
Sanitize all inputs to bundled scripts
- โ
Document all external network connections
- โ
Audit less-trusted skills thoroughly
Development Process
- โ
Start with evaluation (identify capability gaps from real tasks)
- โ
Build incrementally based on actual needs
- โ
Monitor how Claude actually uses the skill
- โ
Iterate collaboratively with Claude
Real-World Examples Reference
Consult these examples for patterns:
-
Financial Statement Analyzer (hybrid knowledge + code)
- SKILL.md: Instructions for 20+ financial ratios
- calculate_ratios.py: FinancialRatioCalculator class with type hints, error handling
- Shows dual-purpose scripts: executable + documentation
-
Brand Guidelines Enforcer (organizational knowledge capture)
- Exact color palettes, typography hierarchies, logo rules
- Document-type-specific guidelines
- Transforms abstract standards into executable instructions
-
Financial Modeling (complex workflows)
- Multi-step analysis workflows
- Cross-format generation (Excel โ PowerPoint โ PDF โ Word)
- Domain-specific modeling patterns
Command Completion
After creating the skill, verify:
Skill location:
- Project:
.claude/skills/${1:-my-skill}/
- User:
~/.claude/skills/${1:-my-skill}/
Next steps:
- Test skill on representative tasks
- Monitor Claude's usage patterns
- Iterate based on observations
- Share with team (if project skill) or use across projects (if user skill)
Additional Resources