Back to Blog

Claude Code Cheat Sheet: Every Command, Shortcut, and Slash Command (2026)

The complete Claude Code cheat sheet for 2026. Every slash command, keyboard shortcut, CLI flag, hook event, and MCP setup step in one page — copy-paste ready, updated for Opus 4.7 and the 1M token context window.

April 22, 2026
8 min read
claude-codecheat-sheetcommandskeyboard-shortcutsslash-commandsclitutorialbeginner-guideclaude-opus-4-7seo

Claude Code Cheat Sheet: Every Command, Shortcut, and Slash Command (2026)

This is the complete Claude Code reference. Every slash command, every keyboard shortcut, every CLI flag, every hook event, every settings key — on one page, copy-paste ready, current for Opus 4.7 and the 1M token context window.

Bookmark it. Search it with Ctrl/Cmd+F. Use it as the single page you open when you forget how to do the thing.


Quick Start: Install Claude Code in 30 Seconds

# macOS / Linux / WSL
curl -fsSL https://claude.ai/install.sh | sh

# Or via npm (any OS)
npm install -g @anthropic-ai/claude-code

# Verify
claude --version

# Start a session in your repo
cd your-project
claude

First run will prompt you to log in with your Claude account. No API key required if you're on Pro, Max, Team, or Enterprise.


The CLI: Every Flag Worth Knowing

claude                    # Start interactive session in current dir
claude "fix the login bug" # One-shot: run a task and exit
claude -c                 # Continue the last session
claude -r <session-id>    # Resume a specific session
claude --model opus       # Pick a model (opus | sonnet | haiku)
claude --print "<task>"   # Non-interactive, prints result to stdout
claude --verbose          # Show tool calls as they happen
claude --no-confirm       # Skip permission prompts (dangerous, use in CI)
claude --permission-mode plan  # Read-only planning mode
claude --add-dir ../sibling    # Allow access to sibling directory
claude --allowed-tools Bash,Read,Edit  # Restrict the tool set

Piping works both ways:

cat error.log | claude "what's wrong here?"
claude --print "generate a PR description" | gh pr create --body-file -

Slash Commands: The Complete List

Slash commands run inside an interactive Claude Code session. Type / to see the full list.

Session Management

CommandDescription
/helpShow available commands
/clearClear the screen and conversation
/compactCompress the conversation to save tokens
/exit or /quitEnd the session
/resumeResume a previous session
/costShow token usage and cost for this session
/logoutSign out
/loginSign back in

Configuration

CommandDescription
/configOpen the settings UI
/modelSwitch the active model (Opus, Sonnet, Haiku)
/permissionsManage which tools Claude can run without asking
/mcpList, add, or remove MCP servers
/hooksInspect and manage hook configuration
/themeSwitch color theme
/fastToggle Fast mode (Opus 4.6 with faster output)
/statusShow account, model, and environment info

Memory & Context

CommandDescription
/initGenerate a CLAUDE.md for this repo
/memoryEdit your global and project memory files
#<text>Add a fact to memory on the fly
/add-dir <path>Grant access to an additional directory

Work & Workflows

CommandDescription
/reviewRun a code review on the current branch
/security-reviewRun a security audit on pending changes
/prGenerate a pull request from current work
/commitStage and commit with an auto-generated message
/todosShow the current todo list the agent is tracking
/bugFile a bug report to Anthropic with session context

Plugins and skills add more slash commands — see /mcp and /plugins to see what your install exposes.


Keyboard Shortcuts (Terminal)

ShortcutAction
EnterSubmit the current prompt
Shift+EnterInsert a newline in the prompt
Ctrl+CInterrupt Claude (stop the current turn)
Ctrl+C (twice)Exit Claude Code
Ctrl+DExit when prompt is empty
Ctrl+LClear screen (keep history)
Ctrl+RReverse-search previous prompts
Up / DownCycle through prompt history
TabAutocomplete slash commands, file paths, @-mentions
EscCancel current input / close modal
Esc EscOpen prompt history picker
@Mention a file (autocompletes paths)
!Run a one-off bash command inline
?Toggle help overlay

In IDE extensions (VS Code / JetBrains): the default submit binding is Cmd+Enter (macOS) / Ctrl+Enter (Windows/Linux). Remap via ~/.claude/keybindings.json.


@-Mentions: Pulling Things Into Context

@README.md              # Include a file
@src/components/        # Include an entire directory
@https://example.com    # Fetch a URL (read-only)

Use @-mentions instead of pasting. Claude handles tokenization better when files are loaded through the tool, and paths show up in the audit log.


CLAUDE.md: The File That Controls Everything

# Project rules

## Stack
- Next.js 16, React 19, Tailwind 4
- Postgres via Prisma
- Deploys on Vercel

## Conventions
- Server components by default; client only when needed
- No inline styles; use Tailwind utility classes
- Tests live next to the file: `foo.ts` + `foo.test.ts`

## Commands
- `npm run dev` — local dev server
- `npm run test` — run tests
- `npm run build` — production build (must pass before merging)

## Don't
- Don't add new dependencies without asking
- Don't touch `src/legacy/` — it's frozen

Locations Claude reads in priority order:

  1. ./CLAUDE.md (repo root)
  2. ./.claude/CLAUDE.md
  3. Parent directories (walks up until git root)
  4. ~/.claude/CLAUDE.md (global defaults)

Shorter is better. A 30-line CLAUDE.md beats a 300-line one that nobody reads.


MCP Servers: Every Command

