logo

Claude Code Command Quick Reference

Filter commands by purpose and quickly find the right entry point

CommandPurposeCategoryExampleTags
claudeEnter interactive modeSessionclaudeInteractiveEntry
claude "task"One-off task then exitQueryclaude "fix the build error"TaskQuick Run
claude -p "query"One-off query then exitQueryclaude -p "explain this function"QueryRead-only
claude -c -p "query"Continue last conversation with one-off outputQueryclaude -c -p "Check for type errors"ContinueRead-only
claude -cContinue most recent conversationHistoryclaude -cSessionContinue
claude -rResume a past conversationHistoryclaude -rHistoryResume
claude -r "<session>" "query"Resume a specific session and continueHistoryclaude -r "auth-refactor" "Finish this PR"HistoryResume
claude --resume <session>Resume a specific sessionHistoryclaude --resume auth-refactorSessionResume
claude updateUpdate Claude CodeUpdateclaude updateUpdateMaintenance
claude commitGenerate commit message and create Git commitGitclaude commitCommitCollaboration
claude mcpManage MCP configuration/connectionsMCPclaude mcpMCPExtension
claude --mcp-config <file>Specify MCP config fileMCPclaude --mcp-config ./mcp.jsonMCPConfig
claude --strict-mcp-configStrict MCP config validationMCPclaude --strict-mcp-config --mcp-config ./mcp.jsonMCPSecurity
claude --add-dir <path>Add more directories to contextContextclaude --add-dir ../apps ../libContextMulti-dir
claude --model <name>Specify modelModelclaude --model claude-sonnet-4-5-20250929ModelPerformance
claude --fallback-model <name>Set fallback modelModelclaude -p --fallback-model sonnet "query"ModelReliability
claude --permission-mode <mode>Set permission modePermissionsclaude --permission-mode planPermissionsSecurity
claude --dangerously-skip-permissionsSkip permission confirmation (use with caution)Permissionsclaude --dangerously-skip-permissionsHigh RiskAutomation
claude --output-format jsonJSON output (with -p)Outputclaude -p "query" --output-format jsonStructuredIntegration
claude --output-format stream-jsonStreaming JSON output (with -p)Outputclaude -p --output-format stream-json --include-partial-messages "query"StreamingIntegration
claude --settings <file>Load settings fileConfigclaude --settings ./settings.jsonConfigTeam
claude --setting-sources <list>Select setting sourcesConfigclaude --setting-sources user,projectConfigPriority
claude --ideEnable IDE integrationConfigclaude --ideIDEIntegration
claude --verboseOutput more detailed logsInfoclaude --verboseDebugLogging
claude -vCheck versionInfoclaude -vVersionDiagnostics
/clearClear current contextIn-Session/clearContextCost Control
/initInitialize project collaboration contextIn-Session/initInitializeCollaboration
/helpView command helpIn-Session/helpHelpQuick Reference
34

Claude Code Custom Commands

⏱️ 12 min

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:

  1. Problem clarification - Define core problem, identify hidden assumptions
  2. 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
  3. Critical evaluation - Challenge assumptions, identify cognitive biases
  4. 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:

  1. Analysis phase - Review conversation history, check current CLAUDE.md
  2. Identify issues
    • Inconsistencies in Claude's responses
    • Misunderstandings of user requests
    • Areas where more detail could help
  3. Interactive phase - Suggest improvements, wait for confirmation
  4. 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:

  1. Fetch PR details: gh pr view 123
  2. Get code diff: gh pr diff 123
  3. Analyze changes and provide review feedback
  4. 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:

  1. Fetch Issue details
  2. Analyze root cause
  3. Create fix branch
  4. Implement fix
  5. 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

ParameterDescriptionExample
descriptionCommand description"Code review command"
argument-hintParameter hint"[pr-number]"
allowed-toolsAllowed tools"Read, Edit, Bash(git:*)"

Common allowed-tools Values

  • Read - Read files
  • Write - Write files
  • Edit - Edit files
  • Glob - File search
  • Grep - Content search
  • Bash - Execute commands
  • Bash(git:*) - Git commands only
  • Bash(gh:*) - gh commands only
  • TodoWrite - Task management
  • WebFetch - Web fetching

Best Practices

  1. Name clearly - command name should directly express the function
  2. Describe accurately - description should be instantly understandable
  3. Limit tools - use allowed-tools to restrict permissions
  4. Structured output - define a clear output format
  5. Error handling - consider edge cases

CommandPurposeScenario
/think-harderDeep analysisComplex problem analysis
/reflectionInstruction tuningImproving CLAUDE.md
/gh:review-prPR reviewCode review
/gh:fix-issueIssue fixBug fixing
/translateTech translationDocument translation

Reference: feiskyer/claude-code-settings

📚 相关资源