claudecodeguide.dev

Foundations

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.

On this page (17 sections)

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.

Commands you probably don't know about

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 4.6 (most capable)
/model sonnetSwitch to Sonnet 4.6 (fast and capable, default)
/model haikuSwitch to Haiku 4.5 (fastest, cheapest)
/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:

/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)
Keyboard shortcuts in practice

CLI Flags

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

Starting Sessions

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

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

Context & Files

claude -r "system prompt"    # Add a system prompt / reasoning instruction
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:

{
  "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.

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.

Headless & CI Mode

Run Claude Code in automated pipelines:

# 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

── 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  --bare  -r (reasoning)

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 follow on Substack