Claude Code Commands: Complete CLI and Slash Command Reference
Claude Code ships over 70 slash commands, 50+ CLI flags, and a fully customizable keybinding system. Most developers use fewer than ten. This reference organizes every command by workflow stage, from first-time project setup through shipping a pull request, so you can find the right command without scrolling through alphabetical docs.
How Commands Fit Into the Claude Code Interface
Claude Code authored roughly 4% of all public GitHub commits by February 2026, processing around 135,000 commits per day according to a SemiAnalysis analysis. That throughput depends on three input surfaces working together: CLI flags set before a session starts, slash commands issued during a session, and keyboard shortcuts that trigger actions without typing a command.
CLI flags control how Claude Code launches. They set the model, permission mode, output format, and working directories before the first prompt. Run claude --model opus --permission-mode plan and every interaction in that session inherits those choices. Flags are the right tool for scripted pipelines, CI integrations, and any invocation where you want deterministic behavior without manual confirmation.
Slash commands run inside a live session. Type / at the prompt to see the full list (documented in the official commands reference), or type / followed by letters to filter. A command is only recognized at the start of your message. Everything after the command name becomes its argument. These commands handle model switching, context management, code review, agent coordination, and project setup.
Keyboard shortcuts provide the fast interaction layer. Press Ctrl+T to toggle the task list, Ctrl+R to search command history, or Shift+Tab to cycle permission modes. Unlike slash commands, shortcuts work while Claude is actively responding, so you can background a task with Ctrl+B or interrupt with Ctrl+C without waiting for output to finish.
The three surfaces complement each other. CLI flags handle what you know before the session. Slash commands handle decisions you make during work. Keyboard shortcuts handle split-second actions that would be slower to type out.
CLI Flags for Launching and Configuring Sessions
Every Claude Code session begins with a claude command on the terminal. The full flag list lives in the CLI reference docs. Here are the most useful flags organized by what they control.
Starting and Resuming Sessions
The basic launch options control which conversation you enter:
claudestarts a fresh interactive sessionclaude "query"starts a session with an initial promptclaude -ccontinues the most recent conversation in the current directoryclaude -r "name"resumes a session by name or IDclaude -p "query"runs a one-shot query in print mode and exits (no interactive session)cat file | claude -p "query"pipes file content into a non-interactive query
Print mode (-p) is what makes Claude Code scriptable. Combine it with --output-format json or --output-format stream-json to parse structured output in automation pipelines. Add --max-turns 3 to cap agentic loops or --max-budget-usd 5.00 to set a spending ceiling.
Model and Reasoning Control
--model sonnetsets the model (acceptsopus,sonnet,haiku,fable, or a full model ID)--effort highsets the reasoning effort level (low,medium,high,xhigh,max)--advisor opusenables a second model that advises at key decision points--fallback-model sonnet,haikudefines a fallback chain when the primary model is overloaded
Permission and Safety Modes
--permission-mode planstarts in plan mode (read-only analysis, explicit approval before changes)--permission-mode autostarts in auto mode with classifier-based approval--dangerously-skip-permissionsskips all permission prompts (use with caution)--allowedTools "Bash(git *)" "Read"pre-approves specific tool patterns--disallowedTools "Edit"blocks specific tools entirely
Prompt Customization Four flags control the system prompt.
The append flags add rules on top of the default Claude Code prompt. The replacement flags replace it entirely:
--append-system-prompt "Always use TypeScript"adds instructions to the default prompt--append-system-prompt-file ./rules.txtappends a file's contents to the default prompt--system-prompt "You are a Python expert"replaces the entire default prompt--system-prompt-file ./custom-prompt.txtreplaces with a file's contents
Use append when Claude should remain a coding assistant that also follows your extra rules. Use replace when you're building a non-coding agent or a pipeline worker with a fundamentally different identity.
Background and Parallel Execution - --bg "investigate the flaky test" starts a background agent and returns immediately
--bg --exec 'pytest -x'runs a shell command as a background job-w feature-authstarts Claude in an isolated git worktree-w feature-auth --tmuxcreates a tmux session for the worktree
Slash Commands for In-Session Control
Slash commands are where most daily interaction happens. The official docs list over 70 commands, but the ones that matter cluster around five workflow stages.
Project Setup
Run these once when you first open a repo:
/initgenerates a starter CLAUDE.md file with project conventions/memoryedits CLAUDE.md files and manages auto-memory entries/mcpmanages MCP server connections and OAuth authentication/agentsconfigures subagent definitions/permissionsmanages tool allow, ask, and deny rules
Model and Context Management
These commands adjust how Claude thinks during a session:
/modelopens a picker to switch models mid-session (presssto apply for this session only)/effortsets reasoning effort with an interactive slider (low through max, plus ultracode)/fasttoggles fast mode on or off/compactsummarizes conversation history to free context window space/contextvisualizes current context usage as a colored grid with optimization suggestions/btw "quick question"asks a side question without adding to the conversation history
Code Review and Shipping
Before you push, these commands catch problems:
/diffopens an interactive diff viewer showing uncommitted changes and per-turn diffs/code-reviewreviews the current diff for correctness bugs and cleanup opportunities/code-review --fixapplies review findings to your working tree/code-review ultraruns a deep multi-agent review in the cloud/review 123reviews a GitHub pull request by number/security-reviewanalyzes pending changes for security vulnerabilities/simplifyreviews changed code for cleanup opportunities and applies fixes
Parallel Work and Background Agents
Coordinate multiple agents from a single session:
/backgrounddetaches the current session to run as a background agent/batch "migrate src/ from Solid to React"decomposes work into parallel units across worktrees/fork "refactor the auth module"spawns a background subagent with the full conversation context/branchcreates a conversation branch you can return to with/resume/taskslists everything running in the background/workflowsshows progress for running workflow orchestrations
Session Management
Navigate between sessions and recover from mistakes:
/clearstarts a fresh conversation (previous stays available via/resume)/resumereopens a previous conversation by name or from a picker/rewindrolls code and conversation back to a checkpoint/teleportpulls a web session into the terminal/remote-controlmakes the session controllable from claude.ai/exportsaves the conversation as plain text/copycopies the last response to clipboard (pass a number for earlier responses)
Give your Claude Code agents persistent file storage
Fast.io workspaces let Claude Code agents read, write, and hand off files through MCP, with the endpoint ready at /mcp. Starts with a 14-day free trial.
How to Navigate and Customize Keybindings
Keyboard shortcuts are the fast way to interact with Claude Code. They work across different contexts, from the main chat input to diff viewers and permission dialogs.
Essential Global Shortcuts
These work everywhere in the application:
- Ctrl+C interrupts the current operation
- Ctrl+D exits Claude Code
- Ctrl+T toggles the task list
- Ctrl+O toggles the verbose transcript view
Chat Input Shortcuts
These work while typing in the main input area:
- Enter submits the message
- Ctrl+J inserts a newline without submitting
- Shift+Tab cycles through permission modes (default, acceptEdits, plan, auto)
- Meta+P (Option+P on macOS) opens the model picker
- Meta+O toggles fast mode
- Meta+T toggles extended thinking
- Ctrl+R opens history search to find and rerun previous commands
- Ctrl+S stashes the current prompt
- Ctrl+G opens the input in an external editor
- Ctrl+V pastes an image from clipboard
Permission Dialog Shortcuts
When Claude asks for permission to run a tool:
- Y or Enter confirms
- N or Escape declines
- Shift+Tab cycles permission modes
- Ctrl+E toggles the permission explanation
Diff Viewer Navigation Inside the /diff viewer:
- Left/Right switches between diff sources
- Up/Down or K/J navigates between files
- Enter views diff details
- Space scrolls down a full viewport
- Shift+G jumps to the bottom
Customizing Keybindings
Run /keybindings to create or open ~/.claude/keybindings.json. Each binding block specifies a context and maps keystrokes to actions:
{
"bindings": [
{
"context": "Chat",
"bindings": {
"ctrl+e": "chat:externalEditor",
"ctrl+u": null
}
}
]
}
Setting an action to null unbinds it. Claude Code validates your keybindings and shows warnings for parse errors, reserved shortcut conflicts, and duplicate bindings. Run /doctor to check for issues.
Chords let you create two-key sequences: ctrl+k ctrl+s means press Ctrl+K, release, then Ctrl+S. The existing chord ctrl+x ctrl+k stops all running background subagents, and ctrl+x ctrl+e opens an external editor.
Three shortcuts cannot be rebound: Ctrl+C (hardcoded interrupt), Ctrl+D (hardcoded exit), and Ctrl+M (identical to Enter in terminals).
How to Automate Workflows with CLI Flags
The CLI flags that matter most are the ones that make Claude Code work without human interaction. Here are concrete patterns for CI pipelines, scripts, and agent workflows.
One-Shot Code Review in CI
Run a non-interactive code review that exits with a status code:
claude ultrareview 1234 --json --timeout 15
This reviews PR #1234, outputs structured JSON findings, and times out after 15 minutes. Exit code 0 means success, 1 means issues found.
Scripted File Analysis Pipe content directly into Claude for processing:
cat src/auth.ts | claude -p "List every API endpoint in this file" \
--output-format json \
--max-turns 1
The --max-turns 1 flag prevents agentic loops. Claude reads the piped content, answers the question, and exits.
Budget-Capped Background Agent Start a background agent with spending controls:
claude --bg \
--permission-mode auto \
--max-budget-usd 2.00 \
"Investigate why the login test is flaky and suggest a fix"
The agent runs in the background, auto-approves tool calls within safety bounds, and stops before spending more than $2.
Structured Output for Pipelines Get validated JSON matching a schema:
claude -p \
--json-schema '{"type":"object","properties":{"bugs":{"type":"array"}}}' \
"Find bugs in src/parser.ts"
Claude completes its analysis and returns JSON that matches the schema. This pairs well with jq for downstream processing.
Connecting External Tools via MCP
Load MCP servers from a config file for specialized tool access:
claude --mcp-config ./mcp-servers.json \
--strict-mcp-config \
"Query the database for recent error rates"
The --strict-mcp-config flag ensures only servers from your config file load, ignoring any global MCP configuration. This gives repeatable behavior across machines.
Storing files that agents produce in a shared workspace makes these automation patterns more useful. Fast.io provides persistent workspaces with MCP tooling at /mcp, so Claude Code agents can read input files, write results, and hand off to human reviewers through a single workspace. Plans include workspace storage and monthly credits, and every org starts with a 14-day free trial. See /storage-for-agents/ for setup details.
Quick Reference Tables
Most-Used Slash Commands
/modelswitches the active model/effortadjusts reasoning depth/compactfrees context window space/diffshows what changed/code-reviewreviews the diff for bugs/planenters read-only analysis mode/backgrounddetaches the session to run in the background/resumereturns to a previous conversation/rewindrolls back code and conversation/clearstarts a fresh conversation
Most-Used CLI Flags
-pruns in non-interactive print mode-ccontinues the most recent conversation-r "name"resumes a session by name--modelsets the model--effortsets reasoning effort--permission-modesets the permission mode--bgstarts as a background agent-wstarts in a git worktree--output-format jsonreturns structured output--max-turnscaps agentic loops
Essential Keyboard Shortcuts
- Ctrl+C interrupts
- Ctrl+D exits
- Ctrl+T toggles task list
- Ctrl+R searches history
- Ctrl+B backgrounds the current task
- Shift+Tab cycles permission modes
- Meta+P opens model picker
- Enter submits, Ctrl+J inserts newline
- Ctrl+G opens external editor
- Ctrl+V pastes image
Subcommands for Session Management
claude agentsmonitors background sessionsclaude attach <id>connects to a background sessionclaude stop <id>stops a background sessionclaude logs <id>prints recent output from a background sessionclaude rm <id>removes a background session from the listclaude respawn <id>restarts a background session with its conversation intact
Diagnostic Commands
When something breaks, these commands help:
/doctordiagnoses installation and settings issues (pressfto auto-fix)/debugenables debug logging and analyzes the session log/context allshows full context usage breakdown/usageshows session cost, plan limits, and activity statsclaude daemon statuschecks the background session supervisor
Frequently Asked Questions
What commands does Claude Code support?
Claude Code supports three command surfaces. CLI flags (like --model, --permission-mode, and -p) configure sessions at launch. Slash commands (like /compact, /diff, and /code-review) control behavior during a session. Keyboard shortcuts (like Ctrl+C, Ctrl+T, and Shift+Tab) trigger actions without typing. The official docs list over 70 slash commands and 50+ CLI flags covering model selection, context management, code review, agent coordination, and session lifecycle.
How do I use slash commands in Claude Code?
Type / at the start of your message in an interactive session. A filterable list appears showing every available command. Type more letters to narrow results. The command must be the first thing in your message. Text after the command name becomes its argument. For example, /model sonnet switches to the Sonnet model, and /compact "focus on the auth module" summarizes conversation history with specific focus instructions.
What are the Claude Code keyboard shortcuts?
The most important shortcuts are Ctrl+C (interrupt), Ctrl+D (exit), Ctrl+T (toggle task list), Ctrl+R (search history), Shift+Tab (cycle permission modes), and Meta+P (model picker). In the diff viewer, use arrow keys and J/K for navigation. All shortcuts are customizable through /keybindings, which opens ~/.claude/keybindings.json. Three shortcuts are reserved and cannot be rebound (Ctrl+C, Ctrl+D, Ctrl+M).
How do I run Claude Code from the command line?
Run claude for an interactive session, claude -p "query" for a one-shot non-interactive query, or claude -c to continue your last conversation. For scripting, pipe content with cat file | claude -p "prompt" and add --output-format json for structured output. Use --max-turns and --max-budget-usd to cap resource usage. Start background agents with claude --bg "task description" and monitor them with claude agents.
How do I customize Claude Code keybindings?
Run /keybindings in a session to create or open ~/.claude/keybindings.json. Each binding block specifies a context (Chat, Global, Confirmation, DiffDialog, and others) and maps keystrokes to actions. Set an action to null to unbind it. Chords use space-separated keys like ctrl+k ctrl+s. Changes apply automatically without restarting. Run /doctor to check for binding conflicts or syntax errors.
What is the difference between /compact and /clear?
/compact summarizes the current conversation to free context window space while keeping the same session going. You can pass focus instructions like /compact "focus on the database changes" to guide what the summary preserves. /clear ends the current conversation entirely and starts fresh. The previous conversation remains accessible through /resume. Use /compact when you are mid-task and running low on context. Use /clear when you are switching to a completely different task.
How do I review code with Claude Code commands?
Use /diff to see what changed in an interactive viewer. Then run /code-review for a local review that identifies correctness bugs and cleanup opportunities. Add --fix to apply findings automatically, or --comment to post them as inline PR comments. /code-review ultra runs a deep multi-agent review in the cloud. /review 123 reviews a specific GitHub PR by number. /security-review gives a dedicated vulnerability-focused pass. /simplify applies cleanup fixes without hunting for bugs.
Related Resources
Give your Claude Code agents persistent file storage
Fast.io workspaces let Claude Code agents read, write, and hand off files through MCP, with the endpoint ready at /mcp. Starts with a 14-day free trial.