This Claude Code cheat sheet puts the commands, keyboard shortcuts and CLI flags of Anthropic's coding agent on one searchable page: slash commands like /init, /compact, /context and /rewind, shortcuts like Shift+Tab to cycle permission modes and Esc twice to rewind, and flags like claude -p, --continue, --model and --permission-mode for scripts. It also lists where CLAUDE.md and settings files go, every hook event and the MCP commands, which are the things people most often have to look up mid-session.
Everything was checked on 2026-10-18 against the official documentation at code.claude.com, when the newest release was v2.1.302 (October 16, 2026). Claude Code ships several releases a week, so commands get added, renamed and occasionally removed; removed ones are marked rather than silently dropped. Type / in a session or run claude --help for what your installed version supports, and see the linked docs for the full option lists.
How to use
- Search the reference tables for a command, flag, file or hook event ("resume", "--model", "PreToolUse").
- Use the table links to jump to slash commands, CLI flags, memory files, settings, hooks or MCP.
- Click Copy to copy a command or flag; the # next to each heading or row links straight to it.
- Scroll down to the keyboard shortcuts, with macOS and Windows/Linux columns and their own search.
- Press "Print / Save as PDF" for a two-column printout.
Frequently asked questions
What are the most useful Claude Code slash commands?
/init creates a CLAUDE.md for the project, /clear starts fresh, /compact summarizes a long conversation to free context, and /context shows what is using the context window. /model switches models, /resume reopens an earlier conversation, /rewind rolls code and conversation back to a checkpoint, and /permissions manages which tools run without asking. /mcp, /memory and /usage cover servers, CLAUDE.md files and cost.
What is the difference between /clear and /compact?
/clear starts a new conversation with empty context; the old one is kept and can be reopened with /resume. /compact keeps the same conversation but replaces the history with a summary, so Claude remembers what you were doing while using less context. You can pass instructions to /compact, such as what the summary should focus on.
How do I add a new line in the Claude Code prompt?
Type a backslash and press Enter, which works in every terminal. Ctrl+J also works everywhere. Shift+Enter works natively in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal and Windows Terminal; run /terminal-setup to add it to VS Code, Cursor, Alacritty or Zed. On macOS, Option+Enter works once Option is set to act as Meta.
How do I continue or resume a previous Claude Code session?
Run claude -c (or --continue) to reopen the most recent conversation in the current directory, or claude -r with a session ID or name to resume a specific one. Inside a session, /resume opens a picker. Name sessions with claude -n or /rename so they are easy to find later.
Where do CLAUDE.md and settings.json go?
Personal instructions for every project go in ~/.claude/CLAUDE.md; project instructions shared with the team go in ./CLAUDE.md or ./.claude/CLAUDE.md, and private project notes in ./CLAUDE.local.md. Settings follow the same pattern: ~/.claude/settings.json for you, .claude/settings.json for the team, .claude/settings.local.json for your private overrides. Managed settings from an organization take precedence over all of them.
How do I stop Claude Code asking for permission every time?
Press Shift+Tab to cycle permission modes: acceptEdits lets Claude edit files without asking, and auto runs everything with background safety checks. Use /permissions or --allowedTools to pre-approve specific tools, such as Bash(git diff *). --dangerously-skip-permissions (bypassPermissions mode) turns all checks off and is meant only for isolated containers or VMs.
Print mode: Claude Code in scripts and CI
claude -p "prompt" runs one task and prints the answer without the interactive interface, which is what you want in shell scripts, git hooks and CI. You can pipe input in (cat error.log | claude -p "explain this") and combine it with flags that only make sense there:
• --output-format json or stream-json for machine-readable output; --json-schema for validated structured output
• --max-turns and --max-budget-usd to cap how long it runs and how much it spends
• --allowedTools / --disallowedTools or --permission-mode dontAsk so it never waits for a prompt nobody will answer
• --bare to skip loading hooks, plugins, MCP servers and CLAUDE.md for faster, predictable runs
• -c or --resume to continue an earlier print-mode conversation
Hooks in one minute
Hooks are commands Claude Code runs at fixed points: PreToolUse before a tool call, PostToolUse after one, Stop when Claude finishes, Notification when it needs you, SessionStart when a session begins, and about 30 events in all (listed above). They live under the "hooks" key of a settings file, grouped by event, with an optional matcher such as "Bash" or "Edit|Write".
A PostToolUse hook on Edit that runs your formatter keeps every file Claude touches formatted. A PreToolUse hook on Bash can inspect the command and exit with code 2 to block it; whatever the script prints to stderr is shown to Claude as the reason. Run /hooks to see which hooks are active.
How this sheet stays current
Claude Code's command set changes quickly: /vim, /pr-comments and /ultraplan have all been removed in recent versions, and new commands arrive most weeks. Every entry here comes from the official docs on the date shown at the top, summarized in plain words, and the page links each source table.
If a command here doesn't exist in your session, check your version with claude -v and update with claude update. If one exists that isn't listed, it is probably newer than the last check or is a skill, plugin or MCP command specific to your setup; /help and the / menu always show what your installation supports.
