Claude Code Commands: Complete Reference Guide 2025

The ultimate Claude Code commands reference. Master all 60+ CLI commands, slash commands, keyboard shortcuts, and flags with practical examples for efficient AI-powered development.

ClaudeCode.Guide Team
commandsreferenceCLIshortcutsproductivity

Claude Code Commands: Complete Reference Guide 2025

Master every Claude Code command with this comprehensive reference. Whether you're a beginner or an advanced user, this guide covers all CLI commands, slash commands, keyboard shortcuts, and flags you need for efficient AI-powered development.

Quick Start Commands

Installation & Setup

# Install Claude Code globally
npm install -g @anthropic-ai/claude-code

# Start Claude Code in current directory
claude

# Start with a specific task
claude "fix the login bug"

# Start in a specific directory
claude --cwd /path/to/project

Essential First Commands

CommandDescription
claudeStart interactive mode
claude --helpShow all available options
claude --versionCheck installed version
claude configOpen configuration settings

Slash Commands (Interactive Mode)

Slash commands are used inside the Claude Code interactive session. Type / to see all available commands.

CommandDescription
/helpDisplay help and available commands
/clearClear the current conversation context
/compactCompact conversation history to save tokens
/exit or /quitExit Claude Code
/statusShow current session status

File & Code Operations

CommandDescription
/add <file>Add a file to the conversation context
/drop <file>Remove a file from context
/filesList all files currently in context
/diffShow pending changes
/undoUndo the last file change

Git Integration

CommandDescription
/commitCreate a git commit with AI-generated message
/prCreate a pull request
/branch <name>Create and switch to a new branch
/statusShow git status

Mode Switching

CommandDescription
/chatSwitch to chat-only mode (no file edits)
/codeSwitch to code editing mode
/planEnter planning mode for complex tasks

Advanced Commands

CommandDescription
/configOpen settings configuration
/modelSwitch between Claude models
/costShow token usage and cost estimate
/historyView conversation history
/resumeResume a previous session
/checkpointCreate a checkpoint for rollback
/rollbackRollback to a previous checkpoint

CLI Flags & Options

Execution Modes

# Interactive mode (default)
claude

# Execute a single command and exit
claude -p "explain this function"

# Pipe mode - read from stdin
echo "fix this code" | claude -p

# Continue from last session
claude --resume

# Resume specific session
claude --resume <session-id>

Configuration Flags

FlagDescription
--cwd <path>Set working directory
--model <model>Specify Claude model (opus, sonnet, haiku)
--max-tokens <n>Set maximum response tokens
--temperature <n>Set temperature (0-1)
--no-gitDisable git integration
--verboseEnable verbose output
--quietMinimal output mode

Output Control

# JSON output format
claude -p "list all functions" --output-format json

# Markdown output
claude -p "explain the architecture" --output-format markdown

# Stream output (default)
claude -p "write a test" --stream

# No streaming
claude -p "write a test" --no-stream

Safety & Permissions

# Auto-approve all file edits (use with caution)
claude --dangerously-skip-permissions

# Dry run - show what would be done without executing
claude --dry-run

# Sandbox mode - restrict file access
claude --sandbox

Keyboard Shortcuts

During Interactive Session

ShortcutAction
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
Ctrl+LClear screen
/ Navigate command history
TabAutocomplete commands/files
EscCancel current input

Quick Actions

ShortcutAction
!<cmd>Execute bash command directly
@<file>Quick add file to context
#<tag>Add context tag

Bang Commands (!)

Execute shell commands directly without leaving Claude Code:

# Run any bash command
!ls -la

# Run tests
!npm test

# Git operations
!git status
!git diff

# Build commands
!npm run build

MCP (Model Context Protocol) Commands

CommandDescription
/mcp listList available MCP servers
/mcp connect <server>Connect to an MCP server
/mcp disconnectDisconnect from MCP server
/mcp statusShow MCP connection status

Configuration Commands

# Open config in editor
claude config

# Set API key
claude config set api_key <key>

# Set default model
claude config set model sonnet

# Enable/disable features
claude config set auto_commit true
claude config set show_cost true

# View current config
claude config list

Session Management

# List previous sessions
claude sessions list

# Resume last session
claude --resume

# Resume specific session
claude --resume abc123

# Delete session
claude sessions delete <id>

# Export session
claude sessions export <id> > session.json

Advanced Usage Examples

Automated Workflows

# Fix all TypeScript errors
claude -p "fix all TypeScript errors in src/"

# Generate tests for a file
claude -p "write comprehensive tests for src/utils.ts"

# Refactor with specific instructions
claude -p "refactor this class to use dependency injection" --add src/service.ts

# Code review
claude -p "review this PR for security issues" --add $(git diff --name-only main)

Integration with CI/CD

# Use in scripts
claude -p "generate changelog from recent commits" --output-format markdown > CHANGELOG.md

# Automated code fixes
claude -p "fix linting errors" --dangerously-skip-permissions

# Generate documentation
claude -p "generate API documentation" --output-format markdown > docs/API.md

Multi-file Operations

# Add multiple files
claude --add "src/**/*.ts" -p "analyze the codebase structure"

# Exclude patterns
claude --exclude "node_modules/**" --exclude "dist/**"

# Work with specific files
claude -p "refactor these components" --add src/components/Header.tsx --add src/components/Footer.tsx

Environment Variables

VariableDescription
ANTHROPIC_API_KEYYour Anthropic API key
CLAUDE_CODE_MODELDefault model to use
CLAUDE_CODE_CONFIGPath to config file
CLAUDE_CODE_CACHECache directory path
NO_COLORDisable colored output

Troubleshooting Commands

# Check installation
claude --version

# Verify API connection
claude --check-api

# Reset configuration
claude config reset

# Clear cache
claude cache clear

# Debug mode
claude --debug

# Show detailed logs
claude --verbose

Quick Reference Card

Most Used Commands

CommandWhat it does
claudeStart interactive session
/clearFresh start, clear context
/add <file>Include file in conversation
!git statusQuick git check
/commitAI-assisted commit
/undoRevert last change
Ctrl+CStop current operation

Pro Tips

  1. Use /clear frequently - Start fresh for new tasks to avoid context pollution
  2. Leverage ! commands - Execute quick shell commands without breaking flow
  3. Add files selectively - Only add files relevant to your current task
  4. Use --model haiku - For quick, simple tasks to save costs
  5. Create checkpoints - Before major refactoring operations

Last updated: January 2025. Commands are based on Claude Code version 1.x.