AI & Agents

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.

Fast.io Editorial Team 14 min read
Developer using Claude Code commands in a terminal interface

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:

  • claude starts a fresh interactive session
  • claude "query" starts a session with an initial prompt
  • claude -c continues the most recent conversation in the current directory
  • claude -r "name" resumes a session by name or ID
  • claude -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 sonnet sets the model (accepts opus, sonnet, haiku, fable, or a full model ID)
  • --effort high sets the reasoning effort level (low, medium, high, xhigh, max)
  • --advisor opus enables a second model that advises at key decision points
  • --fallback-model sonnet,haiku defines a fallback chain when the primary model is overloaded

Permission and Safety Modes

  • --permission-mode plan starts in plan mode (read-only analysis, explicit approval before changes)
  • --permission-mode auto starts in auto mode with classifier-based approval
  • --dangerously-skip-permissions skips 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.txt appends 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.txt replaces 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-auth starts Claude in an isolated git worktree
  • -w feature-auth --tmux creates a tmux session for the worktree
Claude Code CLI command output in a developer terminal

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:

  • /init generates a starter CLAUDE.md file with project conventions
  • /memory edits CLAUDE.md files and manages auto-memory entries
  • /mcp manages MCP server connections and OAuth authentication
  • /agents configures subagent definitions
  • /permissions manages tool allow, ask, and deny rules

Model and Context Management

These commands adjust how Claude thinks during a session:

  • /model opens a picker to switch models mid-session (press s to apply for this session only)
  • /effort sets reasoning effort with an interactive slider (low through max, plus ultracode)
  • /fast toggles fast mode on or off
  • /compact summarizes conversation history to free context window space
  • /context visualizes 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:

  • /diff opens an interactive diff viewer showing uncommitted changes and per-turn diffs
  • /code-review reviews the current diff for correctness bugs and cleanup opportunities
  • /code-review --fix applies review findings to your working tree
  • /code-review ultra runs a deep multi-agent review in the cloud
  • /review 123 reviews a GitHub pull request by number
  • /security-review analyzes pending changes for security vulnerabilities
  • /simplify reviews changed code for cleanup opportunities and applies fixes

Parallel Work and Background Agents

Coordinate multiple agents from a single session:

  • /background detaches 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
  • /branch creates a conversation branch you can return to with /resume
  • /tasks lists everything running in the background
  • /workflows shows progress for running workflow orchestrations

Session Management

Navigate between sessions and recover from mistakes:

  • /clear starts a fresh conversation (previous stays available via /resume)
  • /resume reopens a previous conversation by name or from a picker
  • /rewind rolls code and conversation back to a checkpoint
  • /teleport pulls a web session into the terminal
  • /remote-control makes the session controllable from claude.ai
  • /export saves the conversation as plain text
  • /copy copies the last response to clipboard (pass a number for earlier responses)
Fastio features

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).

Keyboard shortcut reference for Claude Code terminal navigation

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

  • /model switches the active model
  • /effort adjusts reasoning depth
  • /compact frees context window space
  • /diff shows what changed
  • /code-review reviews the diff for bugs
  • /plan enters read-only analysis mode
  • /background detaches the session to run in the background
  • /resume returns to a previous conversation
  • /rewind rolls back code and conversation
  • /clear starts a fresh conversation

Most-Used CLI Flags

  • -p runs in non-interactive print mode
  • -c continues the most recent conversation
  • -r "name" resumes a session by name
  • --model sets the model
  • --effort sets reasoning effort
  • --permission-mode sets the permission mode
  • --bg starts as a background agent
  • -w starts in a git worktree
  • --output-format json returns structured output
  • --max-turns caps 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 agents monitors background sessions
  • claude attach <id> connects to a background session
  • claude stop <id> stops a background session
  • claude logs <id> prints recent output from a background session
  • claude rm <id> removes a background session from the list
  • claude respawn <id> restarts a background session with its conversation intact

Diagnostic Commands

When something breaks, these commands help:

  • /doctor diagnoses installation and settings issues (press f to auto-fix)
  • /debug enables debug logging and analyzes the session log
  • /context all shows full context usage breakdown
  • /usage shows session cost, plan limits, and activity stats
  • claude daemon status checks 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

Fastio features

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.