← Back to Guides

Claude Code Command Reference

A practical reference for the Claude Code CLI — slash commands, keyboard shortcuts, CLAUDE.md, hooks, subagents, MCP, permission modes, and IDE integrations.

Last updated 2026-09-03
Claude Code
CLI
Slash Commands
Keyboard Shortcuts
MCP
Hooks

Claude Code Command Reference

Slash commands, keyboard shortcuts, CLAUDE.md, hooks, and integrations

2026 Edition


About this guide

Claude Code has a large and fast-moving surface area — many commands, flags, and behaviors are version-gated, and new ones ship continuously. This guide covers the commands and concepts developers reach for most often, verified directly against Anthropic's official Claude Code documentation at code.claude.com/docs. It is not exhaustive — the full command and flag list is longer than fits a practical reference. Run /help or type / in your own session to see the live, authoritative menu for your installed version, platform, and plan; press ? on an empty prompt for the current keyboard shortcut panel.

Some commands and behaviors below are marked with the Claude Code version they require, taken directly from the official docs. If a command doesn't work as described, your installed version may be older — run claude update.


Table of contents

  1. Starting a session
  2. Slash commands
  3. Keyboard shortcuts
  4. CLAUDE.md and memory
  5. Permission modes
  6. Hooks
  7. Subagents
  8. MCP servers
  9. Plan mode
  10. Headless mode and scripting
  11. IDE integrations
  12. Official resources

1. Starting a session

claude                       # Start an interactive session
claude "explain this project"  # Start with an initial prompt
claude -p "explain this function"  # Print mode: run once, then exit
claude -c                    # Continue the most recent conversation here
claude -r "session-name" "query"  # Resume a specific session by name or ID
cat error.log | claude -p "diagnose this"   # Pipe content in

2. Slash commands

Type / in Claude Code to see the commands available to you, or / followed by letters to filter. The menu lists built-in commands, bundled and user-authored skills, and commands contributed by plugins and MCP servers — not every command below is visible to every user, since some depend on platform, plan, or version.

Session and conversation

Command What it does
/clear (aliases /reset, /new) Start a new conversation with empty context; optionally pass a name to label the previous one in the /resume picker
/resume Reopen a previous session
/branch [name] Branch the conversation at this point to try a different direction, without losing the current thread
/fork [prompt] Copy the current conversation into a new background session, so it keeps running while you continue here
/compact [instructions] Summarize the conversation so far to free up context; optionally focus the summary
/context [all] Visualize current context window usage as a grid, with optimization suggestions
/exit (alias /quit) Exit the CLI

Model and effort

Command What it does
/model [model] Switch the active model (e.g. sonnet, opus, haiku, fable) and save it as your default; no argument opens a picker
/effort [level|auto|status] Set effort level: low, medium, high, xhigh, max, or auto; status prints the current level
/fast [on|off] Toggle fast mode (v2.1.205+)

Project setup and memory

Command What it does
/init Explore the codebase and generate a starting CLAUDE.md
/memory Edit CLAUDE.md files, toggle auto memory on/off, and view auto memory entries
/add-dir <path> Grant file access to an additional working directory for this session
/cd <path> Move the session to a new working directory, keeping the conversation (v2.1.169+)

Code review and quality

