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
/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
/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
/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
/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
/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
! 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
/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
/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.
| Command | Description |
|---|---|
/clear | Clear 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 |
/exit | Exit 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.
| Command | Description |
|---|---|
/cost | Show 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 |
/usage | Show plan usage limits and rate limit status |
/extra-usage | Configure 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.
| Command | Description |
|---|---|
/diff | Interactive diff viewer (git diff + per-turn diffs) |
/rewind | Rewind conversation and code to a previous point. Alias: /checkpoint |
/security-review | Analyze current branch changes for security vulnerabilities |
/copy | Copy last assistant response to clipboard with code block picker |
/plan | Enter Plan Mode directly from the prompt |
Project Settings
Project initialization, configuration, and permission management.
| Command | Description |
|---|---|
/init | Initialize project with CLAUDE.md guide |
/memory | Edit CLAUDE.md memory files and auto-memory settings |
/config | Open Settings UI (Config tab). Alias: /settings |
/permissions | View or update permissions. Alias: /allowed-tools |
/hooks | Manage hook configurations for tool events |
/agents | Manage subagent configurations |
/plugin | Manage Claude Code plugins |
/reload-plugins | Reload all active plugins without restarting |
/skills | List available skills |
/keybindings | Open 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.
| Command | Description |
|---|---|
/mcp | Manage MCP server connections and OAuth authentication |
/ide | Manage IDE integrations and show status |
/chrome | Configure Chrome integration (web automation and testing) |
/remote-control | Enable remote control from claude.ai. Alias: /rc |
/remote-env | Configure default remote environment for teleport sessions |
/pr-comments [PR] | Fetch and display GitHub PR comments. Requires gh CLI |
/install-github-app | Set up Claude GitHub Actions app for a repository |
/install-slack-app | Install the Claude Slack app |
Keyboard Shortcuts
Some keys differ by OS and terminal. Switch tabs to see your platform.
General Controls (Windows / WSL)
| Shortcut | Description |
|---|---|
Ctrl+C | Cancel current input or generation |
Ctrl+D | Exit Claude Code session |
Ctrl+L | Clear terminal screen (keeps conversation history) |
Ctrl+G | Open in default text editor |
Ctrl+O | Toggle verbose output |
Ctrl+R | Reverse search command history |
Ctrl+B | Background running tasks (tmux users press twice) |
Ctrl+T | Toggle task list visibility |
Ctrl+F | Kill all background agents (press twice within 3 seconds) |
Alt+V | Paste image from clipboard |
Shift+Tab / Alt+M | Toggle permission modes |
Alt+P | Switch model |
Alt+T | Toggle extended thinking (run /terminal-setup first) |
Esc + Esc | Rewind 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)
| Shortcut | Description |
|---|---|
Ctrl+K | Delete to end of line |
Ctrl+U | Delete entire line |
Ctrl+Y | Paste deleted text |
Alt+Y (after Ctrl+Y) | Cycle paste history |
Alt+B | Move cursor back one word |
Alt+F | Move cursor forward one word |
Multiline Input (Windows / WSL)
| Method | Shortcut | Notes |
|---|---|---|
| Quick escape | \ + Enter | Works in all terminals |
| Shift+Enter | Shift+Enter | Works in WezTerm, Ghostty, Kitty |
| Control sequence | Ctrl+J | Line feed character |
| Paste mode | Paste directly | For 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:
# 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
| Flag | Description | Example |
|---|---|---|
--model | Set model (sonnet, opus, or full model name) | claude --model opus |
--print, -p | Print response without interactive mode | claude -p "explain this" |
--continue, -c | Continue most recent conversation | claude -c |
--resume, -r | Resume session by ID or name | claude -r "auth-refactor" |
--worktree, -w | Start in isolated git worktree | claude -w feature-auth |
--allowedTools | Tools that run without permission prompts | --allowedTools "Bash(git log *)" "Read" |
--append-system-prompt | Add instructions to default prompt | --append-system-prompt "Use TypeScript" |
Automation & SDK Flags
| Flag | Description |
|---|---|
--output-format | Output format (text, json, stream-json). Essential for scripting |
--input-format | Input format (text, stream-json) |
--json-schema | Get validated JSON output matching a schema (print mode only) |
--max-turns | Limit agent turns (print mode only) |
--max-budget-usd | Maximum API spend (print mode only) |
--fallback-model | Auto-fallback when default model is overloaded (print mode only) |
--no-session-persistence | Disable session saving (print mode only) |
--include-partial-messages | Include partial streaming events in output |
Security & Permission Flags
| Flag | Description |
|---|---|
--permission-mode | Start in specified permission mode |
--dangerously-skip-permissions | Skip all permission prompts (use with caution) |
--allow-dangerously-skip-permissions | Enable permission bypassing as an option |
--permission-prompt-tool | MCP tool to handle permission prompts in non-interactive mode |
--sandbox | Toggle sandbox mode |
--tools | Restrict available tools ("" to disable all, "default" for all) |
--disallowedTools | Remove tools from model context |
Prompt & Configuration Flags
| Flag | Description |
|---|---|
--system-prompt | Replace entire system prompt |
--system-prompt-file | Load system prompt from file (replaces default) |
--append-system-prompt | Append to default prompt (recommended) |
--append-system-prompt-file | Append file contents to default prompt |
--agent | Specify agent for current session |
--agents | Define custom subagents dynamically via JSON |
--settings | Load settings from JSON file or string |
--setting-sources | Comma-separated setting sources (user, project, local) |
--mcp-config | Load MCP servers from JSON files |
--strict-mcp-config | Only use MCP servers from --mcp-config |
Other Flags
| Flag | Description |
|---|---|
--add-dir | Add additional working directories |
--chrome / --no-chrome | Enable or disable Chrome integration |
--debug | Debug mode (category filter: "api,hooks") |
--disable-slash-commands | Disable all skills and commands |
--fork-session | Create new session ID when resuming |
--from-pr | Resume sessions linked to a GitHub PR |
--ide | Auto-connect to IDE if exactly one is available |
--init / --init-only | Run initialization hooks (--init-only exits without session) |
--maintenance | Run maintenance hooks and exit |
--plugin-dir | Load plugins from directories for this session |
--remote | Create a web session on claude.ai |
--session-id | Use specific session ID (UUID format) |
--teammate-mode | Agent team display (auto, in-process, tmux) |
--teleport | Resume web session in local terminal |
--betas | Include beta headers in API requests |
--verbose | Enable verbose logging |
--version, -v | Show 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.
| Command | Aliases | Description |
|---|---|---|
/add-dir <path> | — | Add working directory to current session |
/agents | — | Manage subagent configurations |
/btw <question> | — | Side question without adding to conversation. Works while Claude is busy |
/chrome | — | Configure Chrome integration |
/clear | /reset, /new | Clear conversation history and free context |
/compact [instructions] | — | Compress conversation with optional focus |
/config | /settings | Open Settings UI (Config tab) |
/context | — | Visualize context usage as colored grid |
/copy | — | Copy last response to clipboard |
/cost | — | Show token usage statistics |
/desktop | /app | Continue session in Desktop app (macOS/Windows only) |
/diff | — | Open interactive diff viewer |
/doctor | — | Diagnose installation and settings |
/exit | /quit | Exit the CLI |
/export [filename] | — | Export conversation as plain text |
/extra-usage | — | Configure extra usage for rate limits |
/fast [on|off] | — | Toggle fast mode |
/feedback [report] | /bug | Submit feedback |
/fork [name] | — | Fork conversation at current point |
/help | — | Show help and available commands |
/hooks | — | Manage hook configurations for tool events |
/ide | — | Manage IDE integrations and status |
/init | — | Initialize project with CLAUDE.md |
/insights | — | Generate session analysis report |
/install-github-app | — | Set up Claude GitHub Actions app |
/install-slack-app | — | Install Claude Slack app |
/keybindings | — | Open or create keybindings config file |
/login | — | Sign in to Anthropic account |
/logout | — | Sign out |
/mcp | — | Manage MCP server connections and OAuth |
/memory | — | Edit CLAUDE.md files and auto-memory settings |
/mobile | /ios, /android | Show 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) |
/passes | — | Share free week with friends (eligible accounts only) |
/permissions | /allowed-tools | View or update permissions |
/plan | — | Enter Plan Mode directly |
/plugin | — | Manage plugins |
/pr-comments [PR] | — | Fetch and display GitHub PR comments |
/privacy-settings | — | View/update privacy settings (Pro/Max only) |
/release-notes | — | View full changelog |
/reload-plugins | — | Reload all active plugins without restarting |
/remote-control | /rc | Enable remote control from claude.ai |
/remote-env | — | Configure default remote environment for teleport |
/rename [name] | — | Rename session (omit for auto-generation) |
/resume [session] | /continue | Resume session by ID or name |
/review | — | Deprecated. Use code-review plugin |
/rewind | /checkpoint | Rewind conversation and code to previous point |
/sandbox | — | Toggle sandbox mode (supported platforms only) |
/security-review | — | Analyze branch changes for security vulnerabilities |
/skills | — | List available skills |
/stats | — | Visualize daily usage, sessions, and streaks |
/status | — | Show version, model, account, and connectivity |
/statusline | — | Configure status line |
/stickers | — | Order Claude Code stickers |
/tasks | — | List and manage background tasks |
/terminal-setup | — | Configure terminal keybindings (Shift+Enter etc.) |
/theme | — | Change color theme |
/upgrade | — | Open upgrade page (Pro/Max only) |
/usage | — | Show plan usage and rate limits |
/vim | — | Toggle 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