Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Guidance for developing custom slash commands for Claude Code plugins from the official Anthropic repository.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
README.md
1# Command Development Skill23Comprehensive guidance on creating Claude Code slash commands, including file format, frontmatter options, dynamic arguments, and best practices.45## Overview67This skill provides knowledge about:8- Slash command file format and structure9- YAML frontmatter configuration fields10- Dynamic arguments ($ARGUMENTS, $1, $2, etc.)11- File references with @ syntax12- Bash execution with !` syntax13- Command organization and namespacing14- Best practices for command development15- Plugin-specific features (${CLAUDE_PLUGIN_ROOT}, plugin patterns)16- Integration with plugin components (agents, skills, hooks)17- Validation patterns and error handling1819## Skill Structure2021### SKILL.md (~2,470 words)2223Core skill content covering:2425**Fundamentals:**26- Command basics and locations27- File format (Markdown with optional frontmatter)28- YAML frontmatter fields overview29- Dynamic arguments ($ARGUMENTS and positional)30- File references (@ syntax)31- Bash execution (!` syntax)32- Command organization patterns33- Best practices and common patterns34- Troubleshooting3536**Plugin-Specific:**37- ${CLAUDE_PLUGIN_ROOT} environment variable38- Plugin command discovery and organization39- Plugin command patterns (configuration, template, multi-script)40- Integration with plugin components (agents, skills, hooks)41- Validation patterns (argument, file, resource, error handling)4243### References4445Detailed documentation:4647- **frontmatter-reference.md**: Complete YAML frontmatter field specifications48- All field descriptions with types and defaults49- When to use each field50- Examples and best practices51- Validation and common errors5253- **plugin-features-reference.md**: Plugin-specific command features54- Plugin command discovery and organization55- ${CLAUDE_PLUGIN_ROOT} environment variable usage56- Plugin command patterns (configuration, template, multi-script)57- Integration with plugin agents, skills, and hooks58- Validation patterns and error handling5960### Examples6162Practical command examples:6364- **simple-commands.md**: 10 complete command examples65- Code review commands66- Testing commands67- Deployment commands68- Documentation generators69- Git integration commands70- Analysis and research commands7172- **plugin-commands.md**: 10 plugin-specific command examples73- Simple plugin commands with scripts74- Multi-script workflows75- Template-based generation76- Configuration-driven deployment77- Agent and skill integration78- Multi-component workflows79- Validated input commands80- Environment-aware commands8182## When This Skill Triggers8384Claude Code activates this skill when users:85- Ask to "create a slash command" or "add a command"86- Need to "write a custom command"87- Want to "define command arguments"88- Ask about "command frontmatter" or YAML configuration89- Need to "organize commands" or use namespacing90- Want to create commands with file references91- Ask about "bash execution in commands"92- Need command development best practices9394## Progressive Disclosure9596The skill uses progressive disclosure:97981. **SKILL.md** (~2,470 words): Core concepts, common patterns, and plugin features overview992. **References** (~13,500 words total): Detailed specifications100- frontmatter-reference.md (~1,200 words)101- plugin-features-reference.md (~1,800 words)102- interactive-commands.md (~2,500 words)103- advanced-workflows.md (~1,700 words)104- testing-strategies.md (~2,200 words)105- documentation-patterns.md (~2,000 words)106- marketplace-considerations.md (~2,200 words)1073. **Examples** (~6,000 words total): Complete working command examples108- simple-commands.md109- plugin-commands.md110111Claude loads references and examples as needed based on task.112113## Command Basics Quick Reference114115### File Format116117```markdown118---119description: Brief description120argument-hint: [arg1] [arg2]121allowed-tools: Read, Bash(git:*)122---123124Command prompt content with:125- Arguments: $1, $2, or $ARGUMENTS126- Files: @path/to/file127- Bash: !`command here`128```129130### Locations131132- **Project**: `.claude/commands/` (shared with team)133- **Personal**: `~/.claude/commands/` (your commands)134- **Plugin**: `plugin-name/commands/` (plugin-specific)135136### Key Features137138**Dynamic arguments:**139- `$ARGUMENTS` - All arguments as single string140- `$1`, `$2`, `$3` - Positional arguments141142**File references:**143- `@path/to/file` - Include file contents144145**Bash execution:**146- `!`command`` - Execute and include output147148## Frontmatter Fields Quick Reference149150| Field | Purpose | Example |151|-------|---------|---------|152| `description` | Brief description for /help | `"Review code for issues"` |153| `allowed-tools` | Restrict tool access | `Read, Bash(git:*)` |154| `model` | Specify model | `sonnet`, `opus`, `haiku` |155| `argument-hint` | Document arguments | `[pr-number] [priority]` |156| `disable-model-invocation` | Manual-only command | `true` |157158## Common Patterns159160### Simple Review Command161162```markdown163---164description: Review code for issues165---166167Review this code for quality and potential bugs.168```169170### Command with Arguments171172```markdown173---174description: Deploy to environment175argument-hint: [environment] [version]176---177178Deploy to $1 environment using version $2179```180181### Command with File Reference182183```markdown184---185description: Document file186argument-hint: [file-path]187---188189Generate documentation for @$1190```191192### Command with Bash Execution193194```markdown195---196description: Show Git status197allowed-tools: Bash(git:*)198---199200Current status: !`git status`201Recent commits: !`git log --oneline -5`202```203204## Development Workflow2052061. **Design command:**207- Define purpose and scope208- Determine required arguments209- Identify needed tools2102112. **Create file:**212- Choose appropriate location213- Create `.md` file with command name214- Write basic prompt2152163. **Add frontmatter:**217- Start minimal (just description)218- Add fields as needed (allowed-tools, etc.)219- Document arguments with argument-hint2202214. **Test command:**222- Invoke with `/command-name`223- Verify arguments work224- Check bash execution225- Test file references2262275. **Refine:**228- Improve prompt clarity229- Handle edge cases230- Add examples in comments231- Document requirements232233## Best Practices Summary2342351. **Single responsibility**: One command, one clear purpose2362. **Clear descriptions**: Make discoverable in `/help`2373. **Document arguments**: Always use argument-hint2384. **Minimal tools**: Use most restrictive allowed-tools2395. **Test thoroughly**: Verify all features work2406. **Add comments**: Explain complex logic2417. **Handle errors**: Consider missing arguments/files242243## Status244245**Completed enhancements:**246- ✓ Plugin command patterns (${CLAUDE_PLUGIN_ROOT}, discovery, organization)247- ✓ Integration patterns (agents, skills, hooks coordination)248- ✓ Validation patterns (input, file, resource validation, error handling)249250**Remaining enhancements (in progress):**251- Advanced workflows (multi-step command sequences)252- Testing strategies (how to test commands effectively)253- Documentation patterns (command documentation best practices)254- Marketplace considerations (publishing and distribution)255256## Maintenance257258To update this skill:2591. Keep SKILL.md focused on core fundamentals2602. Move detailed specifications to references/2613. Add new examples/ for different use cases2624. Update frontmatter when new fields added2635. Ensure imperative/infinitive form throughout2646. Test examples work with current Claude Code265266## Version History267268**v0.1.0** (2025-01-15):269- Initial release with basic command fundamentals270- Frontmatter field reference271- 10 simple command examples272- Ready for plugin-specific pattern additions273