Command What it does
/code-review [level] [--fix] [pr#|branch|path] (alias /review) Review a diff, PR, branch, or path for correctness bugs and cleanup opportunities. Levels: low, medium, high, xhigh, max, ultra (deep cloud review). --fix applies findings; --comment posts them as inline GitHub PR comments
/simplify Review recent changes for reuse, simplification, and efficiency — quality only, not bug-hunting
/security-review Check the current diff for security vulnerabilities
/diff Open an interactive diff viewer for uncommitted changes and per-turn diffs

Permissions and configuration

Command What it does
/permissions (alias /allowed-tools) Manage allow, ask, and deny rules for tool permissions in an interactive dialog
/config [key=value ...] (alias /settings) Open the settings interface, or set a key directly, e.g. /config theme=dark (v2.1.181+)
/mcp [reconnect <server>|enable|disable] Manage MCP server connections and OAuth; no argument opens the interactive server list
/hooks View configured hooks, grouped by event (read-only — edit settings JSON to change them)
/keybindings Open your keyboard shortcuts configuration file

Planning and background work

Command What it does
/plan [description] Enter plan mode directly, optionally starting on a specific task
/background [prompt] (alias /bg) Detach the session to run as a background agent and free the terminal; monitor with claude agents
/agents Manage subagent configurations (see Subagents)
/tasks List running background shells and subagents in the current session

Other useful commands

Command What it does
/help Show help and available commands
/doctor Run a setup checkup — installation health, unused skills/MCP servers/plugins, slow hooks, available updates
/status Show account, model, working directory, and version
/usage (alias /cost) Show token usage and session cost
/copy [N] Copy the last (or Nth-latest) response to the clipboard
/export [filename] Export the conversation as plain text
/btw [question] Ask a side question using only what's already in context, without adding it to the main conversation history
/install-github-app Install the Claude GitHub App for a repository
/feedback [report] (aliases /bug, /share) Report a bug or send feedback, with a consent step before anything is sent
/login / /logout Sign in to or out of your Anthropic account

Commands only work at the start of a message. Most queue until Claude finishes its current turn; a few — including /status, /model, /effort, and /fast — apply immediately even mid-response.


3. Keyboard shortcuts

Shortcuts vary somewhat by platform and terminal. Press ? on an empty prompt to see the exact list for your environment.

General

Shortcut Action
Ctrl+C Interrupt a running operation; on an empty prompt, first press clears input, second press exits
Ctrl+D Exit Claude Code (first press shows a confirmation hint, second within 800ms confirms)
Esc Interrupt Claude mid-turn, or close an open dialog
Esc Esc With text in the prompt: clear the draft (saved to history). With an empty prompt: open the rewind menu
Shift+Tab Cycle permission modes: Manual → Accept Edits → Plan → (Auto / Bypass, where available)
Ctrl+R Reverse-search your prompt history
Ctrl+O Toggle the transcript viewer (detailed tool usage and execution)
Ctrl+L Force a full terminal redraw, keeping input and history
Ctrl+T Toggle Claude's to-do checklist (not the same as /tasks, which lists running shells/subagents)
Ctrl+B Move a running Bash command to the background (press twice in tmux)
Ctrl+Z Suspend Claude Code (Unix only; fg to resume)
Ctrl+V / Alt+V (Windows/WSL) Paste an image from the clipboard
Ctrl+G or Ctrl+X Ctrl+E Open your prompt in your default text editor
Option+P (macOS) / Alt+P Switch model without clearing the prompt
Option+T (macOS) / Alt+T Toggle extended thinking
Option+O (macOS) / Alt+O Toggle fast mode

Input and navigation

Shortcut Action
\ + Enter, or Ctrl+J Insert a newline without submitting (works in any terminal)
Shift+Enter Newline — native in iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal, Windows Terminal
Up / Down Move within multiline input, or navigate prompt history once at the first/last line
Tab Accept an autocomplete suggestion
@ Trigger file path autocomplete
! at the start of input Shell mode — run a command directly and have Claude respond to the output
/ at the start of input Open the command/skill menu

Vim editor mode

Enable via /config → Editor mode. Standard vim NORMAL-mode navigation (h/j/k/l, w/e/b, 0/$, gg/G), editing (x, dd, cc, yy, p, u), text objects (iw/aw, i"/a", i(/a(, etc.), and visual mode (v/V) are all supported. Esc or Ctrl+[ returns to NORMAL mode.


4. CLAUDE.md and memory

Claude Code has two complementary memory systems, both loaded at the start of every conversation:

CLAUDE.md files Auto memory
Who writes it You Claude
Contains Instructions and rules Learnings and patterns
Scope Project, user, or org Per repository, shared across worktrees
Use for Coding standards, workflows, architecture Your preferences, corrections, context Claude can't derive from code

Both are context, not enforced configuration — Claude tries to follow them but there's no hard guarantee. For a rule that must always apply regardless of what Claude decides, use a PreToolUse hook instead.

CLAUDE.md locations, in load order

Scope Location Shared with
Managed policy /Library/Application Support/ClaudeCode/CLAUDE.md (macOS) · /etc/claude-code/CLAUDE.md (Linux/WSL) · C:\Program Files\ClaudeCode\CLAUDE.md (Windows) Everyone on the machine
User ~/.claude/CLAUDE.md Just you, all projects
Project ./CLAUDE.md or ./.claude/CLAUDE.md Team, via source control
Local ./CLAUDE.local.md Just you, this project (add to .gitignore)

Run /init to generate a starting CLAUDE.md from the codebase. If one already exists, /init suggests improvements instead of overwriting it.

Guidance from the official docs: keep each file under ~200 lines — longer files consume more context and reduce adherence. Use markdown headers and bullets. Write specific, verifiable instructions ("Use 2-space indentation," "Run npm test before committing") rather than vague ones ("Format code properly"). For large projects, split instructions into .claude/rules/*.md, optionally scoped to specific file paths via paths: frontmatter.

Auto memory

On by default. Claude saves four kinds of notes to ~/.claude/projects/<project>/memory/: user (your role/preferences), feedback (corrections you've given), project (ongoing context not derivable from code), and reference (where to find external information). A MEMORY.md index (first 200 lines / 25KB) loads every session; individual topic files load on demand. Toggle it from /memory, or set autoMemoryEnabled: false in settings.


5. Permission modes

A permission mode controls whether Claude asks before acting. Switch with Shift+Tab in the CLI.

Mode What runs without asking Best for
default (labeled Manual) Reads only Reviewing every action yourself, sensitive work
acceptEdits Reads, file edits, and common filesystem commands (mkdir, mv, cp, etc.) Iterating on code you're actively reviewing
plan Reads, plus classifier-approved commands when auto mode is available Exploring a codebase before changing it
auto Everything, with background safety checks from a second "classifier" model Long tasks, reducing prompt fatigue
dontAsk Only pre-approved tools Locked-down CI and scripts
bypassPermissions Everything Isolated containers/VMs only

On Pro, Max, and Team plans, sessions start in auto mode by default. Deny rules (set via /permissions or permissions.deny in settings) block an action in every mode, including bypassPermissions.

Set a mode for a session with claude --permission-mode <mode>, or skip prompts entirely (dangerous, isolation-only) with --dangerously-skip-permissions.


6. Hooks

Hooks are user-defined shell commands that Claude Code runs automatically at specific points in its lifecycle — giving you deterministic control instead of relying on Claude choosing to do something.

Common hook events: SessionStart, UserPromptSubmit, PreToolUse, PostToolUse, Notification, Stop. See the Hooks reference for the complete list and JSON schemas.

Example — desktop notification whenever Claude needs your input, added to ~/.claude/settings.json:

{
  "hooks": {
    "Notification": [
      {
        "matcher": "",
        "hooks": [
          {
            "type": "command",
            "command": "osascript -e 'display notification \"Claude Code needs your attention\" with title \"Claude Code\"'"
          }
        ]
      }
    ]
  }
}

Run /hooks to browse everything currently configured (read-only — edit the settings JSON, or ask Claude to edit it, to make changes).


7. Subagents

Subagents are specialized assistants that handle a task in an isolated context window — useful when a side task would otherwise flood your main conversation with search results, logs, or file contents you won't need again.

Defining one — a Markdown file with YAML frontmatter in .claude/agents/ (project) or ~/.claude/agents/ (user):

---
name: code-improver
description: Scans files and suggests improvements for readability, performance, and best practices
tools: Read, Grep, Glob
model: sonnet
---

You are a code improvement specialist. For each issue you find, explain
the problem, show the current code, and provide an improved version.

Required fields are name and description; common optional fields include tools, model, permissionMode, and memory (for persistent, cross-session subagent memory).

Invoking one, in order of flexibility to rigidity:

  1. Natural language — describe the task and let Claude decide to delegate: "Use the code-improver agent to suggest improvements in this project."
  2. @-mention — force it: @code-improver look at the auth module.
  3. Session-wideclaude --agent code-improver, or "agent": "code-improver" in settings.

8. MCP servers

The Model Context Protocol (MCP) connects Claude Code to external tools, databases, and APIs.

# Remote HTTP server (recommended for hosted services)
claude mcp add --transport http notion https://mcp.notion.com/mcp \
  --header "Authorization: Bearer your-token"

# Local stdio server
claude mcp add --transport stdio db -- npx -y @bytebase/dbhub --dsn "postgresql://..."

# Manage
claude mcp list
claude mcp get notion
claude mcp remove notion

Scopes:

Scope Loads in Shared Stored in
Local (default) Current project only No ~/.claude.json
Project Current project only Yes, via git .mcp.json
User All your projects No ~/.claude.json

Project-scoped servers live in .mcp.json at the repo root and support ${VAR} / ${VAR:-default} environment variable expansion in command, args, env, url, and headers. Inside a session, /mcp shows connection status and lets you reconnect or toggle servers.


9. Plan mode

Plan mode is a read-only exploration mode: Claude can inspect files and run read-only commands without asking permission, then presents a plan before making any changes. You review, ask questions, or request revisions before Claude switches into implementation and starts editing.

Enter it with /plan [description], or start a session directly in it with claude --permission-mode plan. Exit and approve with Shift+Tab, or via the approval step Claude Code presents once the plan is ready.


10. Headless mode and scripting

claude -p "query"                          # Run once, exit
claude -p "query" --output-format json     # Structured JSON result + usage/cost metadata
claude -p "query" --output-format stream-json  # Newline-delimited streaming tokens
claude -c -p "continue this"               # Continue the most recent conversation, non-interactively

--bare skips auto-discovery of hooks, skills, subagents, plugins, MCP, and CLAUDE.md for faster, more reproducible startup — useful in CI. --permission-mode dontAsk --allowedTools "..." is the typical shape for a fully unattended run with an explicit allowlist.


11. IDE integrations

VS Code extension: install from the VS Code Marketplace. Provides a native panel with inline diffs, plan review before auto-accept, @-mentioning files with specific line ranges from your selection, conversation history, and multiple conversation tabs. Requires VS Code 1.94.0+ and any paid Claude subscription (or a Claude Console/API account) — no separate API key needed for the subscription path.

JetBrains plugin (IntelliJ, PyCharm, WebStorm, etc.): install from the JetBrains Marketplace. Diffs open in the IDE's own diff viewer; your current editor selection is shared with Claude automatically (unless blocked by a read rule); IDE inspection diagnostics are available to Claude via the bundled MCP integration.

Chrome extension: automates a Chrome session for web-based tasks — clicking, filling forms, reading console output, and navigating — inside your existing browser session, with site-level permissions required before it acts.


12. Official resources

Topic URL
Documentation home https://code.claude.com/docs/en
CLI reference https://code.claude.com/docs/en/cli-reference
Interactive mode / keyboard shortcuts https://code.claude.com/docs/en/interactive-mode
Slash commands https://code.claude.com/docs/en/commands
Memory (CLAUDE.md, auto memory) https://code.claude.com/docs/en/memory
Permission modes https://code.claude.com/docs/en/permission-modes
Hooks guide https://code.claude.com/docs/en/hooks-guide
Subagents https://code.claude.com/docs/en/sub-agents
MCP https://code.claude.com/docs/en/mcp
VS Code extension https://code.claude.com/docs/en/vs-code
Claude Code cheatsheet (Anthropic Help Center) https://support.claude.com/en/articles/14553413-claude-code-cheatsheet
Claude Code power user tips (Anthropic Help Center) https://support.claude.com/en/articles/14554000-claude-code-power-user-tips

Final accuracy note

This guide was verified directly against Anthropic's official Claude Code documentation at code.claude.com/docs as of September 3, 2026, and is not exhaustive — Claude Code ships new commands, flags, and behaviors frequently, and some are gated to specific versions or platforms. When this document and your installed CLI differ, the live /help menu, the ? shortcut panel, and the official docs are the source of truth.


Claude Code Command Reference — 2026 Edition

Put this into practice with Prompt Architect

Turn what you just read into production-ready prompts and workflows — free for 7 days, no credit card required.

Start free trial