0%
#cheatsheet#claude-code#reference#guide#commands

Claude Code Cheat Sheet 2026 — Commands, Shortcuts, Settings

Published 2026-04-238 min read

[01]How to Use This Cheat Sheet

Bookmark this page. The tables below are ordered by frequency-of-use, not alphabetically, so scanning top-down covers 80% of daily work. Every entry maps to Claude Code 2026 (late Q1) behavior — if your version differs, claude --version first.

Print-friendly: the page is single-column and avoids color-dependent cues. Ctrl+P (Cmd+P on macOS) produces a clean two-page PDF.

[02]Slash Commands Reference

Session Control

CommandWhat it does
/helpList all slash commands in current session
/clearReset conversation, keep env
/compactManually compress context to free tokens
/resumeResume the last suspended session
/exit or /quitClose Claude Code
/logout / /loginSwitch Anthropic account

Configuration & Diagnostics

CommandWhat it does
/configOpen the settings UI
/modelSwitch model (Opus / Sonnet / Haiku)
/doctorRun environment diagnostics
/costShow current session cost
/statusShow model, version, working dir, active agents
/permissionsInspect effective permission set
/initScaffold CLAUDE.md in the current repo

Advanced

CommandWhat it does
/hooksList active hooks by event
/agentsList custom sub-agents
/mcpManage MCP servers (list, enable, disable)
/memoryOpen memory index
/pr_commentsFetch review comments on the current PR
/ideConnect / disconnect IDE integration

Custom commands live in .claude/commands/<name>.md and appear in the same autocomplete. See the .claude/ folder guide for the template.

[03]Keyboard Shortcuts

KeyAction
EnterSubmit prompt
Shift + Enter / Option + EnterInsert newline (multi-line prompt)
EscCancel the current tool call / interrupt stream
Double EscExit the entire session
Ctrl + CCopy selection (or cancel, second press)
Ctrl + LClear the terminal screen (keeps context)
Ctrl + RReverse-search prompt history
/ Navigate prompt history
TabAutocomplete file path / slash command
Ctrl + JInsert newline (alt binding on some terminals)

Prefix Shortcuts in the Prompt

PrefixEffect
@filenameAttach a file to the prompt by path
/commandInvoke a slash command
#memory noteAppend a note to the memory index without running a tool

[04]CLI Flags & Environment

Common Invocation Flags

FlagPurpose
--model <id>Start in a specific model (e.g. claude-sonnet-4-6)
--verbosePrint resolution chain for permissions / hooks / memory
--print "<prompt>"One-shot mode: execute the prompt and exit
--resumeReopen the last session
--dangerously-skip-permissionsDisable all permission prompts — use only in sandboxes
--verbose --debugFull diagnostic output for bug reports

Environment Variables

VariableEffect
ANTHROPIC_API_KEYOverride OAuth with a raw API key
CLAUDE_PROJECT_DIR(Set by Claude inside hooks) repo root
CLAUDE_SESSION_ID(Set by Claude inside hooks) current session ID
NO_COLOR=1Disable ANSI color output

[05]settings.json Quick Reference

The four fields you will touch 95% of the time:

permissions

"permissions": {
  "allow": ["Bash(npm run *)", "Edit", "Write", "Read", "Grep"],
  "deny":  ["Bash(rm -rf *)", "Bash(git push --force*)", "Bash(sudo *)"]
}

hooks

"hooks": {
  "PreToolUse": [
    {
      "matcher": "Edit|Write",
      "hooks": [{ "type": "command", "command": "sh .claude/hooks/check.sh" }]
    }
  ]
}

Events: PreToolUse, PostToolUse, UserPromptSubmit, Stop, SubagentStop, Notification, PreCompact, SessionStart. See the hooks cookbook for patterns.

mcpServers

"mcpServers": {
  "github": {
    "command": "npx",
    "args": ["-y", "@modelcontextprotocol/server-github"],
    "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "$GITHUB_TOKEN" }
  }
}

env (per-project)

"env": {
  "PYTHONPATH": "./src",
  "NODE_ENV": "development"
}

Resolution order: ~/.claude/settings.json.claude/settings.json.claude/settings.local.json. Later wins on key collision.

[06]Workflow Patterns

GoalPrompt Pattern
Code review a branch/review (if configured) or "Compare current branch to main. Report security, perf, test coverage issues as numbered list with file:line"
Debug a failing test"Run npm test -- <file>, identify root cause, propose minimal fix — do not apply yet"
Refactor safely"Plan the refactor first. Do not touch code. Once I approve, execute step by step."
Write a commit message"Stage the current diff and draft a conventional commit message — do not run git commit"
Explore unfamiliar code@src/module/ "Give me a one-paragraph architecture overview and the three entry points"
Parallel tasks"Delegate type-checking to one agent and linting to another, then merge results"
Session handoff/compact then "Summarize what we decided this session for next time"

Escape Hatches

  • Claude loops on the same fix: Esc, then /clear and paste the last known good state.
  • Context too full: /compact to squash, or /clear to reset.
  • Permission prompts every 10 seconds: edit .claude/settings.json to allowlist the pattern.

[07]Next Steps

This sheet is the index. Go deeper here:

Save, print, pin to your terminal. Tool home for UUID lookup and species guide.

[08]Frequently Asked Questions

Can I print this cheat sheet as PDF?

Yes — Cmd + P (macOS) or Ctrl + P (Windows/Linux) opens your browser's print dialog. Choose "Save as PDF." The layout is single-column and print-friendly, producing roughly two US Letter pages.

Are these commands the same on Windows PowerShell?

Slash commands and keyboard shortcuts are identical. CLI flags on Windows use the same syntax if you launch Claude Code from WSL or an MSYS/Git Bash terminal. Native PowerShell may require escaping quotes differently — prefer WSL for consistency.

How do I add a slash command to this list?

Create .claude/commands/<name>.md with frontmatter describing it. It appears in /help and tab-autocomplete alongside the built-ins. The .claude/ guide has the exact frontmatter schema.

Why does /cost show a different number than the Anthropic console?

The in-session counter is local and tracks current session only. The console aggregates across sessions with a short delay. For exact billing, trust the console. For per-session awareness, trust /cost.

What's the difference between /clear and /compact?

/clear wipes the conversation entirely — Claude starts from scratch with your CLAUDE.md but no context. /compact preserves conclusions but discards verbose intermediate exchanges. Use /compact when you want continuity, /clear when you want a clean slate.

// COMMENTS

github_discussions.sh

Sign in with GitHub to leave a comment.

Ready to find your buddy?

CHECK YOUR BUDDY

Built by the community. Not affiliated with Anthropic.

All computation is local. No data is collected or transmitted.

> EOF