Claude Code Cheat Sheet

This Claude Code cheat sheet condenses the commands, shortcuts, and config files you reach for every day: CLI flags and headless mode, slash commands, keyboard shortcuts, CLAUDE.md, permissions, settings, hooks, skills, subagents, and MCP servers. Every command matches the official Claude Code documentation, so you can keep this Claude cheat sheet open next to your terminal while you work.

You can also download the information as a printable cheat sheet:

Free Bonus: Claude Code Cheat Sheet

Get a Claude Code Cheat Sheet (PDF) with slash commands, shortcuts, CLI flags, CLAUDE.md, permissions, hooks, skills, subagents, and MCP on two printable pages:

Claude Code Cheat Sheet

Practice with hands-on coding exercises, quizzes, and a personal AI mentor. Not sure what to learn next? Get your free personal learning plan.

New to Claude Code?

Install and Start

  • Start claude in your project root and avoid your home folder.
  • Sign in with a paid Claude plan or an Anthropic Console account.
  • Type / for commands and ? for shortcuts.
Language: Shell Filename: Install on macOS and Linux
$ curl -fsSL https://claude.ai/install.sh \
    | bash
Language: Windows PowerShell Filename: Install on Windows
PS> irm https://claude.ai/install.ps1 | iex
Language: Shell Filename: Check and Update
$ claude --version
$ claude update
Language: Shell Filename: Start a Session
$ cd my-project/
$ claude                      # Interactive
$ claude "explain this repo"  # With prompt
$ claude -n auth-fix          # Named
Language: Shell Filename: Resume a Session
$ claude -c          # Latest one in this dir
$ claude -r          # Pick from a list
$ claude -r auth-fix "finish the PR"
Language: Shell Filename: Launch Flags
$ claude --model sonnet
$ claude --effort high
$ claude --permission-mode plan
$ claude --add-dir ../shared-lib
$ claude -w feature-x   # In a git worktree

Walk through a full project in How to Use Claude Code to Write and Debug Python.

Want a guided first session?

Run Claude Code Headless

  • -p prints one answer and exits, so it fits scripts and CI.
  • --allowedTools pre-approves the tools a script needs.
  • --bare skips CLAUDE.md, hooks, skills, and MCP for faster starts.
Language: Shell Filename: One-Shot Prompts
$ claude -p "explain this function"
$ cat error.log | claude -p "root cause?"
$ claude -c -p "check for type errors"
Language: Shell Filename: JSON Output and Limits
$ claude -p "summarize this project" \
    --output-format json | jq -r '.result'
$ claude -p "fix the failing test" \
    --allowedTools "Read,Edit,Bash" \
    --max-turns 5

Scripting Claude Code?

Session Slash Commands

  • Type / to list commands, then keep typing to filter.
  • Put the command at the start of your message.
  • Run /clear when you switch tasks and /compact to keep going.

Context

Command What it does
/context Show context usage
/compact [focus] Summarize the chat to free space
/clear Start a fresh chat. Also /new
/btw [question] Ask a side question

Sessions

Command What it does
/resume [name] Reopen a session. Also /continue
/rename [name] Label this session
/branch [name] Try another direction
/rewind Roll back code and chat. Also /undo
/export [file] Save the chat as plain text
/exit Quit. Also /quit

Background Work

Command What it does
/tasks List running shells and agents
/subtask <task> Hand a task to a forked subagent
/fork [prompt] Run a copy in the background
/background Detach the session. Also /bg
/goal [condition] Keep working until the goal is met
/loop 5m <prompt> Repeat a prompt on an interval

Not sure which one to use?

Setup and Review Slash Commands

  • Press s in the /model picker to switch for this session only.
  • Raise /effort for hard problems, at the cost of more tokens.

Model and Usage

Command What it does
/model [name] Switch model and save it as default
/effort high Set effort from low to max, or auto
/fast Toggle fast mode, or pass on or off
/usage Show cost and limits. Also /cost

Configure

