Claude Code CLI

The complete cheat sheet

All slash commands, keyboard shortcuts, CLI flags, and prompt patterns — in one searchable reference.

41 Slash Commands
26 Shortcuts
18 Prompt Patterns
3 Special Prefixes
Slash Commands 41
/help

Show all available commands and keybindings.

/clear

Clear conversation history and start fresh. Context is wiped.

/compact [instructions]

Compress conversation history to save context window space.

/compact focus on the auth module changes
/config

Open the Claude Code configuration editor. Manage models, permissions, and settings.

/cost

Show token usage and estimated cost for the current session.

/doctor

Check Claude Code installation health. Verifies dependencies, auth, and configuration.

/exit  /quit

Exit Claude Code. Ctrl+D also works.

/init

Generate a CLAUDE.md file. Claude analyses the codebase and creates project-specific instructions.

Power
/login

Authenticate with your Anthropic account via browser OAuth or API key.

/logout

Sign out from your Anthropic account and clear saved credentials.

/memory

Open memory files editor. Manage persistent notes that Claude remembers across sessions.

Power
/model

Select the AI model: Claude Opus 4.7, Sonnet 4.6, or Haiku 4.5.

/permissions

View and manage tool permissions — files, bash, browser, etc.

/pr_comments

Fetch and display comments from the current GitHub pull request.

/release-notes

View the Claude Code release notes and changelog for the installed version.

/review

Request a code review. Claude analyses the diff and suggests improvements.

/status

Show current account status, plan, and usage limits for the session.

/terminal-setup

Install shell integration (bash/zsh/fish). Enables Shift+Tab and other terminal features.

/vim

Toggle vim keybindings in the input prompt.

/bug

Open GitHub issue to report a Claude Code bug. Automatically includes version info.

/commit

Create a git commit with an AI-generated message based on staged changes.

Power
/fast

Toggle fast output mode for quicker responses with Opus 4.7.

New
/mcp

List connected MCP servers and their available tools and status.

Power
/ide

Connect and manage IDE integrations (VS Code, JetBrains, Cursor). Enables real-time file sync.

New
/rewind

Open the rewind UI — restore a past checkpoint, rolling back both chat history AND file changes. Also triggered by Esc+Esc.

Power
/plan [description]

Enter plan mode — read-only. Claude researches and proposes a plan without making file changes.

Power
/effort [level]

Set reasoning effort: low, medium, high, max, auto. Higher = more thinking tokens (Opus 4.7 only).

/effort max
/diff

Open the interactive diff viewer showing all file changes made in the current session.

/context

Visualize context window usage as a colored grid. Shows what's consuming space.

/tasks

List and manage background tasks (subagents). View progress, outputs, stop tasks.

/loop [interval] [prompt]

Run a prompt on a recurring interval. Use to poll status, monitor builds, or run periodic checks.

/loop 5m check test statusSkill
/btw <question>

Ask a side question without adding it to conversation history.

/btw what does RFC 9110 say about 408?
/voice

Toggle voice dictation. Hold Space to record, release to transcribe. 20+ languages.

New
/keybindings

Open the keybindings editor (~/.claude/keybindings.json). Remap any shortcut or create chord sequences.

/add-dir <path>

Add a directory to Claude's working context mid-session.

/add-dir ../shared-lib
/usage

Show your current plan limits, rate limits, and usage quotas. More detailed than /cost.

/copy [N]

Copy the last assistant response to clipboard. Pass N to copy the Nth-last response.

/rename [name]

Rename the current session. Easier to resume with claude -r "name".

/export [filename]

Export the current conversation as a text file.

/hooks

View all configured hooks. Hooks run shell commands on events like PreToolUse, PostToolUse, SessionEnd.

Advanced
Keyboard Shortcuts 26
Ctrl + C

Cancel the current operation or interrupt Claude mid-response.

Ctrl + D

Exit Claude Code (EOF signal). Same as /exit.

Shift + Tab

Auto-accept all pending edits. Cycles permission modes: default → acceptEdits → plan.

Power
Tab

Accept current autocomplete suggestion in the input prompt.

Esc

Return to normal mode (vim) or dismiss autocomplete.

Esc + Esc

Enter rewind mode. Pick a past checkpoint to restore — rolls back conversation AND file changes.

Power
↑ / ↓

Navigate through prompt history.

Ctrl + L

Clear the terminal screen.

Ctrl + A

Move cursor to beginning of the current input line.

Ctrl + E

Move cursor to end of the current input line.

Ctrl + K

Cut text from cursor to end of line. Ctrl+Y to paste back.

Ctrl + U

Cut text from cursor to start of line. Quick way to clear input.

Ctrl + W

Delete the word before the cursor.

Ctrl + Y

Paste the last cut text back. Works with Ctrl+K and Ctrl+U cuts.

Ctrl + T

Toggle the background task list panel.

Ctrl + O

Toggle verbose transcript — shows all tool calls and their full inputs/outputs.

Ctrl + G

Open the current prompt in your $EDITOR for multi-line editing.

Power
Ctrl + B

Background the current running task. Continue chatting while the previous task runs.

Meta + O

Toggle fast mode. Alt+O on Windows/Linux. Same as /fast.

⌘ + T / Meta + T

Toggle extended thinking mode. ⌘+T on macOS, Meta+T on Linux/Windows.

macOS
⌘ + P / Meta + P

Open the inline model picker. Quickly switch between Opus, Sonnet, and Haiku.

macOS
⌥ ← / ⌥ →

Jump word by word. Alt+←/→ on Windows/Linux.

macOS
\ + Enter

Insert a newline without submitting. Write multi-line prompts.

Space (hold)

In voice mode: hold Space to record, release to transcribe and send.

Ctrl + S

Stash the current prompt draft without sending. Retrieve it later in the same session.

Ctrl + R

Incremental reverse history search. Requires shell integration.

Special Prefixes 3
! <command>

Run a shell command directly. Output appears in conversation so Claude can read it.

! git status! npm run testPower
# <note>

Add a note directly to Claude's memory. Persists across sessions.

# always use TypeScript strict mode# project uses Tailwind v4, not v3Power
@ <filepath>

Reference a file in your message. Claude reads and includes file content in context.

Review @src/auth.ts for security issuesPower
Prompt Patterns 18
Think step by step

Forces structured reasoning. Dramatically improves accuracy on complex problems.

Don't ask — just do it

Stops Claude asking clarifying questions. Use when you want immediate action.

Don't ask clarifying questions — just do your best with what you have
Minimal changes only

Prevents over-engineering. Critical when you want surgical fixes, not rewrites.

Make only the minimal changes needed to fix this. Don't refactor anything else.
ultrathink

Triggers maximum reasoning budget. Use for hardest problems. Also: "think hard", "think harder", "think very hard".

ultrathink about the architecture for this systemPower
No yapping / Be concise

Eliminates unnecessary explanation. Use when you want the answer, not the commentary.

Be concise. No preamble, no trailing summary. Just the code/answer.
Read before editing

Ensures Claude reads full context before touching anything. Avoids half-baked edits.

Read the full file before making any changes.
Act as [role]

Assigns an expert persona. Changes tone, depth, and focus of response.

Act as a senior security engineer reviewing this code for vulnerabilities.
Output as [format]

Specify the exact output format. Eliminates guessing and post-processing.

Output the result as a JSON array. No explanation, just the JSON.
Use a todo list

Forces structured task decomposition. Great for complex multi-file changes.

Use a todo list to track each step. Check off tasks as you complete them.
Commit after each step

Creates git checkpoints throughout the task. Lets you review or roll back incremental changes.

Commit your changes after completing each task step with a descriptive message.
Write tests first (TDD)

Enforces test-driven development. Ensures correctness from the start.

Write the failing tests first, then implement the code to make them pass.
ELI5

Explain this like I'm a complete beginner. Great for unfamiliar codebases.

Explain this like I'm a complete beginner, use simple analogies.
What's wrong with this?

Triggers critical analysis. Ask Claude to critique before fixing.

What's wrong with this code? Be critical and thorough. Don't suggest fixes yet.
Continue

Resume a cut-off response. Claude picks up exactly where it stopped.

List pros & cons

Forces balanced analysis before a recommendation.

List the pros and cons of each approach before recommending one.
Rubber duck me

Claude asks questions to help you think through the problem yourself.

Help me think through this problem out loud. Ask me clarifying questions.
Security audit

Full security audit. Checks for OWASP top 10, injection, auth, data exposure.

Perform a security audit of this code. Check for OWASP top 10 vulnerabilities.
Optimize for performance

Analyse for performance bottlenecks with estimated impact per fix.

Analyse this code for performance bottlenecks. Suggest specific optimizations with estimated impact.

No commands found for ""