Claude Code Cheat Sheet 2026 — Commands, Shortcuts, Settings
[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
| Command | What it does |
|---|---|
/help | List all slash commands in current session |
/clear | Reset conversation, keep env |
/compact | Manually compress context to free tokens |
/resume | Resume the last suspended session |
/exit or /quit | Close Claude Code |
/logout / /login | Switch Anthropic account |
Configuration & Diagnostics
| Command | What it does |
|---|---|
/config | Open the settings UI |
/model | Switch model (Opus / Sonnet / Haiku) |
/doctor | Run environment diagnostics |
/cost | Show current session cost |
/status | Show model, version, working dir, active agents |
/permissions | Inspect effective permission set |
/init | Scaffold CLAUDE.md in the current repo |
Advanced
| Command | What it does |
|---|---|
/hooks | List active hooks by event |
/agents | List custom sub-agents |
/mcp | Manage MCP servers (list, enable, disable) |
/memory | Open memory index |
/pr_comments | Fetch review comments on the current PR |
/ide | Connect / 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
| Key | Action |
|---|---|
Enter | Submit prompt |
Shift + Enter / Option + Enter | Insert newline (multi-line prompt) |
Esc | Cancel the current tool call / interrupt stream |
Double Esc | Exit the entire session |
Ctrl + C | Copy selection (or cancel, second press) |
Ctrl + L | Clear the terminal screen (keeps context) |
Ctrl + R | Reverse-search prompt history |
↑ / ↓ | Navigate prompt history |
Tab | Autocomplete file path / slash command |
Ctrl + J | Insert newline (alt binding on some terminals) |
Prefix Shortcuts in the Prompt
| Prefix | Effect |
|---|---|
@filename | Attach a file to the prompt by path |
/command | Invoke a slash command |
#memory note | Append a note to the memory index without running a tool |
[04]CLI Flags & Environment
Common Invocation Flags
| Flag | Purpose |
|---|---|
--model <id> | Start in a specific model (e.g. claude-sonnet-4-6) |
--verbose | Print resolution chain for permissions / hooks / memory |
--print "<prompt>" | One-shot mode: execute the prompt and exit |
--resume | Reopen the last session |
--dangerously-skip-permissions | Disable all permission prompts — use only in sandboxes |
--verbose --debug | Full diagnostic output for bug reports |
Environment Variables
| Variable | Effect |
|---|---|
ANTHROPIC_API_KEY | Override 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=1 | Disable 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
| Goal | Prompt 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/clearand paste the last known good state. - Context too full:
/compactto squash, or/clearto reset. - Permission prompts every 10 seconds: edit
.claude/settings.jsonto allowlist the pattern.
[07]Next Steps
This sheet is the index. Go deeper here:
- .claude/ folder complete guide — settings.json, commands, agents, hooks in depth.
- Hooks cookbook — 5 copy-paste hook recipes.
- Top 10 MCP servers — which ones to install first.
- Hidden features — KAIROS, ULTRAPLAN, Undercover Mode.
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.