docsfoundations4 min read

Complete Command Cheatsheet

Every slash command, keyboard shortcut, CLI flag, and hook event in Claude Code. The three commands that alone save 30% on costs are buried in here.

Most people use about 10% of Claude Code.

They type prompts and hit Enter. That's it. They don't know /compact exists. They don't know you can switch models mid-conversation. They definitely don't know that pressing Escape cancels a running operation without losing any context.

This is everything, in one place.

Slash Commands

Type these directly into the Claude Code prompt.

Session Management

CommandWhat it does
/helpShow all available commands and options
/clearClear conversation history and start fresh
/compactCompress context to free up token space (keeps understanding)
/costShow session token usage, cost, and per-model breakdown
/statusShow current session info (model, permissions, context usage)
/usageShow API usage stats for your account
/quit or /exitEnd the session cleanly
/exportExport conversation as JSON or Markdown
/rewindUndo the last turn in conversation

Configuration

CommandWhat it does
/modelSwitch the active model (opus, sonnet, haiku)
/model opusSwitch to Opus 5.5 (most capable, default)
/model sonnetSwitch to Sonnet 5.5 (fast and capable)
/model haikuSwitch to Haiku 5.5 (fastest, cheapest; v2.1.293 or later)
/initGenerate a CLAUDE.md file for your project
/configView and edit Claude Code configuration
/permissionsView and manage tool permissions
/doctorRun diagnostics (checks install, auth, MCP health)
/memoryView or manage Claude's memory about you

Workflow

CommandWhat it does
/reviewReview recent changes for issues
/planEnter plan mode (Claude proposes before doing)
/agentsList and manage active sub-agents
/mcpView connected MCP servers and tools
/contextShow what's loaded in the context window

Custom Skills

Any .md file in ~/.claude/skills/ or your project's .claude/skills/ becomes a slash command:

text
/my-skill        # Runs the skill defined in my-skill.md
/commit          # If you have a commit skill
/review-pr 123   # Skills can take arguments

Keyboard Shortcuts

The Essentials

ShortcutWhat it does
EnterSend your message
EscapeCancel current operation (safe: keeps context)
Escape, EscapeQuick cancel (double-tap for immediate stop)
Ctrl+CHard cancel / exit if pressed twice
Ctrl+LClear the screen (keeps conversation)
Up arrowCycle through previous prompts

Power User Shortcuts

ShortcutWhat it does
Shift+TabToggle plan mode on/off
TabAccept autocomplete suggestion
Ctrl+RSearch through prompt history
!Prefix to run a shell command directly (e.g., ! git status)
\Multi-line input mode (type across multiple lines before sending)
@Reference a file or context (e.g., @src/api.ts explain this)
% (vim mode)Jump to the matching bracket, alone or with d, c or y (v2.1.301 or later)

Three files in, you see it going wrong. Press Escape to stop (edits so far stay), Shift+Tab into plan mode, then the up arrow to send the same prompt again.

CLI Flags

These go on the claude command when you start a session.

Starting Sessions

bash
claude                       # Start interactive session in current directory
claude "prompt here"         # Start with an initial prompt
claude -p "prompt"           # Pipe mode (non-interactive, for scripts/CI)
claude -c "continue"         # Continue the most recent session
claude --resume              # Resume last conversation (pick up where you left off)

Model & Behavior

bash
claude --model opus          # Start with Opus 5.5 (default)
claude --model sonnet        # Start with Sonnet 5.5
claude --model haiku         # Start with Haiku 5.5
claude --verbose             # Show tool calls and internal reasoning
claude --bare                # Minimal output (for scripted calls)

Context & Files

bash
claude --append-system-prompt "..."  # Add to the system prompt
claude @file.ts              # Load a file into context at start

The --resume flag is criminally underrated. Closed your terminal by accident? claude --resume picks up exactly where you left off. No lost context.

Hook Events

Hooks are shell commands that fire automatically during Claude Code's lifecycle. You configure them in settings.json:

EventWhen it fires
PreToolUseBefore any tool call (Read, Write, Bash, etc.)
PostToolUseAfter a tool call completes
SessionStartWhen a new session begins
SessionEndWhen a session ends

Example: auto-format code after every Write:

json
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Write",
      "command": "prettier --write $FILE_PATH"
    }]
  }
}

Learn more in the Hooks guide.

The Commands People Sleep On

/compact is a lifesaver. Long session getting sluggish? Context window filling up? /compact compresses your conversation while preserving the important context. Use it before Claude starts forgetting things, not after. I run it every 30-40 minutes during long sessions.

/model for cost control. Start complex tasks with Opus, then switch to Haiku for simple follow-ups. "Fix the typo I just introduced" doesn't need the most expensive model. You can switch mid-conversation without losing context.

/cost for awareness. Check it every 30 minutes during long sessions. Shows per-model and cache-hit breakdown so you know exactly where your tokens are going. Most people are surprised by the breakdown.

/rewind is your undo button. Sent Claude Code in the wrong direction? /rewind takes you back one turn. Way more useful than /clear, which nukes everything. It only restores Claude's own file edits, though. Anything changed through a shell command, sed -i included, stays changed.

Escape is not Ctrl+C. Escape gracefully stops the current operation. Claude Code keeps your conversation and any partial work. Ctrl+C is the hard kill. Use it only when things are truly stuck. The difference matters.

! for quick shell commands. Need to check git status without leaving the Claude Code session? Just type ! git status. The output lands right in your conversation, and Claude Code can reference it.

"You should know" catches what you missed. It's a built-in mod, off by default. Turn it on with /plugin enable cc-plugin-you-should-know@builtin, and a side agent rereads the conversation now and then and posts one short note above the prompt, like a tradeoff Claude made without saying so. It runs on your session's model with no tools, and each check counts toward your usage. /plugin lists it only when you connect to the Claude API directly and your organization has it; set CLAUDE_CODE_YOU_SHOULD_KNOW_DEBUG=1 to watch the checks run.

Headless & CI Mode

Run Claude Code in automated pipelines:

bash
# Pipe mode for CI/CD
claude -p "run tests and report failures" | tee test-output.txt

# Headless with specific model
claude -p --model haiku "lint all TypeScript files"

# Chain with other tools
git diff | claude -p "review this diff for bugs"

Quick Reference Card

text
── Session ─────────────────────────────────────
/help  /clear  /compact  /cost  /status  /usage
/quit  /export  /rewind

── Config ──────────────────────────────────────
/init  /model  /config  /permissions  /doctor
/memory  /context

── Workflow ────────────────────────────────────
/review  /plan  /agents  /mcp

── Keyboard ────────────────────────────────────
Escape (cancel)  Shift+Tab (plan)  Tab (complete)
Up (history)  Ctrl+R (search)  ! (shell)
\ (multi-line)  @ (file ref)

── CLI ─────────────────────────────────────────
-p (pipe)  -c (continue)  --resume  --verbose
--model  --effort  --bare  -r (resume)

Print this. Tape it to your monitor. You'll reference it more than you think.

New guides, when they ship

One email, roughly weekly. CLAUDE.md templates, workflows I actually use, and the cut-for-length stuff that does not make the public guides. One-click unsubscribe.

Or read Product Field Notes, the Substack