Interpretive guidance for designing Claude Code slash commands. Helps you apply official documentation effectively and create high-quality commands. Use when creating or reviewing slash commands.
Inherits all available tools
Additional assets for this skill
This skill inherits all available tools. When active, it can use any tool Claude has access to.
This skill provides interpretive guidance and best practices for creating Claude Code slash commands. It helps you understand what the docs mean and how to create excellent commands.
| If you need to... | Go to... |
|---|---|
| Understand command vs agent vs skill | Decision Framework |
| See basic command structure | Quick Start |
| Learn frontmatter fields | Frontmatter Fields |
| Use arguments in commands | Argument Syntax |
| Execute bash or reference files | Advanced Features |
| Decide delegation vs direct implementation | Best Practices |
| Avoid common mistakes | Common Pitfalls |
| Validate before completing | Quality Checklist |
Create a command at .claude/commands/my-command.md:
---
description: Brief description of what this command does
argument-hint: expected-args
---
Command prompt content here.
Use $1, $2 for individual arguments or $ARGUMENTS for all.
Delegation pattern (recommended for complex tasks):
---
description: Run full test suite and analyze failures
---
Use the test-runner agent to execute all tests and provide detailed failure analysis.
Claude Code changes rapidly and is post-training knowledge. Fetch these docs when creating commands to ensure current syntax:
Key distinction:
/command-nameQuality test: If you want this to happen automatically based on context, it's an agent, not a command.
Commands are Markdown files with optional YAML frontmatter:
---
description: Brief description (optional, defaults to first line)
argument-hint: [expected-args]
allowed-tools: Tool1, Tool2
disable-model-invocation: false
---
Command prompt content goes here.
Use $1, $2 for individual arguments or $ARGUMENTS for all.
All fields are optional:
| Field | Purpose | Default |
|---|---|---|
description | Brief command description for /help | First line of prompt |
argument-hint | Expected arguments (e.g., [pr-number] [priority]) | None |
allowed-tools | Restrict to specific tools (e.g., Bash(git:*)) | Inherits from conversation |
disable-model-invocation | Prevents SlashCommand tool from auto-invoking | false |
Best practice: Always include description even though it's optional - improves discoverability and Claude's ability to use the SlashCommand tool.
All arguments as single string:
$ARGUMENTS
Example: /fix-issue 123 high-priority → $ARGUMENTS = "123 high-priority"
Individual positional arguments:
$1, $2, $3, etc.
Example: /review-pr 456 high alice → $1="456", $2="high", $3="alice"
Official guidance: "Use individual arguments ($1, $2) for complex commands with multiple parameters"
Best practice: Use $1, $2 when you need arguments in different parts of the prompt or want to provide defaults. Keep argument parsing simple - if you need validation or complex logic, delegate to an agent.
! PrefixExecute bash commands before the prompt runs:
---
allowed-tools: Bash(git:*)
---
!git status
Review the git status above and suggest next steps.
@ PrefixInclude file contents in the prompt:
Review @src/utils/helpers.js for potential improvements.
Multiple files: Compare @src/old.js with @src/new.js
Organize commands in subdirectories:
.claude/commands/frontend/component.md → /component (project:frontend)
.claude/commands/backend/endpoint.md → /endpoint (project:backend)
Command name comes from filename, subdirectory appears in /help as namespace label.
Use Command when:
/something to make X happen"Use Agent when:
Use Skill when:
Most robust commands delegate to specialized agents rather than implementing complex logic:
---
description: Run full test suite and analyze failures
---
Use the test-runner agent to execute all tests and provide detailed failure analysis.
Why this works:
When to use: Any command that needs file reading/parsing, complex decision trees, error recovery logic, or multi-step state management.
For simple, deterministic operations, restrict tools for security and clarity:
---
description: Show git status
allowed-tools: Bash(git status:*)
---
Run `git status` and display the output.
Benefits:
Commands CAN handle sequential bash operations when they're straightforward and don't require file inspection or complex parsing:
---
description: Install GitHub CLI if not present
allowed-tools: Bash
---
Check if gh CLI is installed. If not, provide installation instructions for the user's platform.
Simple workflow:
1. Check: `which gh` or `command -v gh`
2. If not found, provide platform-specific install guidance
3. Verify with `gh --version` if installed
4. Output success message or next steps
This pattern is OK in commands when you have:
✅ 3-5 sequential bash steps - Simple linear workflow ✅ Basic conditionals - Simple if/else (installed vs not installed) ✅ Simple verification - Exit codes, command success/failure ✅ User-facing instructions - Output guidance, next steps
When to keep it in a command:
which, command -v)brew install, apt-get install)--version, status checks)Rule of thumb: If you can write it as 3-5 bash commands with simple if/else logic and no file reading, keep it in the command.
Delegate to an agent when you need:
❌ File reading/parsing - Requires Read, Grep, or complex text processing ❌ Complex decision trees - Framework detection, config file parsing, multi-path logic ❌ Error recovery logic - Retries, fallbacks, multiple failure modes ❌ State management - Tracking across multiple steps, rollback capability ❌ Multiple tool orchestration - Coordinating Read + Grep + Write + Bash
Example requiring agent delegation:
# ❌ Too complex for command - needs agent
---
description: Set up test environment
---
Detect test framework by:
1. Read package.json, check for jest/mocha/vitest dependencies
2. Read test config files (.jestrc, mocha.opts, vitest.config.ts)
3. Scan for existing test files in src/, tests/, __tests__/
4. Parse configuration to determine coverage settings
5. Install missing dependencies based on framework
6. Generate framework-specific config if missing
7. Create example test files following detected patterns
8. Verify setup with test run
Why this needs an agent:
Better approach:
---
description: Set up test environment for current project
---
Use the test-setup agent to detect the test framework, install dependencies, and configure the testing environment.
The threshold:
which gh && gh --version || echo "Install with: brew install gh"For creating files/code, be specific about structure and requirements:
---
description: Create a new React component with TypeScript
argument-hint: component-name
---
Create a new React component named `$1` in the components directory.
Include:
- TypeScript interface for props
- Basic component structure with proper typing
- Export statement
- Test file in __tests__ directory
Follow project conventions for imports and file structure.
Problem: Using commands to store documentation instead of actions
Example of wrong pattern:
---
description: Show API documentation standards
---
Our API documentation standards:
[50 lines of guidelines...]
Why it's wrong: This is knowledge, not an action. Commands should DO things.
Better approach: Create a skill for standards, command for action:
---
description: Generate API documentation for current file
---
Use the api-documentation skill to generate comprehensive API docs for the current file.
Problem: Commands with complex logic that agents handle better
Example of wrong pattern:
---
description: Run tests
---
First, scan for test files in src/, tests/, and __tests__.
Then determine the test framework by checking package.json.
If Jest, run `npm test`. If pytest, run `pytest -v`.
Parse the output for failures and categorize by severity...
Why it's wrong: Too much logic, too many decisions, better in isolated context.
Better approach:
---
description: Run full test suite
---
Use the test-runner agent to execute the full test suite and analyze failures.
Problem: Arguments that need extensive parsing or validation
Example of questionable pattern:
/deploy env=staging branch=main force=true rollback=false
Why it's questionable: No argument validation, no type checking, brittle parsing.
Better approach: Keep arguments simple, let agent handle complexity:
---
description: Deploy to specified environment
argument-hint: environment
---
Deploy to $1 environment. The deployer agent will handle validation, rollback strategy, and confirmation.
Problem: Single command tries to do too much
Example:
description: Test, lint, format, commit, and deploy
Why it fails: Multiple distinct operations with different failure modes.
Better: Separate commands or orchestrator agent that coordinates multiple specialized agents.
Before finalizing a command:
Structure (from official docs):
Best Practices (opinionated):
description field for discoverabilityargument-hint if arguments expectedOfficial locations:
.claude/commands/ (shared with team)~/.claude/commands/ (personal, all projects)plugins/[name]/commands/ (when creating plugin commands)Resolution logic:
plugins/[name]/commands/.claude/commands/ (project-level)Command names must be kebab-case (filename without .md extension):
Transform these:
run-tests.mdcreate-component.mddeploy-staging.mdBefore (from hypothetical docs):
---
description: Create component
---
Create a new component.
Issues:
After (applying best practices):
---
description: Create a new React component with TypeScript and tests
argument-hint: component-name
---
Create a new React component named `$1`.
Requirements:
- Location: src/components/$1/$1.tsx
- TypeScript interface for props
- Proper exports (default and named)
- Test file: src/components/$1/__tests__/$1.test.tsx
- Storybook file: src/components/$1/$1.stories.tsx
Follow project conventions:
- Use existing component patterns as reference
- Include JSDoc comments
- Export types separately
Improvements: