Claude Code is Anthropic's agentic coding assistant that runs directly in your terminal. It reads files, executes commands, edits code, and reasons about your entire codebase -- no copy-paste, no IDE plugins, no web interface required.
This cheatsheet covers every keyboard shortcut, slash command, and CLI flag you need. Everything here is verified against the official Claude Code documentation as of April 2026. Bookmark it, print it, or keep it open in a second tab.
Most Used Claude Code CLI Commands (Start Here)
These twelve shortcuts and commands show up in nearly every Claude Code session. If you learn nothing else from this cheatsheet, commit these to muscle memory.
Quick Reference -- Most Used
| Shortcut | Description |
|---|---|
Ctrl+C | Cancel current input or generation |
Ctrl+D | Exit Claude Code session (EOF) |
Tab | Autocomplete file paths in prompts |
Up/Down | Navigate command history |
/help | Show all available commands |
/clear | Clear conversation, free context |
/compact | Summarize context to save tokens |
Shift+Enter | New line without submitting |
Esc + Esc | Rewind to a checkpoint |
/exit | Exit session (alias: /quit) |
Ctrl+R | Reverse search command history |
Shift+Tab | Cycle permission modes |
Setup & Installation
Claude Code installs via npm and runs anywhere Node.js does. Zero to first session in under five minutes.
How to Install Claude Code CLI
-
Install Node.js 18+
Claude Code requires Node.js version 18 or higher. Check with
node --version. Download from nodejs.org if needed. -
Install Claude Code globally
Add it to your system path:
npm install -g @anthropic-ai/claude-code -
Authenticate
You have two options. For a Claude subscription, run
claude auth login. For API billing, runclaude auth login --console. Or set your key directly:export ANTHROPIC_API_KEY=your_key_here -
Navigate to your project
Claude Code works best when launched inside your codebase:
cd /path/to/your/project -
Launch Claude Code
Start an interactive session:
claude
Add export ANTHROPIC_API_KEY=your_key to your ~/.zshrc or ~/.bashrc so you never have to set it again. Run source ~/.zshrc after saving. Alternatively, you can set environment variables permanently in your settings.json.
Session Management Keyboard Shortcuts
These shortcuts control your Claude Code session -- starting, stopping, pausing, and managing the conversation flow. All shortcuts verified against the official interactive mode docs.
| Shortcut | Action | Notes |
|---|---|---|
Ctrl+C |
Cancel current input or generation | Standard interrupt. Stops a running task or clears pending input |
Ctrl+D |
Exit session | EOF signal; cleanly closes the session and returns to your shell |
Ctrl+L |
Clear prompt input | Clears typed text but preserves conversation history |
Esc+Esc |
Rewind or summarize | Restore code and/or conversation to a previous checkpoint. Also available via /rewind |
Shift+Tab |
Cycle permission modes | Cycles through default, acceptEdits, plan, and any enabled modes (auto, bypassPermissions) |
Alt+T |
Toggle extended thinking | Enable deeper reasoning mode. Mac: Option+T (requires terminal Meta config) |
Alt+P |
Switch model | Change models (Sonnet, Opus, Haiku) without clearing your prompt. Mac: Option+P |
Alt+O |
Toggle fast mode | Enable faster responses with the same model. Mac: Option+O |
Shift+Enter |
Insert newline without submitting | Works out of the box in iTerm2, WezTerm, Ghostty, Kitty. Run /terminal-setup for other terminals |
Enter |
Submit prompt | Sends your current input to Claude |
Ctrl+T |
Toggle task list | Show or hide the task list in the terminal status area |
Ctrl+O |
Toggle transcript viewer | Cycles through normal, transcript mode, and focus view. Shows detailed tool usage |
Ctrl+G |
Open in external editor | Edit prompts in your default text editor. Also: Ctrl+X Ctrl+E |
Ctrl+B |
Background running task | Send bash commands and agents to the background. Tmux users: press twice |
Ctrl+X Ctrl+K |
Kill all background agents | Press the sequence twice within 3 seconds to confirm |
Ctrl+V |
Paste image from clipboard | Inserts an [Image #N] chip. Mac in iTerm2: Cmd+V. Windows: Alt+V |
Hold Space |
Push-to-talk dictation | Requires /voice to be enabled. Transcript inserts at cursor |
Option/Alt shortcuts (Alt+T, Alt+P, Alt+O) require configuring Option as Meta in your terminal. In iTerm2: Settings > Profiles > Keys > set Left/Right Option to "Esc+". In VS Code: set "terminal.integrated.macOptionIsMeta": true.
Navigation & Input Shortcuts
Navigate command history, search previous prompts, and use the quick-command prefixes that make Claude Code faster than a chat window.
| Shortcut | Action | Notes |
|---|---|---|
↑ / ↓ |
Navigate command history | Recall previous inputs. History is per working directory and resets on /clear |
Ctrl+R |
Reverse search command history | Type to search. Ctrl+R again to cycle matches. Tab/Esc to accept, Enter to execute |
Tab |
Autocomplete file path or command | Works with @ file mentions and after ! bash prefix |
@ |
File path mention | Triggers file path autocomplete. E.g., @src/auth.ts fix the bug |
! at start |
Bash mode | Run shell commands directly. Output added to conversation context. E.g., ! npm test |
/ at start |
Command or skill | Type / and keep typing to filter available commands |
Alt+B |
Move cursor back one word | Word navigation. Mac: requires Option as Meta |
Alt+F |
Move cursor forward one word | Word navigation. Mac: requires Option as Meta |
← / → |
Cycle dialog tabs | Navigate between tabs in permission dialogs and menus |
Multiline Input Methods
Claude Code supports several ways to write multi-line prompts.
| Method | How | Notes |
|---|---|---|
| Backslash escape | \ then Enter |
Works in all terminals |
| macOS default | Option+Enter |
Default on macOS |
| Shift+Enter | Shift+Enter |
Works in iTerm2, WezTerm, Ghostty, Kitty. Run /terminal-setup for others |
| Control sequence | Ctrl+J |
Line feed character. Works everywhere |
| Paste mode | Paste directly | For code blocks, logs, and large text |
Text Editing Shortcuts
Claude Code uses readline-style editing. These shortcuts let you cut, paste, and manipulate prompt text without reaching for the mouse.
| Shortcut | Action | Notes |
|---|---|---|
Ctrl+K |
Delete to end of line | Stores deleted text for pasting with Ctrl+Y |
Ctrl+U |
Delete from cursor to line start | Stores deleted text for pasting. Repeat to clear across lines in multiline input |
Ctrl+Y |
Paste deleted text (yank) | Pastes text deleted with Ctrl+K or Ctrl+U. Different from system clipboard |
Alt+Y |
Cycle paste history | After Ctrl+Y, cycle through previously deleted text. Mac: requires Option as Meta |
Prefer vim-style editing? Enable it via /config > Editor mode. You get full normal mode navigation (h/j/k/l, w/b/e), editing operators (d, c, y, p), and text objects (iw, i", i{). Full vim reference in the docs.
All Slash Commands
Type / in Claude Code to see every available command, or type / followed by letters to filter. Commands marked [Skill] are bundled skills -- prompts handed to Claude that it can also invoke automatically when relevant. Full list at the official commands reference.
Session Control
| Command | Description | When to Use |
|---|---|---|
| /help | Show all available commands | First thing to run in a new session |
| /clear | Clear conversation history and free context | When switching tasks. Aliases: /reset, /new |
| /compact [instructions] | Summarize conversation to reclaim context space | When context fills up in long sessions. Pass instructions to guide the summary |
| /exit | Exit Claude Code and return to the shell | Alias: /quit |
| /status | Show session info (model, context usage, cost) | Monitor token consumption during long sessions |
| /cost | Show cumulative cost for this session | Track spending, especially in automation |
| /model [model] | Display or switch the active model | Use sonnet or opus aliases, or full model IDs |
| /effort [level] | Set effort level (low, medium, high, max) | Lower effort for simple tasks; max for Opus 4.6 deep reasoning |
| /fast [on|off] | Toggle fast mode | Same model, faster output |
Context & Navigation
| Command | Description | When to Use |
|---|---|---|
| /resume [session] | Resume a conversation by ID or name | Pick up where you left off. Alias: /continue |
| /rename [name] | Set a display name for the current session | Shown in /resume picker and prompt bar |
| /branch [name] | Branch the conversation at this point | Try different approaches without losing history. Alias: /fork |
| /rewind | Rewind conversation and/or code to a checkpoint | Supports code-only or conversation-only rollback. Alias: /checkpoint |
| /diff | Show all changes made this session | Review before committing |
| /copy [N] | Copy last response to clipboard | Pass N for Nth-latest. Code block picker available. w writes to file |
| /export [filename] | Export conversation to file | Save the full session transcript |
| /btw <question> | Ask a side question without adding to history | Quick answers that do not clutter context. Works while Claude is processing |
| /context | Show current context window usage | See how full the context is |
| /memory | Manage CLAUDE.md memory files | Edit persistent project instructions |
Configuration & Setup
| Command | Description | When to Use |
|---|---|---|
| /config | Open settings interface | Adjust theme, model, output style, editor mode. Alias: /settings |
| /permissions | Manage tool permission rules | View/edit allow, ask, and deny rules by scope. Alias: /allowed-tools |
| /init | Initialize project with CLAUDE.md | Run in every new repository to create persistent project context |
| /keybindings | Open keyboard shortcuts config | Customize at ~/.claude/keybindings.json |
| /doctor | Run diagnostics | Debug keybinding conflicts, MCP issues, plugin problems |
| /theme | Change color theme | Customize Claude Code appearance |
| /terminal-setup | Install terminal keybindings | Needed for Shift+Enter in VS Code, Alacritty, Zed, Warp |
| /mcp | Manage MCP server connections | Add, remove, or configure Model Context Protocol servers |
| /hooks | View configured hooks | See active lifecycle hooks for the session |
| /login / /logout | Manage authentication | Sign in or out of your Anthropic account |
Advanced Skills & Automation
These are bundled skills -- prompt-based workflows that Claude executes as multi-step tasks.
| Command | Description | Example |
|---|---|---|
| /batch <instruction> | Orchestrate large-scale changes in parallel | /batch migrate src/ from Solid to React |
| /simplify [focus] | Review recent changes for quality and efficiency, then fix | /simplify focus on memory efficiency |
| /autofix-pr [prompt] | Watch current PR and push fixes for CI failures and reviews | /autofix-pr only fix lint errors |
| /loop [interval] <prompt> | Run a prompt repeatedly on an interval | /loop 5m check if the deploy finished |
| /schedule [description] | Create scheduled tasks | Set up tasks to run at specific times |
| /ultraplan <prompt> | Deep planning for complex multi-step tasks | /ultraplan redesign the auth system |
| /plan [description] | Enter plan mode directly | /plan fix the auth bug |
| /debug [description] | Enable debug logging and troubleshoot issues | /debug MCP server not connecting |
| /security-review | Security audit of recent changes | Run before pushing sensitive code changes |
Remote & Cross-Device
| Command | Description | Notes |
|---|---|---|
| /remote-control | Make this session controllable from claude.ai | Alias: /rc. Control from web or mobile app |
| /teleport | Pull a web session into this terminal | Alias: /tp. Fetches branch and conversation |
| /desktop | Continue session in Claude Code Desktop app | macOS and Windows only. Alias: /app |
| /voice | Enable push-to-talk voice input | Hold Space to dictate after enabling |
| /chrome | Enable Chrome browser integration | For web automation and testing |
| /ide | Connect to IDE | Auto-connect to a running IDE instance |
CLI Flags & Startup Options
These flags are passed when launching Claude Code from the command line. Note: claude --help does not list every flag -- a flag's absence from --help does not mean it is unavailable. Full reference at code.claude.com/docs/en/cli-reference.
Core Commands
| Command | Description | Example |
|---|---|---|
| claude | Start interactive session | claude |
| claude "query" | Start session with initial prompt | claude "explain this project" |
| claude -p "query" | Print mode: run prompt, then exit | claude -p "explain this function" |
| claude -c | Continue most recent conversation | claude -c |
| claude -r <session> "query" | Resume session by ID or name | claude -r "auth-refactor" "Finish this PR" |
| claude update | Update to latest version | claude update |
| claude auth login | Sign in to Anthropic account | claude auth login --console for API billing |
| claude agents | List all configured subagents | claude agents |
| claude mcp | Configure MCP servers | claude mcp add my-server |
| claude plugin | Manage plugins | claude plugin install code-review@claude-plugins-official |
| claude remote-control | Start Remote Control server mode | claude remote-control --name "My Project" |
| cat file | claude -p "query" | Pipe content as input | cat logs.txt | claude -p "explain these errors" |
Session & Model Flags
| Flag | Description | Example |
|---|---|---|
| --model | Set the model. Accepts aliases (sonnet, opus) or full IDs |
claude --model sonnet |
| --effort | Set effort level: low, medium, high, max | claude --effort high |
| --continue / -c | Load most recent conversation | claude -c |
| --resume / -r | Resume session by ID or name | claude -r auth-refactor |
| --name / -n | Set session display name | claude -n "my-feature-work" |
| --fork-session | Create new session ID when resuming | claude --resume abc123 --fork-session |
| --fallback-model | Auto-fallback model when primary is overloaded | claude -p --fallback-model sonnet "query" |
Permissions & Tools Flags
| Flag | Description | Example |
|---|---|---|
| --permission-mode | Start in a specific permission mode (default, acceptEdits, plan, auto, bypassPermissions) | claude --permission-mode plan |
| --dangerously-skip-permissions | Skip all permission prompts | Equivalent to --permission-mode bypassPermissions |
| --allowedTools | Tools that execute without prompting | claude --allowedTools "Bash(git log *)" "Read" |
| --disallowedTools | Remove specific tools entirely | claude --disallowedTools "Bash(git push *)" |
| --tools | Restrict which built-in tools Claude can use | claude --tools "Bash,Edit,Read" or "" for none |
Automation & CI Flags
| Flag | Description | Example |
|---|---|---|
| --output-format | Output format for print mode: text, json, stream-json | claude -p "list files" --output-format json |
| --max-turns | Limit agentic turns in print mode | claude --max-turns 10 -p "fix tests" |
| --max-budget-usd | Maximum dollar spend before stopping | claude -p --max-budget-usd 5.00 "query" |
| --json-schema | Get validated JSON matching a schema | claude -p --json-schema '{"type":"object",...}' "query" |
| --bare | Minimal mode: skip hooks, skills, plugins, MCP, CLAUDE.md | claude --bare -p "query" |
| --verbose | Full turn-by-turn logging | claude --verbose |
| --debug | Debug output with optional category filter | claude --debug "api,mcp" |
Remote & Worktree Flags
| Flag | Description | Example |
|---|---|---|
| --worktree / -w | Start in isolated git worktree | claude -w feature-auth |
| --tmux | Create tmux session for worktree. Requires -w |
claude -w feature-auth --tmux |
| --remote | Create a web session on claude.ai | claude --remote "Fix the login bug" |
| --remote-control / --rc | Start interactive session with Remote Control | claude --rc "My Project" |
| --teleport | Resume a web session in your terminal | claude --teleport |
| --chrome | Enable Chrome browser integration | claude --chrome |
| --add-dir | Add extra working directories | claude --add-dir ../apps ../lib |
System Prompt Flags
| Flag | Description | Example |
|---|---|---|
| --system-prompt | Replace the entire system prompt | claude --system-prompt "You are a Python expert" |
| --system-prompt-file | Replace prompt from file | claude --system-prompt-file ./review.txt |
| --append-system-prompt | Append to default prompt | claude --append-system-prompt "Always use TypeScript" |
| --append-system-prompt-file | Append file contents to default prompt | claude --append-system-prompt-file ./rules.txt |
This flag (and the equivalent --permission-mode bypassPermissions) auto-approves every operation including file deletions and shell commands. It is designed for CI pipelines and automation scripts where you trust the environment -- not for interactive development where you want to review changes first.
Pro Tips & Productivity Patterns
These patterns come from real usage across teams building with Claude Code daily. None of them are obvious from the docs alone.
1. Use /compact before you hit the wall
Claude Code has a context window limit. In sessions where you have explored dozens of files, the model starts losing track of early context. Run /compact proactively -- every 30 minutes or whenever you shift to a new subtask. You can pass instructions to guide the summary: /compact keep the auth refactor context, drop the test exploration.
2. Scope prompts with @ file mentions
Generic prompts like "fix the authentication bug" force Claude to search your entire codebase. Reference specific files with @src/auth/session.ts syntax to reduce hallucination and speed up responses. Tab-completion works with @, so you do not need to type full paths.
3. Use /btw for quick questions mid-task
When Claude is in the middle of a long task, use /btw to ask a side question without polluting conversation context. The answer appears in an overlay and never enters history. Useful for "what was that config file called again?" moments.
4. Match model to task with /model
Not every task needs Opus. Switch to /model haiku for quick tasks -- renaming variables, generating docstrings, writing utility functions. Save Opus for architectural reasoning, complex debugging, and multi-file refactors. The cost difference is 10-20x at scale.
5. Chain --output-format json with pipes for automation
When using Claude Code in scripts and CI pipelines, combine -p with --output-format json for machine-parseable output. Add --max-budget-usd to cap spend: claude -p "analyze test failures" --output-format json --max-budget-usd 2.00
6. Pin a CLAUDE.md for persistent project context
Create a CLAUDE.md file in your project root. Claude Code reads it at the start of every session. Use it for code style preferences, architectural decisions, naming conventions, and domain knowledge. Run /init to generate one automatically, or /memory to edit it mid-session.
7. Use worktrees for parallel sessions
Working on multiple features? Use --worktree to isolate each session in its own git worktree: claude -w feature-auth. This creates a worktree at .claude/worktrees/feature-auth. Combine with --tmux to get each session in its own pane.
8. Remote Control for mobile monitoring
Start a session with --rc to control it from claude.ai or the Claude mobile app. Start a long-running task, walk away from your desk, and check progress from your phone. Combine with worktrees for isolated remote sessions: claude -w bugfix --rc "Fix the login bug"
9. Use /batch for large-scale refactors
The /batch skill decomposes large changes into 5-30 independent units, then spawns parallel agents in isolated worktrees. Each agent implements its unit, runs tests, and opens a PR. This turns a day of manual refactoring into a 30-minute supervised operation.
10. Save shell aliases for repeated workflows
If you run the same Claude Code prompts repeatedly, save them as shell aliases in your ~/.zshrc:
| Alias | Expands To |
|---|---|
| cc-review | claude -p "review the staged changes for bugs, security issues, and style" |
| cc-tests | claude -p "generate unit tests for modified files in this branch" |
| cc-commit | claude -p "write a conventional commit message for my staged changes" |
| cc-explain | claude -p "explain this codebase for a new engineer" |
