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.
references/frontmatter-reference.md
1# Command Frontmatter Reference23Complete reference for YAML frontmatter fields in slash commands.45## Frontmatter Overview67YAML frontmatter is optional metadata at the start of command files:89```markdown10---11description: Brief description12allowed-tools: Read, Write13model: sonnet14argument-hint: [arg1] [arg2]15---1617Command prompt content here...18```1920All fields are optional. Commands work without any frontmatter.2122## Field Specifications2324### description2526**Type:** String27**Required:** No28**Default:** First line of command prompt29**Max Length:** ~60 characters recommended for `/help` display3031**Purpose:** Describes what the command does, shown in `/help` output3233**Examples:**34```yaml35description: Review code for security issues36```37```yaml38description: Deploy to staging environment39```40```yaml41description: Generate API documentation42```4344**Best practices:**45- Keep under 60 characters for clean display46- Start with verb (Review, Deploy, Generate)47- Be specific about what command does48- Avoid redundant "command" or "slash command"4950**Good:**51- ✅ "Review PR for code quality and security"52- ✅ "Deploy application to specified environment"53- ✅ "Generate comprehensive API documentation"5455**Bad:**56- ❌ "This command reviews PRs" (unnecessary "This command")57- ❌ "Review" (too vague)58- ❌ "A command that reviews pull requests for code quality, security issues, and best practices" (too long)5960### allowed-tools6162**Type:** String or Array of strings63**Required:** No64**Default:** Inherits from conversation permissions6566**Purpose:** Restrict or specify which tools command can use6768**Formats:**6970**Single tool:**71```yaml72allowed-tools: Read73```7475**Multiple tools (comma-separated):**76```yaml77allowed-tools: Read, Write, Edit78```7980**Multiple tools (array):**81```yaml82allowed-tools:83- Read84- Write85- Bash(git:*)86```8788**Tool Patterns:**8990**Specific tools:**91```yaml92allowed-tools: Read, Grep, Edit93```9495**Bash with command filter:**96```yaml97allowed-tools: Bash(git:*) # Only git commands98allowed-tools: Bash(npm:*) # Only npm commands99allowed-tools: Bash(docker:*) # Only docker commands100```101102**All tools (not recommended):**103```yaml104allowed-tools: "*"105```106107**When to use:**1081091. **Security:** Restrict command to safe operations110```yaml111allowed-tools: Read, Grep # Read-only command112```1131142. **Clarity:** Document required tools115```yaml116allowed-tools: Bash(git:*), Read117```1181193. **Bash execution:** Enable bash command output120```yaml121allowed-tools: Bash(git status:*), Bash(git diff:*)122```123124**Best practices:**125- Be as restrictive as possible126- Use command filters for Bash (e.g., `git:*` not `*`)127- Only specify when different from conversation permissions128- Document why specific tools are needed129130### model131132**Type:** String133**Required:** No134**Default:** Inherits from conversation135**Values:** `sonnet`, `opus`, `haiku`136137**Purpose:** Specify which Claude model executes the command138139**Examples:**140```yaml141model: haiku # Fast, efficient for simple tasks142```143```yaml144model: sonnet # Balanced performance (default)145```146```yaml147model: opus # Maximum capability for complex tasks148```149150**When to use:**151152**Use `haiku` for:**153- Simple, formulaic commands154- Fast execution needed155- Low complexity tasks156- Frequent invocations157158```yaml159---160description: Format code file161model: haiku162---163```164165**Use `sonnet` for:**166- Standard commands (default)167- Balanced speed/quality168- Most common use cases169170```yaml171---172description: Review code changes173model: sonnet174---175```176177**Use `opus` for:**178- Complex analysis179- Architectural decisions180- Deep code understanding181- Critical tasks182183```yaml184---185description: Analyze system architecture186model: opus187---188```189190**Best practices:**191- Omit unless specific need192- Use `haiku` for speed when possible193- Reserve `opus` for genuinely complex tasks194- Test with different models to find right balance195196### argument-hint197198**Type:** String199**Required:** No200**Default:** None201202**Purpose:** Document expected arguments for users and autocomplete203204**Format:**205```yaml206argument-hint: [arg1] [arg2] [optional-arg]207```208209**Examples:**210211**Single argument:**212```yaml213argument-hint: [pr-number]214```215216**Multiple required arguments:**217```yaml218argument-hint: [environment] [version]219```220221**Optional arguments:**222```yaml223argument-hint: [file-path] [options]224```225226**Descriptive names:**227```yaml228argument-hint: [source-branch] [target-branch] [commit-message]229```230231**Best practices:**232- Use square brackets `[]` for each argument233- Use descriptive names (not `arg1`, `arg2`)234- Indicate optional vs required in description235- Match order to positional arguments in command236- Keep concise but clear237238**Examples by pattern:**239240**Simple command:**241```yaml242---243description: Fix issue by number244argument-hint: [issue-number]245---246247Fix issue #$1...248```249250**Multi-argument:**251```yaml252---253description: Deploy to environment254argument-hint: [app-name] [environment] [version]255---256257Deploy $1 to $2 using version $3...258```259260**With options:**261```yaml262---263description: Run tests with options264argument-hint: [test-pattern] [options]265---266267Run tests matching $1 with options: $2268```269270### disable-model-invocation271272**Type:** Boolean273**Required:** No274**Default:** false275276**Purpose:** Prevent SlashCommand tool from programmatically invoking command277278**Examples:**279```yaml280disable-model-invocation: true281```282283**When to use:**2842851. **Manual-only commands:** Commands requiring user judgment286```yaml287---288description: Approve deployment to production289disable-model-invocation: true290---291```2922932. **Destructive operations:** Commands with irreversible effects294```yaml295---296description: Delete all test data297disable-model-invocation: true298---299```3003013. **Interactive workflows:** Commands needing user input302```yaml303---304description: Walk through setup wizard305disable-model-invocation: true306---307```308309**Default behavior (false):**310- Command available to SlashCommand tool311- Claude can invoke programmatically312- Still available for manual invocation313314**When true:**315- Command only invokable by user typing `/command`316- Not available to SlashCommand tool317- Safer for sensitive operations318319**Best practices:**320- Use sparingly (limits Claude's autonomy)321- Document why in command comments322- Consider if command should exist if always manual323324## Complete Examples325326### Minimal Command327328No frontmatter needed:329330```markdown331Review this code for common issues and suggest improvements.332```333334### Simple Command335336Just description:337338```markdown339---340description: Review code for issues341---342343Review this code for common issues and suggest improvements.344```345346### Standard Command347348Description and tools:349350```markdown351---352description: Review Git changes353allowed-tools: Bash(git:*), Read354---355356Current changes: !`git diff --name-only`357358Review each changed file for:359- Code quality360- Potential bugs361- Best practices362```363364### Complex Command365366All common fields:367368```markdown369---370description: Deploy application to environment371argument-hint: [app-name] [environment] [version]372allowed-tools: Bash(kubectl:*), Bash(helm:*), Read373model: sonnet374---375376Deploy $1 to $2 environment using version $3377378Pre-deployment checks:379- Verify $2 configuration380- Check cluster status: !`kubectl cluster-info`381- Validate version $3 exists382383Proceed with deployment following deployment runbook.384```385386### Manual-Only Command387388Restricted invocation:389390```markdown391---392description: Approve production deployment393argument-hint: [deployment-id]394disable-model-invocation: true395allowed-tools: Bash(gh:*)396---397398<!--399MANUAL APPROVAL REQUIRED400This command requires human judgment and cannot be automated.401-->402403Review deployment $1 for production approval:404405Deployment details: !`gh api /deployments/$1`406407Verify:408- All tests passed409- Security scan clean410- Stakeholder approval411- Rollback plan ready412413Type "APPROVED" to confirm deployment.414```415416## Validation417418### Common Errors419420**Invalid YAML syntax:**421```yaml422---423description: Missing quote424allowed-tools: Read, Write425model: sonnet426--- # ❌ Missing closing quote above427```428429**Fix:** Validate YAML syntax430431**Incorrect tool specification:**432```yaml433allowed-tools: Bash # ❌ Missing command filter434```435436**Fix:** Use `Bash(git:*)` format437438**Invalid model name:**439```yaml440model: gpt4 # ❌ Not a valid Claude model441```442443**Fix:** Use `sonnet`, `opus`, or `haiku`444445### Validation Checklist446447Before committing command:448- [ ] YAML syntax valid (no errors)449- [ ] Description under 60 characters450- [ ] allowed-tools uses proper format451- [ ] model is valid value if specified452- [ ] argument-hint matches positional arguments453- [ ] disable-model-invocation used appropriately454455## Best Practices Summary4564571. **Start minimal:** Add frontmatter only when needed4582. **Document arguments:** Always use argument-hint with arguments4593. **Restrict tools:** Use most restrictive allowed-tools that works4604. **Choose right model:** Use haiku for speed, opus for complexity4615. **Manual-only sparingly:** Only use disable-model-invocation when necessary4626. **Clear descriptions:** Make commands discoverable in `/help`4637. **Test thoroughly:** Verify frontmatter works as expected464