Command What it does
/config Open settings. Also /settings
/config theme=dark Set one key directly
/permissions Edit allow, ask, and deny rules
/memory Edit memory files
/hooks View configured hooks
/skills List and toggle skills
/mcp Manage MCP servers and OAuth
/doctor Diagnose your setup
/status Show version and account

Plan and Review

Command What it does
/init Draft a CLAUDE.md
/plan [task] Enter plan mode
/diff Review the working tree
/code-review --fix Find and fix bugs
/code-review ultra Run a deep cloud review
/security-review Find security issues
/simplify Clean up the code

Plan first, then edit?

More Slash Commands

  • Your skills and plugin skills share the same / menu.
  • MCP server prompts show up as /server:prompt.

Workspace

Command What it does
/add-dir <path> Grant access to another directory
/cd <path> Move the session and keep the chat
/ide Connect your IDE
/copy [N] Copy a response
/insights Report on your sessions

Look and Feel

Command What it does
/theme Pick a color theme
/color [color] Set the prompt bar color
/statusline Configure the status line
/keybindings Edit the shortcuts file
/help List all commands
/release-notes See what’s new

Extend

Command What it does
/plugin Browse and install plugins
/reload-skills Pick up new skills
/workflows Watch dynamic workflows
/schedule Set up recurring cloud routines

Want to extend Claude Code?

Keyboard Shortcuts

  • On macOS, press Option for Alt. Most of these need Option set as Meta, but Option+T works without it.

Control the Session

Keys Action
Shift+Tab Cycle permission modes
Esc Interrupt Claude
Esc Esc Clear input or rewind
Ctrl+C Interrupt, clear, or exit when pressed twice
Ctrl+O Toggle transcript viewer
Ctrl+B Background a running task
Ctrl+T Toggle the task checklist
Alt+P Switch model
Alt+T Toggle extended thinking
Alt+O Toggle fast mode
Ctrl+L Redraw the screen

Write Your Prompt

Keys Action
\ Enter, Ctrl+J New line
Shift+Enter New line in most terminals
Ctrl+R Search prompt history
Ctrl+G Edit prompt in your editor
Ctrl+S Stash or restore the prompt
Ctrl+V Paste an image
Cmd+V Paste an image in iTerm2
Alt+V Paste an image on Windows or WSL
! at start Shell mode
@ Mention a file or subagent
? Show all shortcuts

Curious about @ and !?

CLAUDE.md and Memory

  • CLAUDE.md holds instructions you write. Auto memory holds notes Claude writes.
  • All files load together from broad to specific, so remove contradictions.
  • Since v2.1.277, AGENTS.md loads when a repo has no CLAUDE.md.

Where CLAUDE.md Files Live

File Scope
~/.claude/CLAUDE.md You, in every project
./CLAUDE.md Your team. Commit it
./CLAUDE.local.md You, in this project
sub/CLAUDE.md Loads on demand
Language: Markdown Text Filename: Import Files
# Project Notes
See @README.md for an overview.
- Testing: @docs/testing.md
- Mine: @~/.claude/my-notes.md
Language: Markdown Text Filename: Scope a Rule in .claude/rules/api.md
---
paths:
  - "src/api/**/*.py"
---
- Validate every request body

Set up global, project, and local files in How to Write a CLAUDE.md File for Claude Code.

Starting a CLAUDE.md?

Permissions and Modes

  • Shift+Tab cycles default, acceptEdits, and plan, plus auto when it’s available.
  • Since v2.1.283, most terminal and VS Code sessions start in auto.
  • The UI labels default mode as Manual.
  • Rules check deny, then ask, then allow. The first match wins.
  • Deny rules hold in every mode, even bypassPermissions.
Mode Runs without asking
default Reads only
acceptEdits Reads, edits, file commands
plan Reads to draft a plan
auto Everything, with safety checks
dontAsk Pre-approved tools and file reads
bypassPermissions Everything, in isolated VMs
Language: JSON Filename: Permission Rules
{
  "permissions": {
    "allow": ["Bash(uv run pytest *)"],
    "ask": ["Bash(git push *)"],
    "deny": ["Read(./.env)"]
  }
}

