Skip to main content

๐Ÿ“– 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โ€‹

CommandDescription
/helpShow help
/clearReset the current conversation (aliases: /reset, /new)
/compact [instructions]Summarize the conversation to save context (optional summary instructions)
/memoryEdit CLAUDE.md files, configure auto-memory
/costCheck cumulative cost for the current session
/model [model]Change the active model (adjust Effort Level with left/right arrows)
/permissionsReview tool permission settings (alias: /allowed-tools)
/statusCheck version, model, account, and connection status
/configOpen the settings interface (alias: /settings)
/initGenerate an initial CLAUDE.md
/fast [on|off]Toggle Fast Mode
/diffInteractive diff viewer for uncommitted changes
/contextVisualize current context usage
/copyCopy the last response to the clipboard
/doctorDiagnose 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
/hooksManage hook configuration
/pluginManage plugins
/pr-comments [PR]Fetch GitHub PR comments
/rename [name]Rename the current session
/resume [session]Resume a session (alias: /continue)
/rewindRoll back to an earlier point (alias: /checkpoint)
/sandboxToggle sandbox mode
/skillsList available Skills
/statsVisualize daily usage and session history
/themeChange the color theme
/vimSwitch between Vim/Normal editing modes
tip

/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โ€‹

FlagDescription
--print, -pOutput only (non-interactive mode)
--continue, -cContinue the most recent conversation in the current directory
--resume, -rResume by session ID or name
--modelSpecify model (sonnet, opus, fable, best, or full model name)
--permission-modeSpecify permission mode (default, plan, acceptEdits, bypassPermissions)
--allowedToolsTools to auto-approve
--disallowedToolsTools to prohibit
--toolsRestrict available tools ("Bash,Edit,Read")
--add-dirAdd extra working directories
--system-promptReplace the entire system prompt
--append-system-promptAppend instructions to the default prompt
--max-turnsMax turns for the agentic loop (print mode)
--max-budget-usdAPI cost cap (print mode)
--output-formatOutput format (text, json, stream-json)
--mcp-configLoad an MCP server config JSON file
--worktree, -wRun in an isolated git worktree
--chrome / --no-chromeEnable/disable Chrome browser integration
--agentSpecify the agent for the session
--agentsCustom subagent JSON definitions
--plugin-dirLoad a plugin directory
--dangerously-skip-permissionsSkip all permission checks (caution!)
--verboseVerbose logging (per-turn output)
--debugDebug mode (category filters supported)
--json-schemaStructured output conforming to a JSON Schema (print mode)
--fallback-modelFallback model when the primary is overloaded (print mode)
--fork-sessionFork into a new session ID when resuming
--from-prResume the session linked to a GitHub PR
--remoteCreate a web session on claude.ai
--teleportBring a web session into your local terminal
--teammate-modeAgent Team display mode (auto, in-process, tmux)
tip

--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:

ModeValueDescription
DefaultdefaultAsk for approval on each action
Auto-accept EditsacceptEditsAuto-approve file edits; Bash still requires confirmation
Plan ModeplanRead-only exploration, no file modifications
BypassbypassPermissionsSkip all permission checks
caution

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โ€‹

VariableDescriptionDefault
ANTHROPIC_API_KEYAPI authentication keyโ€”
ANTHROPIC_MODELDefault model settingVaries by plan
CLAUDE_CODE_MAX_OUTPUT_TOKENSMaximum output tokens32,000
CLAUDE_CODE_EFFORT_LEVELEffort Level (low, medium, high)โ€”
CLAUDE_CODE_DISABLE_FAST_MODEDisable Fast Mode (1)โ€”
CLAUDE_CODE_SHELLOverride automatic shell detectionโ€”
CLAUDE_CONFIG_DIRChange where config/data files are storedโ€”
HTTP_PROXY / HTTPS_PROXYProxy settingsโ€”

Feature Togglesโ€‹

VariableDescription
CLAUDE_CODE_DISABLE_AUTO_MEMORYDisable auto-memory (1) / force enable (0)
CLAUDE_CODE_DISABLE_BACKGROUND_TASKSDisable background tasks (1)
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONSRemove built-in commit/PR workflow instructions (1)
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKINGDisable adaptive thinking (1) โ€” applies to Opus 4.6 and Sonnet 4.6 only; Opus 4.7+ is always adaptive
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTIONDisable prompt suggestions (false)
CLAUDE_CODE_ENABLE_TASKSDisable task tracking, restoring the previous TODO list (false)
DISABLE_AUTOUPDATERDisable auto-updates (1)
DISABLE_PROMPT_CACHINGDisable prompt caching (1)
DISABLE_COST_WARNINGSDisable cost warning messages (1)
DISABLE_TELEMETRYDisable telemetry (1)

Bash Tool Settingsโ€‹

VariableDescription
BASH_DEFAULT_TIMEOUT_MSDefault timeout for Bash commands
BASH_MAX_TIMEOUT_MSMaximum timeout for Bash commands
BASH_MAX_OUTPUT_LENGTHMaximum Bash output length in characters (middle is truncated beyond this)

Cloud Providers (Bedrock / Vertex / Foundry)โ€‹

VariableDescription
CLAUDE_CODE_USE_BEDROCKUse AWS Bedrock
CLAUDE_CODE_USE_VERTEXUse Google Vertex
CLAUDE_CODE_USE_FOUNDRYUse Microsoft Foundry
ANTHROPIC_FOUNDRY_BASE_URLFoundry resource URL
tip

For the full list of environment variables, see the official settings documentation.


Model Selection Guideโ€‹

ModelUse CaseRelative Cost
claude-haiku-4-5Fast tasks, bulk processingCheap
claude-sonnet-5General development (recommended default, released 2026-06-30)Medium
claude-opus-4-8Complex design, deep reasoningExpensive
claude-fable-5The hardest reasoning, long autonomous runs (1M default, v2.1.170+)Very expensive

Hook Event Types (18)โ€‹

EventWhen It Fires
SessionStartWhen a session starts or resumes
UserPromptSubmitAfter a prompt is submitted, before Claude processes it
PreToolUseRight before a tool runs (can block)
PermissionRequestWhen a permission dialog is shown
PostToolUseAfter a tool runs successfully
PostToolUseFailureAfter a tool run fails
NotificationWhen Claude sends a notification
SubagentStartWhen a subagent is created
SubagentStopAfter a subagent finishes
StopAfter Claude finishes responding
TeammateIdleWhen an Agent Team teammate goes idle
TaskCompletedWhen a task is marked complete
InstructionsLoadedWhen CLAUDE.md or rules files are loaded
ConfigChangeWhen a config file changes mid-session
WorktreeCreateWhen a worktree is created
WorktreeRemoveWhen a worktree is removed
PreCompactBefore context compaction
SessionEndWhen a session ends
tip

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]"