# Install an MCP server
claude mcp add <name> <command> [args...]

# Install from a JSON config
claude mcp add-json <name> '{"command": "npx", "args": ["-y", "@server/pkg"]}'

# List installed servers
claude mcp list

# Remove a server
claude mcp remove <name>

# Test a server without installing
claude mcp run <name>

Popular MCP servers to install today:

  • filesystem — read/write files outside the project root
  • github — issues, PRs, reviews, CI
  • postgres — query your database directly
  • playwright — browser automation and screenshots
  • context7 — always-current docs for your libraries
  • sequential-thinking — structured multi-step reasoning

Full list: MCP Servers Directory.


Hooks: The Event Table

Hooks are shell commands Claude Code runs automatically on lifecycle events. Configured in .claude/settings.json.

EventFires WhenTypical Use
PreToolUseBefore a tool runsBlock risky commands, require approval
PostToolUseAfter a tool runsLint, format, run tests, log output
NotificationWhen Claude surfaces a notificationPush to Slack, play a sound
StopWhen a turn endsAuto-commit, run CI check, summarize
SessionStartWhen a session beginsSeed context, warm up test runners

Example: format on save

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": "npx prettier --write $CLAUDE_FILE_PATH" }
        ]
      }
    ]
  }
}

Environment variables hooks receive: CLAUDE_FILE_PATH, CLAUDE_TOOL_NAME, CLAUDE_TOOL_INPUT, CLAUDE_SESSION_ID, CLAUDE_PROJECT_DIR.

More patterns: Claude Code Hooks Guide.


Settings: ~/.claude/settings.json

{
  "model": "claude-opus-4-7",
  "env": {
    "CLAUDE_CODE_MAX_OUTPUT_TOKENS": "32000",
    "DISABLE_TELEMETRY": "0"
  },
  "permissions": {
    "allow": ["Bash(git status:*)", "Bash(npm test:*)", "Read", "Edit"],
    "deny": ["Bash(rm -rf *:*)"]
  },
  "hooks": { /* ... */ },
  "mcpServers": { /* ... */ }
}

Project-specific overrides live in .claude/settings.json. Project settings merge with user settings; project keys win on conflict.

Common env vars:

VariablePurpose
ANTHROPIC_API_KEYUse an API key instead of subscription auth
ANTHROPIC_BASE_URLPoint at a proxy or self-hosted gateway
CLAUDE_CODE_MAX_OUTPUT_TOKENSRaise the per-turn output cap
DISABLE_AUTOUPDATERPin the CLI version
DISABLE_TELEMETRYTurn off usage telemetry

Permission Modes

ModeBehavior
defaultAsk before running risky tools
acceptEditsAuto-approve file edits; ask for shell commands
planRead-only — Claude can look but not change anything
bypassPermissionsSkip all prompts (use only in sandboxed CI)

Switch mid-session with /permissions or start with --permission-mode <mode>.


Models: Which to Pick

As of April 2026:

ModelIDWhen to Use
Opus 4.7claude-opus-4-7Hard reasoning, long context, agentic workflows
Opus 4.6claude-opus-4-6Fast mode — interactive coding, faster token output
Sonnet 4.6claude-sonnet-4-6Cheaper everyday coding, mid-complexity tasks
Haiku 4.5claude-haiku-4-5-20251001Fast, cheap — lint-loop, classification, quick rewrites

Opus 4.7 now ships with a 1M token context window. See Claude Opus 4.7: What's Actually New for the details that actually matter day-to-day.

Switch at any time with /model or --model.


The 10 Commands You'll Actually Use Every Day

  1. claude — start a session
  2. claude -c — pick up where you left off
  3. /init — scaffold a CLAUDE.md in a new repo
  4. /compact — free up context mid-session
  5. /review — code review on the current branch
  6. /commit — commit with a good message you didn't have to write
  7. @path/to/file — pull a file into context
  8. # — jot a fact into memory
  9. Ctrl+C — stop Claude, don't wait out a bad turn
  10. Esc Esc — prompt history picker

Troubleshooting Quick Reference

SymptomFix
"Permission denied" on every toolCheck /permissions or run /permissions reset
Context runs out fast/compact or upgrade to Opus 4.7 for 1M window
MCP server not showing upclaude mcp list then restart the session
Hook not firingCheck matcher regex; run /hooks to see resolved config
"Command not found: claude"Add npm global bin to PATH or reinstall via install.sh
Slow responsesTry /fast (Opus 4.6) or switch to Sonnet for routine work
Credits exhausted/cost to see usage; upgrade plan or switch model

Copy-Paste Starter Configs

.claude/settings.json for a Next.js project:

{
  "permissions": {
    "allow": [
      "Read", "Edit", "Write",
      "Bash(npm run *:*)",
      "Bash(git status:*)",
      "Bash(git diff:*)",
      "Bash(git log:*)"
    ]
  },
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          { "type": "command", "command": "npx prettier --write $CLAUDE_FILE_PATH || true" }
        ]
      }
    ]
  }
}

Minimal CLAUDE.md that actually helps:

# Project

Short description of what this codebase does.

## Stack
- <language/framework versions>

## Commands
- `<start dev>`
- `<run tests>`
- `<build>`

## Conventions
- <one or two non-obvious things>

## Don't
- <anything that looks inviting but is a trap>

Where to Go Next

Related reading


Last updated: April 22, 2026. Claude Code ships weekly — if you find something out of date, open an issue on the GitHub repo.