32blogby StudioMitsu

Claude Code Commands Cheat Sheet — Full Reference

Every Claude Code slash command, CLI flag, and keyboard shortcut organized by real-world usage frequency. 50+ commands covered with official documentation as the sole source.

20 min read
On this page

This article covers every Claude Code command, shortcut, and CLI flag — organized by how often you actually use them. Everything here is sourced from official Anthropic documentation and verified against v2.1.72 (March 2026).

Top 10 Commands You'll Use Every Day

These are the commands I reach for daily. Learn these ten and you can handle most workflows.

1. /compact — Compress Context

bash
/compact
/compact Focus on TypeScript type definitions

Compresses the conversation when the context window gets long. You can optionally tell it what to focus on. Essential for long sessions and directly reduces token consumption.

When to use it? After 30+ minutes in a session, or as soon as you see the "context is getting large" warning. During a refactor, try /compact Focus on the auth module and current test failures to keep the most relevant context after compression.

2. /model — Switch Models

bash
/model sonnet
/model opus

Switch between models based on the task — Sonnet for research, Opus for writing and complex reasoning. In the selection screen, use left/right arrow keys to adjust the effort level (thinking depth). Changes take effect immediately without interrupting the current response.

In practice: Use Sonnet for file exploration and grep searches, then switch to Opus for architectural decisions and code implementation. The Alt+P shortcut lets you switch models without clearing your current prompt — useful when you start typing and realize you need a more capable model.

3. /cost — Check Token Usage

bash
/cost
/stats

/cost shows API token consumption for the current session. However, Pro/Max subscribers won't see /cost — it's designed for API users. If you're on a Pro plan, use /stats instead to view daily usage, session history, and streaks.

Build the habit: Check your token usage before ending every session. API users use /cost, Pro users use /stats. Once you know "this task used X resources," you can make better decisions next time — like "this part could have been done with Sonnet instead of Opus."

4. /diff — Review Changes

bash
/diff

Opens an interactive diff viewer. Use left/right arrows to switch between git diff and individual Claude turn diffs, and up/down to browse files. Essential before committing.

Best practice: After asking Claude to refactor a module, run /diff before committing. Switch to "per-turn diffs" to see what changed at each step — this makes it easy to spot unintended modifications that can slip through in large refactors.

5. /clear — Reset Context

bash
/clear

Clears conversation history and frees context. Also available as /reset or /new. Use it at task boundaries to save tokens for the next task.

/compact vs /clear: /compact summarizes and keeps context (maintains awareness). /clear is a hard reset (fresh start). Use /clear when switching to a completely different task in the same project. Use /compact when continuing the same task but the context is getting heavy.

6. Shift+Tab — Toggle Permission Modes

Press Shift+Tab to cycle through Auto-Accept Mode, Plan Mode, and normal mode.

  • Normal mode: Asks for confirmation before every tool execution
  • Auto-Accept: Runs all tools without confirmation (for trusted tasks)
  • Plan Mode: Read-only access. Code changes are proposed as plans and require approval before execution

Alt+M does the same thing.

Practical workflow: Keep Auto-Accept on for writing tests or generating boilerplate. Switch to Plan Mode when touching production-critical files (deployment configs, package.json, DB migrations). The "show plan first → approve → execute" flow prevents accidents.

7. ! — Bash Mode

bash
! npm test
! git status
! ls -la

Prefix input with ! to run bash commands directly. Executes without Claude's interpretation, and the output is added to conversation context. Press Tab to autocomplete from previous ! commands.

Why it's useful: Running git status through Claude means it interprets → executes → explains — three steps. ! git status runs directly and the output just enters the context. Use it when you want Claude to see the output but don't need it to interpret the command itself.

8. /resume — Resume Sessions

bash
/resume
/resume auth-refactor

Resume a past session by ID or name. Without arguments, opens a session picker. Alias: /continue. From the CLI, use claude -c (most recent) or claude -r "name".

Example workflow: Pause feature development to handle a hotfix. After the fix, /resume to open the picker and jump back to the dev session. Name your sessions with /rename auth-refactor so they're easy to find later.

9. /memory — Manage CLAUDE.md

bash
/memory

Edit CLAUDE.md memory files, enable or disable auto-memory. The core feature for maintaining project rules and context across sessions.

What to put in it? Rules like "use Vitest for tests," "CSS with Tailwind v4," "validate API responses with Zod." Any project-specific tech stack choices or coding conventions that you'd otherwise repeat every session.

10. @ — File Path Completion

Type @ during input to trigger file path autocomplete. Useful when referencing specific files in your questions.

Example: @src/components/Header.tsx Fix the responsive layout — Claude knows exactly which file to look at without searching. Saves tokens and gets faster results.

Session Management

Commands for starting, ending, resuming, and branching sessions. These become essential when you're juggling multiple tasks in parallel.

CommandDescription
/clearClear conversation and free context. Aliases: /reset, /new
/resume [session]Resume by ID or name. Alias: /continue
/fork [name]Create a fork of the conversation at this point
/rename [name]Rename the session. Omit the name for auto-generation
/export [filename]Export conversation as plain text
/exitExit the CLI. Alias: /quit

Cost & Performance Management

Commands for token consumption and model configuration. Mastering these six commands is the single most important thing for keeping your Claude Code bill under control.

CommandDescription
/costShow token usage statistics
/compact [instructions]Compress conversation with optional focus instructions
/model [model]Select or change model. Left/right arrows adjust effort level
/fast [on|off]Toggle fast mode. Same Opus 4.6 model with faster output
/usageShow plan usage limits and rate limit status
/extra-usageConfigure extra usage when rate limits are hit

Code Operations & Review

Reviewing changes, rewinding, and security checking. Always review before committing — especially after asking Claude to make large-scale changes.

CommandDescription
/diffInteractive diff viewer (git diff + per-turn diffs)
/rewindRewind conversation and code to a previous point. Alias: /checkpoint
/security-reviewAnalyze current branch changes for security vulnerabilities
/copyCopy last assistant response to clipboard with code block picker
/planEnter Plan Mode directly from the prompt

Project Settings

Project initialization, configuration, and permission management.

CommandDescription
/initInitialize project with CLAUDE.md guide
/memoryEdit CLAUDE.md memory files and auto-memory settings
/configOpen Settings UI (Config tab). Alias: /settings
/permissionsView or update permissions. Alias: /allowed-tools
/hooksManage hook configurations for tool events
/agentsManage subagent configurations
/pluginManage Claude Code plugins
/reload-pluginsReload all active plugins without restarting
/skillsList available skills
/keybindingsOpen or create keybindings configuration file

External Integrations

IDE, browser, GitHub, and remote session integrations. The /remote-control feature is particularly interesting — it lets you control your local Claude Code from claude.ai, meaning you can direct work from your phone while away from your desk.

CommandDescription
/mcpManage MCP server connections and OAuth authentication
/ideManage IDE integrations and show status
/chromeConfigure Chrome integration (web automation and testing)
/remote-controlEnable remote control from claude.ai. Alias: /rc
/remote-envConfigure default remote environment for teleport sessions
/pr-comments [PR]Fetch and display GitHub PR comments. Requires gh CLI
/install-github-appSet up Claude GitHub Actions app for a repository
/install-slack-appInstall the Claude Slack app

Keyboard Shortcuts

Some keys differ by OS and terminal. Switch tabs to see your platform.

General Controls (Windows / WSL)

ShortcutDescription
Ctrl+CCancel current input or generation
Ctrl+DExit Claude Code session
Ctrl+LClear terminal screen (keeps conversation history)
Ctrl+GOpen in default text editor
Ctrl+OToggle verbose output
Ctrl+RReverse search command history
Ctrl+BBackground running tasks (tmux users press twice)
Ctrl+TToggle task list visibility
Ctrl+FKill all background agents (press twice within 3 seconds)
Alt+VPaste image from clipboard
Shift+Tab / Alt+MToggle permission modes
Alt+PSwitch model
Alt+TToggle extended thinking (run /terminal-setup first)
Esc + EscRewind or summarize
/ Navigate command history
/ Cycle through dialog tabs

WSL users: In Windows Terminal, Shift+Enter may not work out of the box. Run /terminal-setup to install the keybinding. When using @ for file paths, use WSL paths like /mnt/c/....

Text Editing (Windows / WSL)

ShortcutDescription
Ctrl+KDelete to end of line
Ctrl+UDelete entire line
Ctrl+YPaste deleted text
Alt+Y (after Ctrl+Y)Cycle paste history
Alt+BMove cursor back one word
Alt+FMove cursor forward one word

Multiline Input (Windows / WSL)

MethodShortcutNotes
Quick escape\ + EnterWorks in all terminals
Shift+EnterShift+EnterWorks in WezTerm, Ghostty, Kitty
Control sequenceCtrl+JLine feed character
Paste modePaste directlyFor code blocks and logs

For Windows Terminal, VS Code, and others, run /terminal-setup to install the Shift+Enter binding.

CLI Flags

Flags you can specify when launching Claude Code. Especially important for scripting and automation.

Common use cases:

bash
# Get a repo overview in one command and save to file
claude -p "Explain this repository's structure" > repo-overview.txt

# Work in an isolated git worktree without affecting your main branch
claude -w experimental-feature

# Automate code review in CI/CD
claude -p --output-format json --max-turns 5 "Review this PR"

# Allow only read-only tools for safe automated analysis
claude -p --allowedTools "Read" "Grep" "Glob" "Find issues in this code"

Commonly Used Flags

FlagDescriptionExample
--modelSet model (sonnet, opus, or full model name)claude --model opus
--print, -pPrint response without interactive modeclaude -p "explain this"
--continue, -cContinue most recent conversationclaude -c
--resume, -rResume session by ID or nameclaude -r "auth-refactor"
--worktree, -wStart in isolated git worktreeclaude -w feature-auth
--allowedToolsTools that run without permission prompts--allowedTools "Bash(git log *)" "Read"
--append-system-promptAdd instructions to default prompt--append-system-prompt "Use TypeScript"

Automation & SDK Flags

FlagDescription
--output-formatOutput format (text, json, stream-json). Essential for scripting
--input-formatInput format (text, stream-json)
--json-schemaGet validated JSON output matching a schema (print mode only)
--max-turnsLimit agent turns (print mode only)
--max-budget-usdMaximum API spend (print mode only)
--fallback-modelAuto-fallback when default model is overloaded (print mode only)
--no-session-persistenceDisable session saving (print mode only)
--include-partial-messagesInclude partial streaming events in output

Security & Permission Flags

FlagDescription
--permission-modeStart in specified permission mode
--dangerously-skip-permissionsSkip all permission prompts (use with caution)
--allow-dangerously-skip-permissionsEnable permission bypassing as an option
--permission-prompt-toolMCP tool to handle permission prompts in non-interactive mode
--sandboxToggle sandbox mode
--toolsRestrict available tools ("" to disable all, "default" for all)
--disallowedToolsRemove tools from model context

Prompt & Configuration Flags

FlagDescription
--system-promptReplace entire system prompt
--system-prompt-fileLoad system prompt from file (replaces default)
--append-system-promptAppend to default prompt (recommended)
--append-system-prompt-fileAppend file contents to default prompt
--agentSpecify agent for current session
--agentsDefine custom subagents dynamically via JSON
--settingsLoad settings from JSON file or string
--setting-sourcesComma-separated setting sources (user, project, local)
--mcp-configLoad MCP servers from JSON files
--strict-mcp-configOnly use MCP servers from --mcp-config

Other Flags

FlagDescription
--add-dirAdd additional working directories
--chrome / --no-chromeEnable or disable Chrome integration
--debugDebug mode (category filter: "api,hooks")
--disable-slash-commandsDisable all skills and commands
--fork-sessionCreate new session ID when resuming
--from-prResume sessions linked to a GitHub PR
--ideAuto-connect to IDE if exactly one is available
--init / --init-onlyRun initialization hooks (--init-only exits without session)
--maintenanceRun maintenance hooks and exit
--plugin-dirLoad plugins from directories for this session
--remoteCreate a web session on claude.ai
--session-idUse specific session ID (UUID format)
--teammate-modeAgent team display (auto, in-process, tmux)
--teleportResume web session in local terminal
--betasInclude beta headers in API requests
--verboseEnable verbose logging
--version, -vShow version number

Full Command Reference

Alphabetical list of every slash command available in Claude Code. Some commands may not be visible depending on your plan, platform, or environment.

CommandAliasesDescription
/add-dir <path>Add working directory to current session
/agentsManage subagent configurations
/btw <question>Side question without adding to conversation. Works while Claude is busy
/chromeConfigure Chrome integration
/clear/reset, /newClear conversation history and free context
/compact [instructions]Compress conversation with optional focus
/config/settingsOpen Settings UI (Config tab)
/contextVisualize context usage as colored grid
/copyCopy last response to clipboard
/costShow token usage statistics
/desktop/appContinue session in Desktop app (macOS/Windows only)
/diffOpen interactive diff viewer
/doctorDiagnose installation and settings
/exit/quitExit the CLI
/export [filename]Export conversation as plain text
/extra-usageConfigure extra usage for rate limits
/fast [on|off]Toggle fast mode
/feedback [report]/bugSubmit feedback
/fork [name]Fork conversation at current point
/helpShow help and available commands
/hooksManage hook configurations for tool events
/ideManage IDE integrations and status
/initInitialize project with CLAUDE.md
/insightsGenerate session analysis report
/install-github-appSet up Claude GitHub Actions app
/install-slack-appInstall Claude Slack app
/keybindingsOpen or create keybindings config file
/loginSign in to Anthropic account
/logoutSign out
/mcpManage MCP server connections and OAuth
/memoryEdit CLAUDE.md files and auto-memory settings
/mobile/ios, /androidShow QR code for mobile app download
/model [model]Select or change model. Arrows adjust effort level
/output-style [style]Switch output style (Default/Explanatory/Learning)
/passesShare free week with friends (eligible accounts only)
/permissions/allowed-toolsView or update permissions
/planEnter Plan Mode directly
/pluginManage plugins
/pr-comments [PR]Fetch and display GitHub PR comments
/privacy-settingsView/update privacy settings (Pro/Max only)
/release-notesView full changelog
/reload-pluginsReload all active plugins without restarting
/remote-control/rcEnable remote control from claude.ai
/remote-envConfigure default remote environment for teleport
/rename [name]Rename session (omit for auto-generation)
/resume [session]/continueResume session by ID or name
/reviewDeprecated. Use code-review plugin
/rewind/checkpointRewind conversation and code to previous point
/sandboxToggle sandbox mode (supported platforms only)
/security-reviewAnalyze branch changes for security vulnerabilities
/skillsList available skills
/statsVisualize daily usage, sessions, and streaks
/statusShow version, model, account, and connectivity
/statuslineConfigure status line
/stickersOrder Claude Code stickers
/tasksList and manage background tasks
/terminal-setupConfigure terminal keybindings (Shift+Enter etc.)
/themeChange color theme
/upgradeOpen upgrade page (Pro/Max only)
/usageShow plan usage and rate limits
/vimToggle between Vim and Normal editing modes

MCP servers can expose prompts as commands in the format /mcp__<server>__<prompt>, dynamically discovered from connected servers.

Bundled skills like /simplify, /batch, and /debug also appear alongside built-in commands when you type /. You can create your own skills as well.

Wrapping Up

Claude Code has over 50 commands, but you'll use about 10 of them daily. Start with /compact, /model, and /cost to build a habit of being aware of tokens and costs.

As you get comfortable, expand to /diff for pre-commit reviews, /fork for experimental branches, and /btw for quick side questions without breaking your flow.

For CLI flags, knowing --print and --output-format json opens up shell scripting and CI/CD integration possibilities.

Official documentation: CLI Reference | Interactive Mode