Still fuzzy on permission rules?

Settings Files

  • Managed settings win, followed by --settings, local, project, and user.
  • List keys like permissions.allow merge across files.
  • Settings files are strict JSON with no comments or trailing commas.
  • /status shows which files loaded.

Where Settings Live

File Scope
~/.claude/settings.json User
.claude/settings.json Project, shared
.claude/settings.local.json Project, just you

Two files, one key?

Hooks

  • Hooks run your commands at fixed points in Claude’s loop.
  • Exit code 2 from PreToolUse blocks the tool call.
  • /hooks shows what’s registered.

Key Events

Event When it runs
SessionStart Session begins or resumes
UserPromptSubmit Before Claude sees your prompt
PreToolUse Before a tool runs. Can block it
PostToolUse After a tool succeeds
Notification Claude needs your input
Stop Claude finished replying
Language: JSON Filename: Format After Every Edit
{
  "hooks": {
    "PostToolUse": [{
      "matcher": "Edit|Write",
      "hooks": [{
        "type": "command",
        "command": "ruff format ."
      }]
    }]
  }
}

Go deeper with these hooks resources:

Wondering how the matcher works?

Skills

  • A folder with a SKILL.md becomes a /name command.
  • Claude also loads a skill when its description fits the task.
  • disable-model-invocation: true makes a skill manual-only.
  • Old .claude/commands/*.md files still work.

Where Skills Live

File Scope
~/.claude/skills/<name>/SKILL.md You
.claude/skills/<name>/SKILL.md Project
Language: Markdown Text Filename: A Minimal SKILL.md
---
name: docstring-doctor
description: >-
  Writes Google-style Python docstrings.
  Use when asked to document code.
---
Open with a one-line summary...

Claude follows the instructions below the frontmatter each time the skill runs.

Think you’ve got skills down?

Subagents

  • A subagent works in its own context and reports back.
  • Built-in subagents include Explore, which searches without editing, and Plan.
  • Claude can write one for you, or you can add a file to .claude/agents/.
Language: Markdown Text Filename: Define .claude/agents/code-reviewer.md
---
name: code-reviewer
description: Reviews code for quality
tools: Read, Glob, Grep
model: sonnet
---
You are a code reviewer...
Language: Shell Filename: Run the Session as an Agent
$ claude --agent code-reviewer
Language: Text Filename: Call a Subagent
@agent-code-reviewer check my changes

Skill or subagent?

MCP Servers

  • MCP connects Claude Code to outside tools and data.
  • Scopes are local, project, and user, with local as the default.
  • Project scope saves servers to a shared .mcp.json file.
  • For stdio servers, -- comes before the server command.
  • Connect databases with a read-only user.
Language: Shell Filename: Add a Server
$ claude mcp add --transport http \
    notion https://mcp.notion.com/mcp
$ claude mcp add --transport stdio \
    --scope project db \
    -- npx -y @bytebase/dbhub \
    --dsn "postgresql://readonly:pw@host/db"
Language: Shell Filename: Manage Servers
$ claude mcp list
$ claude mcp get notion
$ claude mcp remove notion

Want to go deeper on MCP?

Everyday Workflow

  • Switch to plan mode with Shift+Tab before big changes.
  • Review every diff and commit between tasks.
  • Run /branch before a risky experiment.
  • /rewind restores Claude’s file edits but not changes from shell commands.

A Typical Loop

Command What it does
/init Once per project
/plan add a CLI Agree on a plan
/diff Review the edits
/code-review --fix Catch bugs early
/clear Start the next task

Ready to test yourself?

Ready to go beyond the cheat sheet?

You can download this information as a printable cheat sheet:

Free Bonus: Claude Code Cheat Sheet

Get a Claude Code Cheat Sheet (PDF) with slash commands, shortcuts, CLI flags, CLAUDE.md, permissions, hooks, skills, subagents, and MCP on two printable pages:

Claude Code Cheat Sheet