๐ Quick Reference
The commands and settings you'll look up most often when using Claude Code, all in one place.
Basic Usageโ
claude # Start interactive mode
claude "your task" # Run a single prompt
claude -p "prompt" # --print mode (output only)
claude --continue # Continue the last conversation
claude --resume # Pick a session and resume
claude --model sonnet # Specify model (sonnet, opus, fable, best, or full model name)
claude update # Update to the latest version
claude auth login # Log in with your Anthropic account
claude auth status # Check auth status (JSON)
claude agents # List configured subagents
claude mcp # Configure MCP servers
Slash Commandsโ
| Command | Description |
|---|---|
/help | Show help |
/clear | Reset the current conversation (aliases: /reset, /new) |
/compact [instructions] | Summarize the conversation to save context (optional summary instructions) |
/memory | Edit CLAUDE.md files, configure auto-memory |
/cost | Check cumulative cost for the current session |
/model [model] | Change the active model (adjust Effort Level with left/right arrows) |
/permissions | Review tool permission settings (alias: /allowed-tools) |
/status | Check version, model, account, and connection status |
/config | Open the settings interface (alias: /settings) |
/init | Generate an initial CLAUDE.md |
/fast [on|off] | Toggle Fast Mode |
/diff | Interactive diff viewer for uncommitted changes |
/context | Visualize current context usage |
/copy | Copy the last response to the clipboard |
/doctor | Diagnose installation and configuration |
/export [filename] | Export the current conversation as text |
/fork [name] | Copy the conversation into a new background session (shown in claude agents, v2.1.212+) โ for in-session branching use /subtask |
/hooks | Manage hook configuration |
/plugin | Manage plugins |
/pr-comments [PR] | Fetch GitHub PR comments |
/rename [name] | Rename the current session |
/resume [session] | Resume a session (alias: /continue) |
/rewind | Roll back to an earlier point (alias: /checkpoint) |
/sandbox | Toggle sandbox mode |
/skills | List available Skills |
/stats | Visualize daily usage and session history |
/theme | Change the color theme |
/vim | Switch between Vim/Normal editing modes |
/review <pr> is a fast single-pass review; for multi-agent review, run /code-review <level> <pr#> and pick the intensity (v2.1.202+). As of v2.1.215, /verify and /code-review are no longer run automatically โ invoke them yourself when needed.
Key CLI Flagsโ
| Flag | Description |
|---|---|
--print, -p | Output only (non-interactive mode) |
--continue, -c | Continue the most recent conversation in the current directory |
--resume, -r | Resume by session ID or name |
--model | Specify model (sonnet, opus, fable, best, or full model name) |
--permission-mode | Specify permission mode (default, plan, acceptEdits, bypassPermissions) |
--allowedTools | Tools to auto-approve |
--disallowedTools | Tools to prohibit |
--tools | Restrict available tools ("Bash,Edit,Read") |
--add-dir | Add extra working directories |
--system-prompt | Replace the entire system prompt |
--append-system-prompt | Append instructions to the default prompt |
--max-turns | Max turns for the agentic loop (print mode) |
--max-budget-usd | API cost cap (print mode) |
--output-format | Output format (text, json, stream-json) |
--mcp-config | Load an MCP server config JSON file |
--worktree, -w | Run in an isolated git worktree |
--chrome / --no-chrome | Enable/disable Chrome browser integration |
--agent | Specify the agent for the session |
--agents | Custom subagent JSON definitions |
--plugin-dir | Load a plugin directory |
--dangerously-skip-permissions | Skip all permission checks (caution!) |
--verbose | Verbose logging (per-turn output) |
--debug | Debug mode (category filters supported) |
--json-schema | Structured output conforming to a JSON Schema (print mode) |
--fallback-model | Fallback model when the primary is overloaded (print mode) |
--fork-session | Fork into a new session ID when resuming |
--from-pr | Resume the session linked to a GitHub PR |
--remote | Create a web session on claude.ai |
--teleport | Bring a web session into your local terminal |
--teammate-mode | Agent Team display mode (auto, in-process, tmux) |
--append-system-prompt is recommended in most cases because it keeps the default Claude Code behavior and only adds your instructions. --system-prompt replaces everything, so use it with care.
Permission Modesโ
Switch with Shift+Tab, or set at startup with the --permission-mode flag:
| Mode | Value | Description |
|---|---|---|
| Default | default | Ask for approval on each action |
| Auto-accept Edits | acceptEdits | Auto-approve file edits; Bash still requires confirmation |
| Plan Mode | plan | Read-only exploration, no file modifications |
| Bypass | bypassPermissions | Skip all permission checks |
Use --dangerously-skip-permissions (Bypass mode) only in isolated environments (Docker, VMs).
CLAUDE.md Templateโ
# Project Name
## Tech Stack
- Language: TypeScript
- Framework: Next.js
- Package manager: npm
## Coding Conventions
- Function names: camelCase
- File names: kebab-case
- Indentation: 2 spaces
## Common Commands
- Dev server: `npm run dev`
- Build: `npm run build`
- Test: `npm test`
## Current Progress
- โ
Completed work
- ๐ In progress
- โฌ Planned
Environment Variablesโ
Core Settingsโ
| Variable | Description | Default |
|---|---|---|
ANTHROPIC_API_KEY | API authentication key | โ |
ANTHROPIC_MODEL | Default model setting | Varies by plan |
CLAUDE_CODE_MAX_OUTPUT_TOKENS | Maximum output tokens | 32,000 |
CLAUDE_CODE_EFFORT_LEVEL | Effort Level (low, medium, high) | โ |
CLAUDE_CODE_DISABLE_FAST_MODE | Disable Fast Mode (1) | โ |
CLAUDE_CODE_SHELL | Override automatic shell detection | โ |
CLAUDE_CONFIG_DIR | Change where config/data files are stored | โ |
HTTP_PROXY / HTTPS_PROXY | Proxy settings | โ |
Feature Togglesโ
| Variable | Description |
|---|---|
CLAUDE_CODE_DISABLE_AUTO_MEMORY | Disable auto-memory (1) / force enable (0) |
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS | Disable background tasks (1) |
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONS | Remove built-in commit/PR workflow instructions (1) |
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING | Disable adaptive thinking (1) โ applies to Opus 4.6 and Sonnet 4.6 only; Opus 4.7+ is always adaptive |
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTION | Disable prompt suggestions (false) |
CLAUDE_CODE_ENABLE_TASKS | Disable task tracking, restoring the previous TODO list (false) |
DISABLE_AUTOUPDATER | Disable auto-updates (1) |
DISABLE_PROMPT_CACHING | Disable prompt caching (1) |
DISABLE_COST_WARNINGS | Disable cost warning messages (1) |
DISABLE_TELEMETRY | Disable telemetry (1) |
Bash Tool Settingsโ
| Variable | Description |
|---|---|
BASH_DEFAULT_TIMEOUT_MS | Default timeout for Bash commands |
BASH_MAX_TIMEOUT_MS | Maximum timeout for Bash commands |
BASH_MAX_OUTPUT_LENGTH | Maximum Bash output length in characters (middle is truncated beyond this) |
Cloud Providers (Bedrock / Vertex / Foundry)โ
| Variable | Description |
|---|---|
CLAUDE_CODE_USE_BEDROCK | Use AWS Bedrock |
CLAUDE_CODE_USE_VERTEX | Use Google Vertex |
CLAUDE_CODE_USE_FOUNDRY | Use Microsoft Foundry |
ANTHROPIC_FOUNDRY_BASE_URL | Foundry resource URL |
For the full list of environment variables, see the official settings documentation.
Model Selection Guideโ
| Model | Use Case | Relative Cost |
|---|---|---|
claude-haiku-4-5 | Fast tasks, bulk processing | Cheap |
claude-sonnet-5 | General development (recommended default, released 2026-06-30) | Medium |
claude-opus-4-8 | Complex design, deep reasoning | Expensive |
claude-fable-5 | The hardest reasoning, long autonomous runs (1M default, v2.1.170+) | Very expensive |
Hook Event Types (18)โ
| Event | When It Fires |
|---|---|
SessionStart | When a session starts or resumes |
UserPromptSubmit | After a prompt is submitted, before Claude processes it |
PreToolUse | Right before a tool runs (can block) |
PermissionRequest | When a permission dialog is shown |
PostToolUse | After a tool runs successfully |
PostToolUseFailure | After a tool run fails |
Notification | When Claude sends a notification |
SubagentStart | When a subagent is created |
SubagentStop | After a subagent finishes |
Stop | After Claude finishes responding |
TeammateIdle | When an Agent Team teammate goes idle |
TaskCompleted | When a task is marked complete |
InstructionsLoaded | When CLAUDE.md or rules files are loaded |
ConfigChange | When a config file changes mid-session |
WorktreeCreate | When a worktree is created |
WorktreeRemove | When a worktree is removed |
PreCompact | Before context compaction |
SessionEnd | When a session ends |
Hooks support four types: shell command (command), HTTP endpoint, LLM prompt, and MCP tool. For configuration details, see the official Hooks reference.
Agent SDK Quick Referenceโ
import { query } from "@anthropic-ai/claude-agent-sdk";
// Basic run
const response = await query({
prompt: "Your task",
options: {
maxTurns: 10,
allowedTools: ["Read", "Write", "Bash"],
systemPrompt: "You are an expert."
}
});
// Extract response text
const text = response
.filter(m => m.type === "assistant")
.flatMap(m => m.content)
.filter(b => b.type === "text")
.map(b => b.text)
.join("\n");
Common Prompt Patternsโ
# Code review
"Review the changes in this PR and point out bugs, security issues, and improvements."
# Refactoring
"Refactor this function for readability. Don't change its behavior."
# Writing tests
"Write unit tests for this function with Jest. Include edge cases."
# Documentation
"Write JSDoc comments for this module."
# Debugging
"Find the cause of this error and fix it: [error message]"