Claude Code Cheat Sheet — Commands, Shortcuts & Flags
Claude Code slash commands, CLI flags, keyboard shortcuts, CLAUDE.md and settings locations, hooks and MCP commands on one page.
Claude Code cheat sheet — freetoolsforweb.com
Verified against Claude Code docs on (latest release v2.1.302 (October 16, 2026)). Claude Code ships several releases a week, so check the changelog or run claude --help and /help for anything newer.
169 entries in 8 tables
- Built-in slash commands
- CLI commands (run in your shell)
- CLI flags
- Permission modes
- Memory: CLAUDE.md files and where they live
- Settings files (highest precedence first)
- Hook events
- MCP server commands
Built-in slash commands#
Type / in a session to see every command available to you, including skills and commands from plugins and MCP servers. Some depend on your plan or platform.
| Command | What it does | |
|---|---|---|
| /help | Show help and the available commands. | |
| /clear | Start a new conversation with empty context. Aliases /reset and /new. The old one stays in /resume. | |
| /compact [instructions] | Summarize the conversation so far to free context; optional focus instructions for the summary. | |
| /context | Show context-window usage as a colored grid, with suggestions for what is using space. | |
| /init | Create a CLAUDE.md guide for the project. | |
| /memory | Edit CLAUDE.md files, turn auto memory on or off, and view auto memory entries. | |
| /model [model] | Switch model and save it as your default; with no argument opens a picker (left/right arrows adjust effort). | |
| /effort [level|auto|status] | Set the effort level (low to xhigh, max, or auto); status prints the current one. | |
| /fast [on|off] | Toggle fast mode. | |
| /config [key=value] | Open Settings (theme, model, output style...) or set a value directly, e.g. /config theme=dark. | |
| /status | Show version, model, account and connectivity. | |
| /usage | Session cost, plan usage limits and activity stats. Aliases /cost and /stats. | |
| /permissions | Manage allow, ask and deny rules for tools, and working directories. | |
| /plan [description] | Enter plan mode, optionally starting on a task: /plan fix the auth bug. | |
| /resume [session] | Resume a conversation by ID or name, or open the session picker. | |
| /rename [name] | Rename the current session (shown on the prompt bar and in /resume). | |
| /branch [name] | Branch the conversation here to try another direction; the original stays available in /resume. | |
| /fork [prompt] | Copy the conversation into a new background session and keep working here. | |
| /background [prompt] | Detach this session to run as a background agent (alias /bg); monitor with claude agents. | |
| /rewind | Rewind the conversation and/or code to an earlier point. Aliases /checkpoint and /undo. | |
| /btw [question] | Ask a side question without adding it to the conversation. | |
| /diff | Review the changes in your working tree, including Claude’s edits. | |
| /review [level] [pr|branch|path] | Alias of /code-review: review the current diff or a PR for bugs. | |
| /security-review | Review the changes on your branch for security vulnerabilities (needs an origin remote). | |
| /simplify [target] | Skill: review changed code for reuse, simplification and efficiency, then apply the fixes. | |
| /copy [N] | Copy the last (or Nth-latest) response to the clipboard; pick single code blocks. | |
| /export [filename] | Export the conversation as plain text to a file or the clipboard. | |
| /add-dir <path> | Give Claude access to another working directory for this session. | |
| /cd <path> | Move the session to a new working directory, keeping the conversation. | |
| /agents | Reminder for creating subagents: ask Claude, or edit .claude/agents/ or ~/.claude/agents/. | |
| /tasks | View and manage background work (shells and subagents). Also /bashes. | |
| /skills | List available skills; filter, sort by token cost, and show or hide them. | |
| /mcp | Manage MCP server connections and OAuth; /mcp reconnect all retries failed servers. | |
| /hooks | View your hook configurations. | |
| /plugin [subcommand] | Manage plugins: list, install, enable, disable. | |
| /keybindings | Open your keyboard shortcuts file (~/.claude/keybindings.json). | |
| /output-style [style] | List output styles or switch to one. | |
| /theme | Change the color theme (auto, light, dark, colorblind-friendly, ANSI). | |
| /statusline | Configure the status line, or auto-configure it from your shell prompt. | |
| /terminal-setup | Install a Shift+Enter newline binding for your terminal or editor. | |
| /ide | Manage IDE integrations and show their status. | |
| /doctor | Skill: check installation, settings, extensions and CLAUDE.md and propose fixes. Alias /checkup. | |
| /loop [interval] [prompt] | Skill: run a prompt repeatedly while the session stays open, e.g. /loop 5m check the deploy. | |
| /schedule [description] | Create, update, list or run routines that execute in the cloud. | |
| /goal [condition|clear] | Set a goal Claude keeps working toward across turns until it is met. | |
| /install-github-app | Install the Claude GitHub App and optionally set up GitHub Actions. | |
| /sandbox | Toggle sandbox mode (supported platforms only). | |
| /login | Sign in to your Anthropic account. | |
| /logout | Sign out. | |
| /bug [report] | Report a bug or share the conversation, after a consent screen. | |
| /release-notes | Browse the changelog by version. | |
| /exit | Exit the CLI. Alias /quit. | |
| /vim (removed) | Removed in v2.1.92. Switch Vim editing mode in /config > Editor mode instead. |
CLI commands (run in your shell)#
| Command | What it does | |
|---|---|---|
| claude | Start an interactive session. | |
| claude "query" | Start an interactive session with a first prompt. | |
| claude -p "query" | Answer once without the interactive UI, then exit (print / SDK mode). | |
| cat file | claude -p "query" | Process piped content, e.g. cat logs.txt | claude -p "explain". | |
| claude -c | Continue the most recent conversation in this directory. | |
| claude -r "<session>" "query" | Resume a session by ID or name, optionally with a new prompt. | |
| claude update | Update to the latest version. | |
| claude install [version] | Install or reinstall the native binary: a version, stable or latest. | |
| claude auth login | Sign in (--console bills to the Anthropic Console instead of a subscription). | |
| claude auth status | Show sign-in status as JSON (--text for plain text). | |
| claude agents | Open agent view to monitor and dispatch background sessions. | |
| claude doctor | Print install and settings diagnostics without starting a session. | |
| claude mcp | Configure MCP servers (see the MCP table below). | |
| claude plugin | Manage plugins (alias claude plugins). | |
| claude setup-token | Generate a long-lived OAuth token for CI and scripts (needs a subscription). | |
| claude -v | Print the installed version. |
CLI flags#
Flags go after claude, before the prompt. Several (-p only) apply to print mode.
| Flag | What it does | Example | |
|---|---|---|---|
| --print, -p | Print the response without interactive mode. | claude -p "query" | |
| --continue, -c | Load the most recent conversation in the current directory. | claude --continue | |
| --resume, -r | Resume a session by ID or name, or show a picker. | claude --resume auth-refactor | |
| --fork-session | With --resume or --continue, start a new session ID instead of reusing the old one. | claude --resume abc123 --fork-session | |
| --name, -n | Name the session (shown in /resume and the terminal title). | claude -n "my-feature-work" | |
| --model | Model for this session: an alias (sonnet, opus, haiku, fable) or a full model name. | claude --model sonnet | |
| --fallback-model | Fall back to these models, in order, when the main one is overloaded or unavailable. | claude --fallback-model sonnet,haiku | |
| --effort | Effort level for this session: low, medium, high, xhigh, max or ultracode. | claude --effort high | |
| --permission-mode | Start in a permission mode: default (manual), acceptEdits, plan, auto, dontAsk, bypassPermissions. | claude --permission-mode plan | |
| --dangerously-skip-permissions | Skip permission prompts (same as --permission-mode bypassPermissions). Use only in isolated containers or VMs. | claude --dangerously-skip-permissions | |
| --allowedTools | Tools that run without asking, using permission rule syntax. | claude --allowedTools "Bash(git log *)" "Read" | |
| --disallowedTools | Deny rules: a bare tool name removes the tool; a scoped rule denies matching calls. | claude --disallowedTools "Bash(rm *)" "Edit" | |
| --tools | Restrict which built-in tools exist: "" for none, "default", or a list. | claude --tools "Bash,Edit,Read" | |
| --output-format | Print-mode output: text, json or stream-json. | claude -p "query" --output-format json | |
| --input-format | Print-mode input: text or stream-json. | claude -p --output-format json --input-format stream-json | |
| --json-schema | Return validated JSON matching a schema when the run finishes (print mode). | claude -p --json-schema '{"type":"object"}' "query" | |
| --max-turns | Cap the number of agentic turns (print mode). | claude -p --max-turns 3 "query" | |
| --max-budget-usd | Stop once estimated API spend reaches this amount (print mode). | claude -p --max-budget-usd 5.00 "query" | |
| --append-system-prompt | Append text to the default system prompt. | claude --append-system-prompt "Always use TypeScript" | |
| --system-prompt | Replace the whole system prompt. | claude --system-prompt "You are a Python expert" | |
| --add-dir | Add more working directories Claude can read and edit. | claude --add-dir ../apps ../lib | |
| --mcp-config | Load MCP servers from JSON files or strings. | claude --mcp-config ./mcp.json | |
| --strict-mcp-config | Use only the servers from --mcp-config. | claude --strict-mcp-config --mcp-config ./mcp.json | |
| --settings | Load settings from a JSON file or string for this session. | claude --settings ./settings.json | |
| --setting-sources | Which settings files to load: user, project, local. | claude --setting-sources user,project | |
| --agents | Define subagents inline as JSON. | claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}' | |
| --agent | Run the session as a specific agent. | claude --agent my-custom-agent | |
| --worktree, -w | Start in an isolated git worktree under .claude/worktrees/. | claude -w feature-auth | |
| --bare | Minimal mode: skip hooks, skills, plugins, MCP, auto memory and CLAUDE.md for fast scripted runs. | claude --bare -p "query" | |
| --safe-mode | Start with all customizations off to troubleshoot a broken setup. | claude --safe-mode | |
| --verbose | Show full turn-by-turn output. | claude --verbose | |
| --debug | Debug mode, optionally filtered by category. | claude --debug='mcp,startup' | |
| --ide | Connect to your IDE on startup if exactly one is available. | claude --ide | |
| --chrome | Enable Claude in Chrome browser integration. | claude --chrome | |
| --version, -v | Print the version number. | claude -v |
Permission modes#
Cycle with Shift+Tab, start with --permission-mode, or set defaultMode in settings. The mode named Manual in the UI is default in config.
| Mode | What runs without asking | Best for | |
|---|---|---|---|
| default (Manual) | Reads only. | Reviewing every action, sensitive work | |
| acceptEdits | Reads, file edits and common filesystem commands (mkdir, touch, mv, cp...). | Iterating on code you are reviewing | |
| plan | Reads, plus classifier-approved commands when auto mode is available. | Exploring a codebase before changing it | |
| auto | Everything, with background safety checks. | Long tasks, fewer prompts | |
| dontAsk | File reads in your working directories and pre-approved tools; anything else is denied. | Locked-down CI and scripts | |
| bypassPermissions | Everything. | Isolated containers and VMs only |
Memory: CLAUDE.md files and where they live#
CLAUDE.md files load at the start of every session. Use @path/to/file inside one to import another file (up to four hops deep).
| File | Scope and use | |
|---|---|---|
| /Library/Application Support/ClaudeCode/CLAUDE.md | Managed policy (macOS): organization-wide instructions deployed by IT. Linux and WSL: /etc/claude-code/CLAUDE.md; Windows: C:\Program Files\ClaudeCode\CLAUDE.md. | |
| ~/.claude/CLAUDE.md | Your personal instructions for every project. | |
| ./CLAUDE.md or ./.claude/CLAUDE.md | Project instructions shared with the team through source control. | |
| ./CLAUDE.local.md | Your private notes for this project; add it to .gitignore. | |
| .claude/rules/*.md | Topic files (testing.md, api-design.md); optional paths frontmatter loads a rule only for matching files. | |
| ~/.claude/projects/<project>/memory/ | Auto memory: a MEMORY.md index plus topic files Claude writes for itself; manage with /memory. | |
| AGENTS.md | Read as project instructions too; the memory docs explain when it loads instead of or alongside CLAUDE.md. |
Settings files (highest precedence first)#
Managed settings beat --settings, which beats project local, then shared project, then user settings. Lists such as permission rules merge across files.
| File | Scope and use | |
|---|---|---|
| managed-settings.json | Managed: deployed by your organization (file, MDM or server-managed). Your own files and --settings can’t override its keys. | |
| --settings <file-or-json> | Command line: overrides the files below for one session. | |
| .claude/settings.local.json | Project local: you, in this project only; kept out of git. | |
| .claude/settings.json | Shared project: commit it so the team gets the same permissions, hooks and plugins. | |
| ~/.claude/settings.json | User: your preferences in every project (theme, model, your permission rules). | |
| ~/.claude.json | Written by Claude Code itself: sign-in, MCP servers, per-project state. Not one of the precedence levels. | |
| ~/.claude/keybindings.json | Custom keyboard shortcuts (open with /keybindings); changes apply without a restart. |
Hook events#
Hooks are shell commands (or prompts) in the "hooks" key of a settings file. Exit code 2 blocks the action on events that can block, and stderr is shown to Claude.
| Event | When it fires | |
|---|---|---|
| SessionStart | A session begins or resumes. | |
| Setup | Claude Code starts with --init-only, or --init / --maintenance in -p mode. | |
| UserPromptSubmit | A prompt is submitted, before Claude processes it. | |
| UserPromptExpansion | A typed command expands into a prompt; can block the expansion. | |
| PreToolUse | Before a tool call runs; can block it. | |
| PermissionRequest | A tool call needs a permission decision. | |
| PermissionDenied | Auto mode denies a tool call. | |
| PostToolUse | After a tool call succeeds. | |
| PostToolUseFailure | After a tool call fails. | |
| PostToolBatch | After a batch of parallel tool calls resolves, before the next model call. | |
| Notification | Claude Code sends a notification (permission prompt, idle prompt...). | |
| MessageDisplay | While assistant message text is displayed. | |
| SubagentStart | A subagent is spawned. | |
| SubagentStop | A subagent finishes. | |
| TaskCreated | A task is being created. | |
| TaskCompleted | A task is being marked completed. | |
| Stop | Claude finishes responding. | |
| StopFailure | The turn ends because of an API error. | |
| TeammateIdle | An agent-team teammate is about to go idle. | |
| InstructionsLoaded | A CLAUDE.md or .claude/rules file loads into context. | |
| ConfigChange | A configuration file changes during the session. | |
| CwdChanged | The working directory changes (useful with direnv). | |
| DirectoryAdded | A working directory is added with /add-dir. | |
| FileChanged | A watched file changes on disk (matcher lists the filenames). | |
| WorktreeCreate | A worktree is being created; replaces the default git behavior. | |
| WorktreeRemove | A worktree created by a WorktreeCreate hook is removed. | |
| PreCompact | Before context compaction. | |
| PostCompact | After compaction completes. | |
| PreModelSwitch | Before a model switch is applied; can block it. | |
| PostModelSwitch | After the session’s model changes. | |
| Elicitation | An MCP server asks for user input during a tool call. | |
| ElicitationResult | After you answer an MCP elicitation, before the reply is sent. | |
| SessionEnd | A session ends. |
MCP server commands#
Scopes: local (default, this project, stored in ~/.claude.json), project (.mcp.json in the repo, shared with the team) and user (all your projects, ~/.claude.json).
| Command | What it does | Example | |
|---|---|---|---|
| claude mcp add --transport http <name> <url> | Add a remote HTTP server. | claude mcp add --transport http notion https://mcp.notion.com/mcp | |
| claude mcp add [options] <name> -- <command> [args...] | Add a local stdio server; everything after -- runs the server. | claude mcp add --env AIRTABLE_API_KEY=YOUR_KEY --transport stdio airtable -- npx -y airtable-mcp-server | |
| claude mcp add --transport sse <name> <url> | Add a server that only offers an SSE endpoint. | claude mcp add --transport sse asana https://mcp.asana.com/sse | |
| --scope local|project|user | Choose where the server is saved (default local). | claude mcp add --transport http hubspot --scope user https://mcp.hubspot.com/anthropic | |
| claude mcp add-json <name> '<json>' | Add a server from a JSON config object. | claude mcp add-json example '{"command":"npx","args":["-y","@example/mcp-server"]}' | |
| claude mcp list | List servers with a health status (Connected, Needs authentication, Failed). | ||
| claude mcp get <name> | Show one server’s details and any connection issue. | claude mcp get notion | |
| claude mcp remove <name> | Remove a server. | claude mcp remove notion | |
| claude mcp login <name> | Run a server’s OAuth flow without opening /mcp. | ||
| claude mcp add-from-claude-desktop | Import servers configured in Claude Desktop. | ||
| claude mcp reset-project-choices | Reset your approvals for project-scoped .mcp.json servers. | ||
| claude mcp serve | Run Claude Code itself as a stdio MCP server for other apps. |
Keyboard shortcuts
Last verified: against Claude Code v2.1.302 (October 16, 2026). 48 shortcuts.
Most shortcuts are the same on every system and use Control, not Command, even on a Mac. The Option-key shortcuts on macOS (Option plus B, Option plus P...) need “Option as Meta” turned on in your terminal. You can rebind most actions in ~/.claude/keybindings.json (run /keybindings).
Showing all 48 shortcuts in 5 categories
General controls#
| Action | macOS | Windows / Linux | Copy |
|---|---|---|---|
| Interrupt Claude or close a dialogStops the current response or tool call; work done so far is kept. On a permission prompt, Esc answers No. | Escape | Escape | |
| Clear the draft, or open the rewind menu (empty prompt) | Escape then Escape | Escape then Escape | |
| Interrupt; on an idle prompt clear it, press again to exit | Control plus C | Control plus C | |
| Exit Claude Code (press twice)With text in the prompt, Ctrl+D deletes the character after the cursor instead. | Control plus D | Control plus D | |
| Cycle permission modes (Manual, acceptEdits, plan, auto...) | Shift plus Tab | Shift plus Tabor Alt plus MAlt+M on Windows when the runtime doesn’t enable VT input mode. | |
| Switch model without clearing the prompt | Option plus PmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | Alt plus P | |
| Toggle extended thinkingNo effect on models that always think (Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable). | Option plus T | Alt plus T | |
| Toggle fast mode | Option plus O | Alt plus O | |
| Edit the prompt in your text editor | Control plus Gor Control plus X then Control plus E | Control plus Gor Control plus X then Control plus E | |
| Paste an image from the clipboard | Control plus Vor Command plus VCmd+V in iTerm2. | Control plus Vor Alt plus VAlt+V on Windows and WSL. | |
| Reverse-search your prompt history | Control plus R | Control plus R | |
| Previous / next prompt in historyIn a multi-row prompt the arrows move the cursor first. | Up arrowor Down arrowor Control plus Por Control plus N | Up arrowor Down arrowor Control plus Por Control plus N | |
| Toggle the transcript viewer (tool calls in detail) | Control plus O | Control plus O | |
| Send running Bash commands and agents to the backgroundIn tmux, press it twice. | Control plus B | Control plus B | |
| Show or hide Claude’s to-do checklist | Control plus T | Control plus T | |
| Stash the prompt (press again on an empty prompt to restore) | Control plus S | Control plus S | |
| Send queued messages now | Control plus Enteror Control plus X then Control plus S | Control plus Enteror Control plus X then Control plus S | |
| Stop all background subagents (press twice within 3 s) | Control plus X then Control plus K | Control plus X then Control plus K | |
| Redraw the screen (fix a garbled display) | Control plus L | Control plus L | |
| Suspend Claude Code to the shell (run fg to resume) | Control plus Z | Control plus ZLinux only; Unix shells. | |
| Accept an autocomplete suggestion | Tab | Tab | |
| Show the shortcut help panel (empty prompt) | question mark | question mark | |
| Voice dictation: hold (or tap) SpaceOnly with /voice turned on. | Space bar | Space bar |
Prompt text editing (readline style)#
| Action | macOS | Windows / Linux | Copy |
|---|---|---|---|
| Move to the start of the line | Control plus A | Control plus A | |
| Move to the end of the line | Control plus E | Control plus E | |
| Delete to the end of the line | Control plus K | Control plus K | |
| Delete from the cursor to the line start | Control plus Uor Command plus DeleteiTerm2 and Terminal.app send Ctrl+U for Cmd+Backspace. | Control plus U | |
| Delete back to the previous space (whole path or --flag) | Control plus W | Control plus W | |
| Delete the previous word | Option plus Delete | Control plus BackspaceWindows. | |
| Paste the text you last deleted | Control plus Y | Control plus Y | |
| Cycle through earlier deleted text (after Ctrl+Y) | Option plus YmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | Alt plus Y | |
| Move back one word | Option plus BmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | Alt plus B | |
| Move forward one word | Option plus FmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | Alt plus F | |
| Delete to the end of the word | Option plus DmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | Alt plus D | |
| Undo the last edit to the prompt | Control plus underscoreor Control plus Shift plus hyphen | Control plus underscoreor Control plus Shift plus hyphen |
Multiline input#
| Action | macOS | Windows / Linux | Copy |
|---|---|---|---|
| New line: type \ then press Enter (any terminal) | backslash then Return | backslash then Enter | |
| New line with Shift+EnterWorks natively in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal and Windows Terminal; /terminal-setup adds it to VS Code, Cursor, Alacritty and Zed. | Shift plus Return | Shift plus Enter | |
| New line with Ctrl+J (works without setup) | Control plus J | Control plus J | |
| New line with Option+Enter | Option plus ReturnmacOS: needs "Option as Meta" turned on in your terminal (see /terminal-setup or the docs). | No default shortcut |
Quick prefixes: /, !, @#
| Action | macOS | Windows / Linux | Copy |
|---|---|---|---|
| Start a command or skill | slash | slash | |
| Shell mode: run a command and add its output | exclamation point | exclamation point | |
| Mention a file (path autocomplete) | at sign | at sign | |
| Emoji shortcode (:name:) | colon | colon |
Transcript viewer (Ctrl+O)#
| Action | macOS | Windows / Linux | Copy |
|---|---|---|---|
| Leave the transcript viewer | Qor Control plus Cor Escape | Qor Control plus Cor Escape | |
| Show all content (classic renderer) | Control plus E | Control plus E | |
| Jump to the previous / next prompt (fullscreen) | left braceor right brace | left braceor right brace | |
| Write the conversation to terminal scrollback (fullscreen) | left bracket | left bracket | |
| Open the conversation in $EDITOR (fullscreen) | V | V |
Sources (1 official pages)
Everything runs in your browser; searches are not sent anywhere. Entries are checked against the official Claude Code documentation. Browse all free tools.
Found a problem, or something that could be better? We read every message and we fix things quickly.
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.
Related free tools
- MCP Config Generator — Define an MCP server once and get the exact config file or command for Claude Desktop, Claude Code, Cursor, VS Code, Windsurf and Codex.
- Token Counter — Count tokens exactly for OpenAI models, estimate them for Claude, Gemini and Llama, see the cost, and watch the text split into tokens.
- LLM API Cost Calculator — Compare the cost of your workload across 40+ models, with caching, batch discounts, long-context tiers and reasoning tokens. Prices sourced and dated.
- VS Code Shortcuts — Every default Visual Studio Code shortcut for Windows and Mac, with Linux differences: multi-cursor, search, refactoring, terminal.
- Git Cheat Sheet — Git commands organised by what you want to do: undo the last commit, rename a branch, delete a remote branch. Modern switch/restore with classic equivalents and danger badges.