Full docs: docs.anthropic.com/en/docs/claude-code — complete documentation index
Keyboard Shortcuts
Essential
| Key | Action |
|---|
Enter | Send message / submit |
Esc | Interrupt / stop generation |
Esc Esc | Open rewind menu (go back in conversation or code) |
Ctrl+C | Cancel current operation (hard stop) |
Ctrl+D | Exit Claude Code |
Shift+Tab | Cycle modes: Normal → acceptEdits → Plan |
? | Show available keyboard shortcuts |
Navigation
| Key | Action |
|---|
Ctrl+R | Search command history |
Ctrl+T | Toggle task list |
Ctrl+O | Toggle verbose transcript |
Ctrl+G | Open external editor (write long prompts) |
Ctrl+V | Paste image (screenshots, diagrams) |
Alt+P / Option+P | Switch model |
Alt+T / Option+T | Toggle extended thinking |
Alt+M | Toggle permission modes |
Editing (Bash-style)
| Key | Action |
|---|
Ctrl+A / Ctrl+E | Start / end of line |
Opt+F / Opt+B | Word forward / back |
Ctrl+W | Delete previous word |
Ctrl+K | Delete to end of line |
Ctrl+U | Delete entire line |
Ctrl+Y | Paste deleted text (Alt+Y to cycle) |
Ctrl+J | Newline (control sequence alternative) |
\ + Enter | New line (without sending) |
Background Tasks
| Key | Action |
|---|
Ctrl+B | Send running task to background |
Ctrl+F | Kill all background agents (press twice confirm) |
Tip: Run /terminal-setup to enable Shift+Enter for multi-line input in iTerm2 & VS Code. Run /keybindings to customize all shortcuts.
Slash Commands
Session Control
| Command | Action |
|---|
/clear | Reset conversation history (fresh start) |
/compact [hint] | Compress context to save tokens. Optional hint for what to keep. |
/rewind | Go back in conversation AND/OR code changes |
/export [file] | Export conversation to file or clipboard |
/copy | Copy last response to clipboard |
/cost | Show session cost & token usage |
/usage | Show plan usage & rate limits |
/context | Token consumption visualization |
/stats | Visualize daily usage and streaks |
/rename [name] | Rename current session |
/resume [session] | Resume conversation by ID or name |
Configuration
| Command | Action |
|---|
/config | Open settings panel |
/model | Switch between Sonnet / Opus / Haiku |
/permissions | View & update tool permissions |
/keybindings | Open keyboard shortcuts config file |
/vim | Toggle vim mode for input |
/terminal-setup | Setup Shift+Enter for multi-line input |
/theme | Change color theme |
/status | Open Settings (Status tab) |
/statusline | Set up status line UI |
/hooks | Open interactive hooks manager |
Development
| Command | Action |
|---|
/init | Create CLAUDE.md for your project — do this first! |
/memory | View & edit CLAUDE.md project memory |
/review | Code review analysis |
/doctor | Environment diagnostics & health check |
/agents | Manage sub-agents |
/mcp | Manage MCP servers |
/plan | Enter plan mode from prompt |
/debug [description] | Troubleshoot current session |
/add-dir | Add working directory during session |
/todos | List current TODO items |
Advanced
| Command | Action |
|---|
/insights | Generate HTML usage report |
/pr_comments | View GitHub PR feedback |
/install-github-app | Setup automated PR reviews |
/tasks | Persistent task list management |
/teleport | Transfer session between web ↔ local |
/desktop | Hand off CLI session to Desktop app |
CLI Launch Flags
Starting Sessions
| Flag | Action |
|---|
claude | Start interactive session |
claude "query" | Start with an initial prompt |
claude -p "query" | Print mode — answer & exit (for scripting) |
claude -c | Continue last conversation |
claude -r "name" | Resume specific session by name or ID |
claude -w name | Start in isolated git worktree |
Model & Behavior
| Flag | Action |
|---|
--model sonnet | Use Sonnet (fast, cheap) |
--model opus | Use Opus (smartest) |
--fallback-model | Automatic fallback model |
--agent my-agent | Use a specific sub-agent |
--permission-mode plan | Start in plan mode |
--max-turns N | Limit conversation turns |
--max-budget-usd N | Set max spend limit |
--teammate-mode | Agent team display mode |
Context & Directories
| Flag | Action |
|---|
--add-dir ../path | Add extra directories to context |
--chrome | Enable browser integration |
--no-chrome | Disable Chrome integration |
--ide | Auto-connect to IDE |
--verbose | Show detailed logging |
Session Management
| Flag | Action |
|---|
--session-id | Use specific session UUID |
--fork-session | New session ID when resuming |
--from-pr | Resume sessions linked to GitHub PR |
System Prompt
| Flag | Action |
|---|
--system-prompt | Custom system prompt |
--system-prompt-file | System prompt from file |
--append-system-prompt | Append to default system prompt |
Permissions
| Flag | Action |
|---|
--allowedTools | Whitelist specific tools |
--disallowedTools | Block specific tools |
--tools "Bash,Edit" | Restrict to only these tools |
Configuration
| Flag | Action |
|---|
--init / --init-only | Run initialization hooks |
--maintenance | Run maintenance hooks |
--strict-mcp-config | Only use specified MCP servers |
--disable-slash-commands | Disable all skills |
--setting-sources | Comma-separated setting sources |
--settings | Path to settings JSON |
| Flag | Action |
|---|
--output-format text | Plain text (default) |
--output-format json | Structured JSON |
--output-format stream-json | Real-time streaming JSON |
--json-schema | Validated JSON output matching schema |
--input-format | Input format for print mode |
Tip: Pipe data in! git diff | claude -p "review this" or cat error.log | claude -p "explain"
The Big 5 — Claude Code Extension System
1. CLAUDE.md — Project Memory
| |
|---|
| What | A markdown file Claude reads every session. Your project’s “brain dump” — coding style, architecture, common commands, conventions. |
| Where | .claude/CLAUDE.md (project) or ~/.claude/CLAUDE.md (global) |
| Create | Run /init in your project — Claude generates it for you |
2. Custom Slash Commands
| |
|---|
| What | Your own /commands. Markdown files with prompts that YOU invoke. Like prompt templates. |
| Where | .claude/commands/ (project) or ~/.claude/commands/ (global) |
| Use | Filename = command name. review.md → type /project:review |
3. Skills — Auto-Invoked Knowledge
| |
|---|
| What | Like commands, but Claude decides when to use them automatically. You DON’T invoke them — Claude detects when they’re relevant. |
| Where | .claude/skills/ with a SKILL.md inside each skill folder |
| Use | Just work on your project — Claude picks up relevant skills from context |
4. Sub-Agents — Specialized Helpers
| |
|---|
| What | Separate Claude instances with their own context & role. Like team members: reviewer, debugger, architect, etc. |
| Where | .claude/agents/ (markdown files with YAML metadata) |
| Invoke | /agents to manage, or just say “Use the reviewer agent” |
| CLI | --agent my-agent or --agents '{json}' |
| |
|---|
| What | Connect Claude to external tools: GitHub, Notion, databases, APIs, browsers, etc. |
| Setup | claude mcp add <name> <command> |
| List | claude mcp list |
| Config | --mcp-config ./mcp.json at launch |
| |
|---|
| What | Bundles of commands, skills, hooks & more from the community |
| Browse | /plugin to browse, install, enable, disable |
| Dir | --plugin-dir ./my-plugins for local plugins |
How they differ:
Custom Commands → YOU invoke them vs Skills → CLAUDE invokes them vs Sub-Agents → Separate AI instances vs MCP → External tool connections
Permission Modes
| Mode | Description |
|---|
| Normal | Claude asks permission for every tool use (read, write, bash, etc.) |
| acceptEdits | Claude runs tools WITHOUT asking. Faster but less control. Good for trusted tasks. |
| Plan Mode | Claude ONLY reads & plans. Won’t write or run anything. Review first, then switch to Normal to execute. |
| dontAsk | Auto-denies permissions unless pre-approved in settings. |
| bypassPermissions | Skips all permission prompts. Requires safe/sandboxed environment. |
Cycle: Shift+Tab → Normal → acceptEdits → Plan → Normal…
Permission Rule Syntax
| Pattern | Description |
|---|
Tool(specifier) | Allow a specific tool with a specifier |
Bash(git:*) | Allow all git commands |
Bash(npm:*) | Allow all npm commands |
Edit(**/src/**) | Allow edits in src directory |
Wildcards (*) | Match any value within a specifier |
| Evaluation order | deny → ask → allow (deny wins over allow) |
Best workflow: Start in Plan Mode to explore & understand the problem. Review Claude’s plan. Switch to Normal/acceptEdits to implement.
Hooks — Event Automation
Hook Events
| Hook | Description |
|---|
PreToolUse | Runs BEFORE Claude uses a tool — validate, block, or modify |
PostToolUse | Runs AFTER a tool — check results, auto-format, lint |
PostToolUseFailure | After a tool call fails |
UserPromptSubmit | Before your message is processed |
PermissionRequest | When permission dialog appears |
Stop | When Claude finishes its response |
SessionStart | When a session begins |
SessionEnd | When a session ends |
PreCompact | Before context compression |
Notification | When Claude sends a notification |
SubagentStart | When a subagent starts |
SubagentStop | When a subagent stops |
TeammateIdle | Agent team teammate about to go idle |
TaskCompleted | When a task is marked as completed |
ConfigChange | Config file changes during session |
WorktreeCreate | When a worktree is created |
WorktreeRemove | When a worktree is removed |
Handler Types
| Type | Description |
|---|
command | Run a shell command |
http | POST to an HTTP endpoint |
prompt | Single-turn Claude evaluation |
agent | Subagent with tools for verification |
Example: Auto-run prettier after every file edit, or block writes to .env files. Configure in your settings JSON.
| Feature | Description |
|---|
@ mention | Type @ to reference files & folders. Claude reads them into context. |
! prefix | Type ! to run shell commands inline. E.g., ! git status |
| Paste images | Ctrl+V to paste screenshots, diagrams, error images directly |
| Pipe input | cat file.py | claude -p "explain" — feed data directly |
| Multi-dir | claude --add-dir ../api ../web — work across multiple projects |
| Worktrees | claude -w feature — isolated git branch + Claude session |
Pro tip: Use @ references instead of copy-pasting file contents. It’s smarter with context and uses fewer tokens.
Configuration
Settings Priority (highest → lowest)
| Level | Location |
|---|
| Enterprise | /etc/claude-code/managed-settings.json |
| Project Local | .claude/settings.local.json (your personal project settings) |
| Project Shared | .claude/settings.json (committed to git, shared with team) |
| User Global | ~/.claude/settings.json (your defaults) |
Config CLI
| Command | Action |
|---|
claude config list | Show all settings |
claude config get key | Check a value |
claude config set key value | Change a value |
claude config add key value | Add to array |
Permissions example: Allow git commands without asking: add "Bash(git:*)" to your allowedTools in settings.
File Structure Map
Project Level (.claude/)
| File/Dir | Purpose |
|---|
CLAUDE.md | Project memory — conventions, architecture, commands |
settings.json | Shared project settings (committed to git) |
settings.local.json | Your personal settings (gitignored) |
commands/ | Project slash commands (*.md files) |
skills/ | Project skills (folders with SKILL.md) |
agents/ | Project sub-agents (*.md files) |
Global Level (~/.claude/)
| File/Dir | Purpose |
|---|
CLAUDE.md | Global memory (applies to ALL projects) |
settings.json | Global settings |
commands/ | Personal global commands |
skills/ | Personal global skills |
keybindings.json | Custom keyboard shortcuts |
Rewind & Checkpoints
| Key/Command | Action |
|---|
Esc Esc | Open rewind menu anywhere |
/rewind | Same but typed as command |
Rewind Options
| Option | Description |
|---|
| Conversation | Go back in chat only. Code stays as-is. |
| Code | Restore files only. Conversation stays. |
| Full Rewind | Restore both conversation AND code to a point. |
Note: Bash side-effects (database changes, API calls, deleted files via rm) can’t be rewound. Checkpoints only track file edits by Claude. Use Git for permanent safety.
Pro Workflow — How to Get the Best Out of Claude Code
Starting a New Project
cd project && claude → /init → Edit CLAUDE.md → Code!
The Plan → Execute Pattern
Shift+Tab → Plan Mode → Describe what you want → Review Claude’s plan → Shift+Tab → Normal/Auto → Execute
Saving Money
| Strategy | Why |
|---|
Use /compact | When context gets big, compress it. Saves tokens dramatically. |
Use /clear | Between unrelated tasks. Don’t carry irrelevant context. |
| Use Sonnet | For routine tasks. Save Opus for complex architecture decisions. |
Use @ refs | Instead of pasting code — smarter context management. |
Debugging Like a Pro
| Strategy | Why |
|---|
| Paste errors | Copy-paste the full error message. Claude parses stack traces brilliantly. |
| Paste screenshots | Ctrl+V a screenshot of the bug. Claude sees it. |
| Pipe logs | cat error.log | claude -p "what's wrong?" |
/doctor | If something feels broken, run this first. |
Parallel Development
| Strategy | How |
|---|
| Worktrees | claude -w feature-auth — isolated branch + session |
| Multiple dirs | --add-dir ../api ../web — work across repos |
| Background | Ctrl+B sends a task to background so you can start another |
| Agent Teams | Multiple Claude instances collaborating (experimental) |
Create Custom Commands
| Step | Action |
|---|
| 1. Create file | .claude/commands/review.md |
| 2. Write prompt | The markdown content IS the prompt Claude will use |
| 3. Use it | Type /project:review in Claude Code |
Optional YAML Frontmatter
| Key | Purpose |
|---|
argument-hint | Placeholder text for argument input |
description | Shows in /help listing |
allowed-tools | Restrict what tools the command can use |
model | Force a specific model for this command |
Variable: $ARGUMENTS
Use $ARGUMENTS in your markdown — it gets replaced with whatever you type after the command.
Example: /project:review src/auth.ts → $ARGUMENTS = “src/auth.ts”
Remote Control — Continue Sessions From Any Device
Control your local Claude Code session from your phone, tablet, or any browser. Your session runs locally — the remote device is just a window into it.
Requirements
| Requirement | Details |
|---|
| Subscription | Max plan required (Pro coming soon). No API keys. |
| Auth | Run claude → /login to sign in via claude.ai |
| Trust | Run claude in your project dir once to accept trust |
Starting a Remote Session
| Method | Command / Action |
|---|
| New session | claude remote-control |
| From existing | Type /remote-control or /rc inside a session |
| Enable for all | /config → Enable Remote Control for all sessions → true |
Connecting From Another Device
| Method | How |
|---|
| Session URL | Shown in terminal — open in any browser |
| QR code | Press spacebar to toggle QR display, scan with phone |
| Session list | Open claude.ai/code or Claude app — find by name (🟢 = online) |
Launch Flags
| Flag | Action |
|---|
--verbose | Show detailed connection & session logs |
--sandbox | Enable filesystem & network isolation |
--no-sandbox | Disable sandboxing (default) |
How It Works
- Your local session makes outbound HTTPS only — no inbound ports opened
- All traffic routes through Anthropic API over TLS
- Session reconnects automatically after sleep or network drops
- One remote connection per Claude Code instance
Remote Control vs Claude Code on the Web
| Feature | Remote Control | Claude Code on the Web |
|---|
| Runs on | Your machine | Anthropic cloud infrastructure |
| Local tools | ✅ MCP, filesystem, project config | ❌ Cloud environment only |
| Best for | Continue local work from anywhere | Start fresh without local setup |
Limitations
| Limitation | Details |
|---|
| One session at a time | Each Claude Code instance supports one remote connection |
| Terminal must stay open | Closing the terminal or stopping claude ends the session |
| Network timeout | ~10 min without network → session times out (restart with claude remote-control) |
Tip: Use /rename before /remote-control to give the session a descriptive name — makes it easy to find across devices. Use /mobile to get the Claude app download QR code.
Quick Reference — Most Used Combos
Daily Essentials
| What | How |
|---|
| Start project | cd project && claude |
| Continue where I left off | claude -c |
| Quick question, no session | claude -p "how do I..." |
| Review my changes | git diff | claude -p "review" |
| Explain error | cat error.log | claude -p "explain" |
| Check cost | Type /cost anytime |
| Undo mistake | Esc Esc → rewind |
Power Moves
| What | How |
|---|
| Parallel sessions | claude -w feature-a + claude -w feature-b |
| Custom reviewer agent | Create .claude/agents/reviewer.md |
| Auto-format on edit | PostToolUse hook → run prettier |
| Web session | claude --remote "fix the bug" |
| Transfer to local | claude --teleport |
| Budget limit | claude -p --max-budget-usd 2 "query" |
| Scripted automation | claude -p --output-format json "query" | jq |