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.
examples/simple-commands.md
1# Simple Command Examples23Basic slash command patterns for common use cases.45**Important:** All examples below are written as instructions FOR Claude (agent consumption), not messages TO users. Commands tell Claude what to do, not tell users what will happen.67## Example 1: Code Review Command89**File:** `.claude/commands/review.md`1011```markdown12---13description: Review code for quality and issues14allowed-tools: Read, Bash(git:*)15---1617Review the code in this repository for:18191. **Code Quality:**20- Readability and maintainability21- Consistent style and formatting22- Appropriate abstraction levels23242. **Potential Issues:**25- Logic errors or bugs26- Edge cases not handled27- Performance concerns28293. **Best Practices:**30- Design patterns used correctly31- Error handling present32- Documentation adequate3334Provide specific feedback with file and line references.35```3637**Usage:**38```39> /review40```4142---4344## Example 2: Security Review Command4546**File:** `.claude/commands/security-review.md`4748```markdown49---50description: Review code for security vulnerabilities51allowed-tools: Read, Grep52model: sonnet53---5455Perform comprehensive security review checking for:5657**Common Vulnerabilities:**58- SQL injection risks59- Cross-site scripting (XSS)60- Authentication/authorization issues61- Insecure data handling62- Hardcoded secrets or credentials6364**Security Best Practices:**65- Input validation present66- Output encoding correct67- Secure defaults used68- Error messages safe69- Logging appropriate (no sensitive data)7071For each issue found:72- File and line number73- Severity (Critical/High/Medium/Low)74- Description of vulnerability75- Recommended fix7677Prioritize issues by severity.78```7980**Usage:**81```82> /security-review83```8485---8687## Example 3: Test Command with File Argument8889**File:** `.claude/commands/test-file.md`9091```markdown92---93description: Run tests for specific file94argument-hint: [test-file]95allowed-tools: Bash(npm:*), Bash(jest:*)96---9798Run tests for $1:99100Test execution: !`npm test $1`101102Analyze results:103- Tests passed/failed104- Code coverage105- Performance issues106- Flaky tests107108If failures found, suggest fixes based on error messages.109```110111**Usage:**112```113> /test-file src/utils/helpers.test.ts114```115116---117118## Example 4: Documentation Generator119120**File:** `.claude/commands/document.md`121122```markdown123---124description: Generate documentation for file125argument-hint: [source-file]126---127128Generate comprehensive documentation for @$1129130Include:131132**Overview:**133- Purpose and responsibility134- Main functionality135- Dependencies136137**API Documentation:**138- Function/method signatures139- Parameter descriptions with types140- Return values with types141- Exceptions/errors thrown142143**Usage Examples:**144- Basic usage145- Common patterns146- Edge cases147148**Implementation Notes:**149- Algorithm complexity150- Performance considerations151- Known limitations152153Format as Markdown suitable for project documentation.154```155156**Usage:**157```158> /document src/api/users.ts159```160161---162163## Example 5: Git Status Summary164165**File:** `.claude/commands/git-status.md`166167```markdown168---169description: Summarize Git repository status170allowed-tools: Bash(git:*)171---172173Repository Status Summary:174175**Current Branch:** !`git branch --show-current`176177**Status:** !`git status --short`178179**Recent Commits:** !`git log --oneline -5`180181**Remote Status:** !`git fetch && git status -sb`182183Provide:184- Summary of changes185- Suggested next actions186- Any warnings or issues187```188189**Usage:**190```191> /git-status192```193194---195196## Example 6: Deployment Command197198**File:** `.claude/commands/deploy.md`199200```markdown201---202description: Deploy to specified environment203argument-hint: [environment] [version]204allowed-tools: Bash(kubectl:*), Read205---206207Deploy to $1 environment using version $2208209**Pre-deployment Checks:**2101. Verify $1 configuration exists2112. Check version $2 is valid2123. Verify cluster accessibility: !`kubectl cluster-info`213214**Deployment Steps:**2151. Update deployment manifest with version $22162. Apply configuration to $12173. Monitor rollout status2184. Verify pod health2195. Run smoke tests220221**Rollback Plan:**222Document current version for rollback if issues occur.223224Proceed with deployment? (yes/no)225```226227**Usage:**228```229> /deploy staging v1.2.3230```231232---233234## Example 7: Comparison Command235236**File:** `.claude/commands/compare-files.md`237238```markdown239---240description: Compare two files241argument-hint: [file1] [file2]242---243244Compare @$1 with @$2245246**Analysis:**2472481. **Differences:**249- Lines added250- Lines removed251- Lines modified2522532. **Functional Changes:**254- Breaking changes255- New features256- Bug fixes257- Refactoring2582593. **Impact:**260- Affected components261- Required updates elsewhere262- Migration requirements2632644. **Recommendations:**265- Code review focus areas266- Testing requirements267- Documentation updates needed268269Present as structured comparison report.270```271272**Usage:**273```274> /compare-files src/old-api.ts src/new-api.ts275```276277---278279## Example 8: Quick Fix Command280281**File:** `.claude/commands/quick-fix.md`282283```markdown284---285description: Quick fix for common issues286argument-hint: [issue-description]287model: haiku288---289290Quickly fix: $ARGUMENTS291292**Approach:**2931. Identify the issue2942. Find relevant code2953. Propose fix2964. Explain solution297298Focus on:299- Simple, direct solution300- Minimal changes301- Following existing patterns302- No breaking changes303304Provide code changes with file paths and line numbers.305```306307**Usage:**308```309> /quick-fix button not responding to clicks310> /quick-fix typo in error message311```312313---314315## Example 9: Research Command316317**File:** `.claude/commands/research.md`318319```markdown320---321description: Research best practices for topic322argument-hint: [topic]323model: sonnet324---325326Research best practices for: $ARGUMENTS327328**Coverage:**3293301. **Current State:**331- How we currently handle this332- Existing implementations3333342. **Industry Standards:**335- Common patterns336- Recommended approaches337- Tools and libraries3383393. **Comparison:**340- Our approach vs standards341- Gaps or improvements needed342- Migration considerations3433444. **Recommendations:**345- Concrete action items346- Priority and effort estimates347- Resources for implementation348349Provide actionable guidance based on research.350```351352**Usage:**353```354> /research error handling in async operations355> /research API authentication patterns356```357358---359360## Example 10: Explain Code Command361362**File:** `.claude/commands/explain.md`363364```markdown365---366description: Explain how code works367argument-hint: [file-or-function]368---369370Explain @$1 in detail371372**Explanation Structure:**3733741. **Overview:**375- What it does376- Why it exists377- How it fits in system3783792. **Step-by-Step:**380- Line-by-line walkthrough381- Key algorithms or logic382- Important details3833843. **Inputs and Outputs:**385- Parameters and types386- Return values387- Side effects3883894. **Edge Cases:**390- Error handling391- Special cases392- Limitations3933945. **Usage Examples:**395- How to call it396- Common patterns397- Integration points398399Explain at level appropriate for junior engineer.400```401402**Usage:**403```404> /explain src/utils/cache.ts405> /explain AuthService.login406```407408---409410## Key Patterns411412### Pattern 1: Read-Only Analysis413414```markdown415---416allowed-tools: Read, Grep417---418419Analyze but don't modify...420```421422**Use for:** Code review, documentation, analysis423424### Pattern 2: Git Operations425426```markdown427---428allowed-tools: Bash(git:*)429---430431!`git status`432Analyze and suggest...433```434435**Use for:** Repository status, commit analysis436437### Pattern 3: Single Argument438439```markdown440---441argument-hint: [target]442---443444Process $1...445```446447**Use for:** File operations, targeted actions448449### Pattern 4: Multiple Arguments450451```markdown452---453argument-hint: [source] [target] [options]454---455456Process $1 to $2 with $3...457```458459**Use for:** Workflows, deployments, comparisons460461### Pattern 5: Fast Execution462463```markdown464---465model: haiku466---467468Quick simple task...469```470471**Use for:** Simple, repetitive commands472473### Pattern 6: File Comparison474475```markdown476Compare @$1 with @$2...477```478479**Use for:** Diff analysis, migration planning480481### Pattern 7: Context Gathering482483```markdown484---485allowed-tools: Bash(git:*), Read486---487488Context: !`git status`489Files: @file1 @file2490491Analyze...492```493494**Use for:** Informed decision making495496## Tips for Writing Simple Commands4974981. **Start basic:** Single responsibility, clear purpose4992. **Add complexity gradually:** Start without frontmatter5003. **Test incrementally:** Verify each feature works5014. **Use descriptive names:** Command name should indicate purpose5025. **Document arguments:** Always use argument-hint5036. **Provide examples:** Show usage in comments5047. **Handle errors:** Consider missing arguments or files505