Claude Code Custom Commands
Claude Code Custom Commands Guide
Claude Code supports custom slash commands that let you quickly run common operations. This chapter covers practical commands and how to use them.
What Are Custom Commands
Custom commands are Markdown files stored in .claude/commands/. You invoke them with /<command-name>.
Command File Structure
---
description: Command description (shown in command list)
argument-hint: [parameter hint]
allowed-tools: Read, Edit, Bash(git:*)
---
# Command Title
This is the command's prompt content...
Use $ARGUMENTS to reference user-provided arguments
Command File Location
.claude/
└── commands/
├── think-harder.md
├── reflection.md
└── gh/
├── review-pr.md
└── fix-issue.md
Analysis & Thinking Commands
/think-harder - Enhanced Deep Analysis
For deep analysis of complex problems.
Usage:
/think-harder How should I design a high-concurrency order system?
Core flow:
- Problem clarification - Define core problem, identify hidden assumptions
- Multi-dimensional analysis
- Structural decomposition: break into base components and dependencies
- Stakeholder perspectives: consider all affected parties
- Temporal analysis: short-term vs long-term impact
- Causal reasoning: map cause-effect chains and feedback loops
- Critical evaluation - Challenge assumptions, identify cognitive biases
- Synthesis - Connect cross-domain insights
Output format:
- Problem reframe
- Key insights
- Reasoning chain
- Alternative approaches
- Uncertainties
- Actionable recommendations
/think-ultra - Ultra-Deep Analysis
More comprehensive than /think-harder. For extremely complex problems.
Usage:
/think-ultra How would you build an AI programming assistant from scratch?
/reflection - Instruction Reflection
Analyzes the current session and improves instructions in CLAUDE.md.
Usage:
/reflection
Core flow:
- Analysis phase - Review conversation history, check current CLAUDE.md
- Identify issues
- Inconsistencies in Claude's responses
- Misunderstandings of user requests
- Areas where more detail could help
- Interactive phase - Suggest improvements, wait for confirmation
- Implementation phase - Modify CLAUDE.md
Best practices:
- Use TodoWrite to track analysis progress
- Read current CLAUDE.md thoroughly before modifying
- Consider edge cases and common scenarios
/reflection-harder - Deep Session Analysis
Comprehensive analysis of the entire session, capturing learnings and improvement points.
Usage:
/reflection-harder
/eureka - Record Technical Breakthroughs
Use this when you have an important technical insight worth saving.
Usage:
/eureka Discovered that React 18 Suspense perfectly solves the data-fetching waterfall problem
GitHub Integration Commands
/gh:review-pr - PR Code Review
Auto-fetches PR details and runs a code review.
Usage:
/gh:review-pr 123
Core flow:
- Fetch PR details:
gh pr view 123 - Get code diff:
gh pr diff 123 - Analyze changes and provide review feedback
- Post comments directly on GitHub
Review focus:
- Code correctness
- Project convention compliance
- Performance impact
- Test coverage
- Security considerations
Comment format:
# Get commit ID
gh api repos/OWNER/REPO/pulls/123 --jq '.head.sha'
# Post comment
gh api repos/OWNER/REPO/pulls/123/comments \
--method POST \
--field body="Suggestion: consider using useMemo here for optimization" \
--field commit_id="abc123" \
--field path="src/components/List.tsx" \
--field line=42 \
--field side="RIGHT"
/gh:fix-issue - Issue Fix Workflow
Complete Issue fix workflow.
Usage:
/gh:fix-issue 456
Core flow:
- Fetch Issue details
- Analyze root cause
- Create fix branch
- Implement fix
- Create PR linked to Issue
Utility Commands
/translate - Technical Translation
Translates English/Japanese technical content to Chinese.
Usage:
/translate This article explains the fundamentals of RAG...
Features:
- Preserves technical terms
- Maintains code formatting
- Proper technical expression in the target language
/cc:create-command - Create New Command
Quickly creates a new custom command.
Usage:
/cc:create-command deploy "Automated deployment to production"
Creating Your Own Commands
Step 1: Create the Command File
mkdir -p .claude/commands
touch .claude/commands/my-command.md
Step 2: Write the Command Content
---
description: My custom command description
argument-hint: [parameter description]
allowed-tools: Read, Write, Bash
---
# Command Title
You are a professional [role].
## Task
Based on the user's $ARGUMENTS, perform the following:
1. Step one
2. Step two
3. Step three
## Output Format
- Use clear headings
- Provide specific recommendations
Step 3: Use the Command
/my-command argument content
Command Config Parameters
| Parameter | Description | Example |
|---|---|---|
description | Command description | "Code review command" |
argument-hint | Parameter hint | "[pr-number]" |
allowed-tools | Allowed tools | "Read, Edit, Bash(git:*)" |
Common allowed-tools Values
Read- Read filesWrite- Write filesEdit- Edit filesGlob- File searchGrep- Content searchBash- Execute commandsBash(git:*)- Git commands onlyBash(gh:*)- gh commands onlyTodoWrite- Task managementWebFetch- Web fetching
Best Practices
- Name clearly - command name should directly express the function
- Describe accurately - description should be instantly understandable
- Limit tools - use allowed-tools to restrict permissions
- Structured output - define a clear output format
- Error handling - consider edge cases
Recommended Command Set
| Command | Purpose | Scenario |
|---|---|---|
/think-harder | Deep analysis | Complex problem analysis |
/reflection | Instruction tuning | Improving CLAUDE.md |
/gh:review-pr | PR review | Code review |
/gh:fix-issue | Issue fix | Bug fixing |
/translate | Tech translation | Document translation |
Reference: feiskyer/claude-code-settings