Claude Code is Anthropic's official AI-powered CLI tool — a terminal-based coding assistant that can understand your project, write and edit code, run commands, and iterate based on your feedback. Here's a complete command reference to help you get productive quickly.
Quick Start
# Install Claude Code (requires Node.js)
npm install -g @anthropic-ai/claude-code
# On Windows, first open WSL
wsl
# Launch the interactive REPL
claude
# Start with an initial prompt
claude "summarise this project"
# Check installed version
claude --version
# Update to the latest version
claude update
Level 1: Basic Commands
REPL Navigation
/help # Show help and available commands
/exit # Exit the REPL
/clear # Clear conversation history
/config # Open configuration panel
/doctor # Check Claude Code installation health
File Operations
# Print mode — execute a query and exit
claude -p "explain this function"
# Process piped content
cat logs.txt | claude -p "explain"
# Continue the most recent conversation
claude -c
# Continue with a follow-up prompt
claude -c -p "Check for type errors"
Session Management
# Resume a session by ID
claude -r "abc123" "Finish this PR"
# Continue current session
claude --continue
# Show cost and duration of current session
/cos
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current operation |
Ctrl+D | Exit Claude Code |
Tab | Auto-complete |
Up/Down | Navigate command history |
Level 2: Model & Output Configuration
# Switch models
claude --model sonnet
claude --model opus
claude --model claude-sonnet-4-20250514
# Output formats
claude -p "query" --output-format json
claude -p "query" --output-format text
claude -p "query" --output-format stream-json
# Limit conversation turns
claude -p --max-turns 3 "query"
# Enable verbose logging
claude --verbose
# Add additional working directories
claude --add-dir ../apps ../lib
Level 3: Tool & Permission Management
# Allow specific tools without prompting
claude --allowedTools "Bash(git log:*)" "Bash(git diff:*)" "Write"
# Disallow specific tools
claude --disallowedTools "Bash(rm:*)" "Bash(sudo:*)"
# Skip all permission prompts (use with caution)
claude --dangerously-skip-permissions
Level 4: Advanced Piping & Automation
# Git integration
git log --oneline | claude -p "summarise these commits"
git diff HEAD~1 | claude -p "review this PR for security issues"
# Log analysis
cat error.log | claude -p "find the root cause"
# JSON output for scripting
SESSION=$(claude -p "start analysis" --output-format json | jq -r '.session_id')
claude -r "$SESSION" "continue analysis"
Level 5: Custom Slash Commands
Create markdown files in
.claude/commands/to define your own slash commands. These become available in any Claude Code session within that project.
# Example: .claude/commands/review.md
# This creates a /review slash command
Perform a thorough code review of the current changes.
Check for: security issues, performance problems, and code style.
Suggest specific improvements with code examples.
Slash Commands Reference
| Command | Description |
|---|---|
/help | Show help and available commands |
/exit | Exit the REPL |
/clear | Reset conversation history and context |
/config | Open configuration panel |
/doctor | Check installation health |
/cos | Show cost and duration of session |
/compact [instructions] | Summarise conversation to reduce context |
/ide | Manage IDE integrations (VS Code etc.) |
/mcp | Access Model Context Protocol functionality |
Best Practices
Performance
- Use
/clearfrequently between unrelated tasks - Use
/compactfor long sessions to keep context manageable - Specify exact tools with
--allowedToolsto reduce overhead - Limit context with
--max-turnsfor focused, single-shot queries
Security
- Avoid
--dangerously-skip-permissionsin shared or automated environments - Use
--disallowedTools "Bash(rm:*)" "Bash(sudo:*)"to prevent destructive operations - Keep Claude Code updated to get the latest security patches
Workflow
- Create custom slash commands in
.claude/commands/for tasks you repeat - Use
--output-format jsonwhen integrating with scripts or CI pipelines - Use session IDs (
-r) to resume long-running analysis sessions