Claude Code Reference

v2.1.178 · 87 auto-discovered · Commands, shortcuts, hooks, Python/AWS tips.

CLI Flags & Options

Click any flag to see its accepted values and copy-ready examples.

--worktree, -wAUTO
Start Claude in an isolated [git worktree](/en/worktrees) at <repo>/.claude/worktrees/<name>. If no name is given, one is auto-generated. Pass #<number> or a GitHub pull request URL to fetch that PR from origin and branch the worktree from it
--version, -vAUTO
Output the version number
--resume, -rAUTO
Resume a specific session by ID or name, or show an interactive picker to choose a session. The picker and name search include sessions that added this directory with /add-dir; passing a session ID searches only the current project directory and its git worktrees. As of v2.1.144, [background sessions](/en/agent-view) appear in the picker marked with bg
--remote-control-session-name-prefix <prefix>AUTO
Prefix for auto-generated [Remote Control](/en/remote-control) session names when no explicit name is set. Defaults to your machine's hostname, producing names like myhost-graceful-unicorn. Set CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX for the same effect
--remote-control, --rcAUTO
Start an interactive session with [Remote Control](/en/remote-control#start-a-remote-control-session) enabled so you can also control it from claude.ai or the Claude app. Optionally pass a name for the session
--print, -pAUTO
Print response without interactive mode (see [Agent SDK documentation](/en/agent-sdk/overview) for programmatic usage details)
--name, -nAUTO
Set a display name for the session, shown in /resume and the terminal title. You can resume a named session with claude --resume <name>. <br /><br />[/rename](/en/commands) changes the name mid-session and also shows it on the prompt bar
--disallowedTools, --disallowed-toolsAUTO
Deny rules. A bare tool name removes the matching tools from the model's context: "Edit" removes Edit, "*" removes every tool, and "mcp__*" removes every MCP tool. A scoped rule such as Bash(rm *) leaves the tool available and denies only matching calls
--debug-file <path>AUTO
Write debug logs to a specific file path. Implicitly enables debug mode. Takes precedence over CLAUDE_CODE_DEBUG_LOGS_DIR
--continue, -cAUTO
Load the most recent conversation in the current directory. Includes sessions that added this directory with /add-dir
--allowedTools, --allowed-toolsAUTO
Tools that execute without prompting for permission. See [permission rule syntax](/en/settings#permission-rule-syntax) for pattern matching. To restrict which tools are available, use --tools instead
--advisor <model>AUTO
{/* min-version: 2.1.98 */}Enable the server-side [advisor tool](/en/advisor) for this session with a model alias: opus, sonnet, or fable ({/* min-version: 2.1.170 */}v2.1.170+), or a full model ID. Takes precedence over the advisorModel setting for the session. Requires Claude Code v2.1.98 or later
Observability in the terminalAUTO
Enhances observability for engineers working via command line with agentic tools like Claude Code.N/A
gcx CLI toolAUTO
provides observability in the terminal for monitoring systems and responding to issuesN/A
Terminal observabilityAUTO
Get observability in the terminal with the gcx CLI tool for monitoring systems and responding to issues with agentic tools like Claude CodeNot applicable
observability in the terminalAUTO
Use the gcx CLI tool to observe systems and respond to issues in the terminal, compatible with agentic tools like Claude Code.Not provided
claude
Start an interactive Claude Code session in the current directory.claude

Examples

claude
cd ~/projects/api && claude
claude --model claude-sonnet-4-6

TipRun inside the repo root so Claude picks up CLAUDE.md and .claude/ settings.

claude "prompt"
Start a session and immediately run a prompt.claude "fix the auth bug"

Examples

claude "add a /healthz endpoint"
claude "explain the data layer in src/db"
claude "find unused exports in src/lib"
claude -p
Non-interactive (print) mode. Runs once, prints, exits — perfect for scripts and CI.claude -p "analyze this code"

Examples

claude -p "summarize TODOs in src/"
git diff main | claude -p "review this diff"
claude -p --output-format json "list public API endpoints"

TipCombine with --max-turns and --max-budget-usd in CI to bound cost.

claude -c
Continue your most recent session right where you left off.claude -c

Examples

claude -c

TipUseful after closing the terminal — context, todo list, and history are restored.

claude -r "name"
Resume a named session.claude -r "auth-refactor"

Examples

claude -r "auth-refactor"
claude -r "infra-migration"
claude --resume
Open an interactive picker of recent sessions to resume.claude --resume

Examples

claude --resume
claude -w
Open a session in an isolated git worktree so you can work on a side branch without disturbing your current tree.claude -w feature-auth

Examples

claude -w feature-auth
claude -w hotfix/login-redirect
claude -w bump-deps

TipEach worktree is its own checkout — perfect for parallel features.

--model
Choose which Claude model to use for this session.claude --model claude-opus-4-7

Accepted values

  • claude-opus-4-7Most capable, 1M context, best for hard agentic coding (latest).
  • claude-opus-4-6Previous flagship — strong reasoning, 1M context.
  • claude-sonnet-4-6Fast & cheap default — great speed/quality trade-off.
  • claude-haiku-4-5Fastest, cheapest — classification, structured output.

Examples

claude --model claude-opus-4-7
claude -p --model claude-haiku-4-5 "lint these commit messages"
Read upstream docs
--effort
Set how hard Claude should think before answering. Higher = more thinking tokens, slower, better quality.claude --effort high

Accepted values

  • lowSnappy answers, minimal thinking. Best for quick edits.
  • mediumDefault. Balanced for most tasks.
  • highMore extensive reasoning. Use for tricky bugs.
  • maxMaximum reasoning depth. For the hardest problems.

Examples

claude --effort high
claude -p --effort max "explain why this race condition happens"

TipAlso settable per-message with /effort or via env CLAUDE_CODE_EFFORT_LEVEL.

--permission-mode
Control how Claude handles tool permissions for this session.claude --permission-mode plan

Accepted values

  • defaultPrompt before each new tool use (safest interactive default).
  • planPlan-only — Claude analyzes and proposes a plan but cannot edit until you switch modes.
  • acceptEditsAuto-accept file edits without prompting. Bash still prompts.
  • bypassPermissionsSkip ALL permission prompts. Dangerous — use only in sandboxes.

Examples

claude --permission-mode plan
claude --permission-mode acceptEdits
claude -p --permission-mode bypassPermissions "run the test suite and fix failures"

TipToggle modes mid-session with Shift+Tab.

--allowedTools
Pre-approve specific tools (and command patterns) so Claude doesn't ask each time.--allowedTools "Read,Edit,Bash"

Accepted values

  • ReadAllow reading any file.
  • EditAllow modifying existing files.
  • WriteAllow creating new files.
  • BashAllow ANY shell command (broad — prefer narrow patterns).
  • Bash(npm *)Allow only npm subcommands. Same syntax for git, aws, terraform…
  • GrepAllow content search.
  • GlobAllow file pattern matching.
  • WebSearchAllow web search.
  • WebFetchAllow URL fetches.

Examples

claude --allowedTools "Read,Edit,Bash(npm test)"
claude -p --allowedTools "Read,Grep,Glob" "find all TODO comments"
claude --allowedTools "Read,Edit,Bash(git *),Bash(npm *)"
--max-turns
Cap the number of agentic turns Claude can take in a single run.claude -p --max-turns 5

Examples

claude -p --max-turns 3 "quick lint pass"
claude -p --max-turns 10 "add tests for src/auth"

TipCombine with --max-budget-usd to safely bound CI runs.

--max-budget-usd
Stop the session once API spending crosses this dollar amount.claude -p --max-budget-usd 5.00

Examples

claude -p --max-budget-usd 0.50 "summarize this file"
claude -p --max-turns 10 --max-budget-usd 2.00 "refactor utils"
--output-format
Format of stdout in print mode. Lets you pipe Claude into jq, xargs, etc.claude -p --output-format json "query"

Accepted values

  • textPlain text (default).
  • jsonSingle JSON object with content + metadata.
  • stream-jsonNewline-delimited JSON events as they happen.

Examples

claude -p --output-format json "list api routes" | jq .content
claude -p --output-format stream-json "review src/auth" | tee log.ndjson
--bare
Minimal mode — disables hooks, skills, and project memory. Great for reproducible runs.claude --bare

Examples

claude --bare
claude --bare -p "plain answer with no project context"

TipEquivalent to setting CLAUDE_CODE_SIMPLE=1.

--debug
Enable verbose debug logging (tool calls, hook events, API requests).claude --debug

Examples

claude --debug
claude --debug 2> debug.log
pipe input
Pipe stdin into Claude — diffs, logs, files, anything.cat file.py | claude -p "review this"

Examples

cat error.log | claude -p "explain the root cause"
git diff main | claude -p "review for security issues"
kubectl describe pod foo | claude -p "why is this crashing?"

Environment Variables

ANTHROPIC_API_KEY
API key for direct Anthropic access
CLAUDE_CODE_USE_BEDROCK
Set to 1 to use AWS Bedrock
CLAUDE_CODE_USE_VERTEX
Set to 1 to use Google Vertex AI
CLAUDE_CODE_EFFORT_LEVEL
Default effort level (low/medium/high/max)
MAX_THINKING_TOKENS
Max tokens for extended thinking
CLAUDE_CODE_SIMPLE
Set to 1 for bare mode (no hooks/skills)

Available Tools

gcx CLI tool integrationAUTO

Provides observability in the terminal for engineers using agentic tools like Claude Code.

Anthropic’s Claude Mythos PreviewAUTO

A significant leap in AI capability under the gated defense framework of Project Glasswing, enhancing cybersecurity.

Model Context Protocol (MCP) integrationAUTO

Enables AI assistants like Claude Code to interact with Terraform, reducing manual effort and accelerating delivery.

gcx CLI toolAUTO

Enables observability in the terminal for engineers using agentic tools like Claude Code.

Project Glasswing integrationAUTO

Claude Code is integrated with Anthropic’s Claude Mythos Preview under the gated defense framework of Project Glasswing.

Terraform MCP server integrationAUTO

Enables AI assistants like Claude Code to interact with Terraform through the Model Context Protocol (MCP).

Project GlasswingAUTO

A gated defense framework under which Anthropic’s Claude Mythos Preview operates, enhancing cybersecurity capabilities.

Observability in the terminalAUTO

Enhances observability for engineers using command line tools like Claude Code.

gcx CLI tool supportAUTO

Claude Code is effective at handling day-to-day engineering tasks, now with observability in the terminal through the gcx CLI tool.

Claude CodeAUTO

handles many day-to-day engineering tasks effectively

Cursor and Claude CodeAUTO

Agentic tools that have become highly effective at handling many day-to-day engineering tasks

Agentic toolsAUTO

Handle many day-to-day engineering tasks efficiently

Cursor and Claude Code integrationAUTO

Handle many day-to-day engineering tasks effectively

agentic toolsAUTO

Cursor and Claude Code are highly effective at handling many day-to-day engineering tasks

Claude Managed AgentsAUTO

Cloudflare's integration with Anthropic's Claude Managed Agents for fast, isolated execution environment

Astro migrationAUTO

mass-migrated blog to Astro using Claude Code

AI Coding AgentAUTO

mass-migrated blog to Astro using Claude Code

Integration with CloudflareAUTO

Claude Managed Agents are integrated with Cloudflare for fast, isolated execution environment for autonomous code delivery.

Astro migration supportAUTO

Claude Code can handle mass-migrating blogs to Astro, managing posts, images, URLs, and sitemaps.

skills fileAUTO

teach the Claude Code agent about blog architecture, deployment, and what not to touch

mass-migrated blog to AstroAUTO

migrate large amounts of content to Astro using Claude Code

observability in the terminalAUTO

Use the gcx CLI tool to observe systems and respond to issues when working with agentic tools like Claude Code.

integration with Claude Managed AgentsAUTO

Cloudflare's integration with Anthropic's Claude Managed Agents for fast, isolated execution environment for autonomous code delivery.

Isolation and execution environmentAUTO

Fast, isolated execution environment for autonomous code delivery

Isolated execution environmentAUTO

Cloudflare's integration with Claude Managed Agents for autonomous code delivery

customizing agent's toolsAUTO

Easily customize your agent's tools in the Cloudflare integration.

global scaling of agent workflowsAUTO

Scale agent workflows globally while controlling access to private backends.

fast, isolated execution environmentAUTO

Cloudflare integrates with Claude Managed Agents to provide a fast, isolated execution environment for autonomous code delivery.

Agentic tools integrationAUTO

handle day-to-day engineering tasks with agentic tools like Cursor and Claude Code

Autonomous code deliveryAUTO

scale agent workflows globally with strict control over private backends

Isolation and deploymentAUTO

manage canonical URLs, JSON-LD markup, sitemap generation with Claude Code

Specialized Deep Research SkillAUTO

Adds a specialized deep research skill to Claude Code, enhancing its ability to manage sessions, chain tools, execute code, and respond to user requests.

SembleAUTO

a code search tool for agents that uses significantly fewer tokens than grep

Coding Agent SandboxesAUTO

Provides secure, microVM-based isolation for running AI coding agents like Claude Code.

agenic toolsAUTO

Claude Code is mentioned as an effective agenic tool for handling day-to-day engineering tasks.

AI coding agentsAUTO

Claude Code is used as an AI coding agent in a secure, microVM-based isolation environment provided by Docker's Coding Agent Sandboxes.

DeepSeek V4 ProAUTO

A new version of the DeepSeek tool integrated with Claude Code for more efficient agent loop operations.

DeepClaudeAUTO

Claude Code agent loop with DeepSeek V4 Pro, 17x cheaper

secure microVM-based isolationAUTO

provides secure environment for running AI coding agents like Claude Code

NVIDIA DeepStream Coding AgentsAUTO

Helps developers build real-time vision AI applications by handling intricate data pipelines

NVIDIA DynamoAUTO

Enables coding agents to write production code at scale

Read

Read files from disk

Write

Create new files

Edit

Edit existing files (sends only the diff)

Bash

Run shell commands

Glob

Find files by pattern (faster than find)

Grep

Search file contents (faster than grep/rg)

WebSearch

Search the web

WebFetch

Fetch and parse web pages

Monitor

Watch background scripts

Agent

Invoke subagents for parallel work

TodoWrite

Create and manage task lists

AskUserQuestion

Ask clarifying questions