Skip to content

CLI Reference

Complete command-line interface reference for Claude Code.

Installation

macOS / Linux / WSL

bash
curl -fsSL https://claude.ai/install.sh | bash

Homebrew

bash
brew install --cask claude-code

Windows PowerShell

powershell
irm https://claude.ai/install.ps1 | iex

Windows CMD

cmd
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

NPM

bash
npm install -g @anthropic-ai/claude-code

Basic Usage

Start Interactive Mode

bash
claude

One-Time Task

bash
claude "create a hello world function"

Query and Exit

bash
claude -p "what files are in this directory"

Command-Line Options

Session Options

FlagDescription
-c, --continueContinue most recent conversation
-r, --resume [id]Resume specific session
--printPrint mode (non-interactive)

Output Options

FlagDescription
-p, --printPrint response and exit
--output-format <fmt>Output format (text, json, stream-json)
--verboseVerbose output
--debugDebug mode with detailed logging

Model Options

FlagDescription
--model <model>Specify model to use
--max-tokens <n>Maximum output tokens

Permission Options

FlagDescription
--dangerously-skip-permissionsSkip permission prompts
--permission-mode <mode>Set permission mode

MCP Options

FlagDescription
--mcp-config <file>MCP configuration file
--mcp-debugDebug MCP connections

Other Options

FlagDescription
--helpShow help
--versionShow version
--cwd <dir>Set working directory
--config <file>Configuration file

Examples

Basic Interaction

bash
# Start interactive session
claude

# Ask a question
claude "explain this code" < main.py

# Continue last conversation
claude -c

Automation

bash
# One-shot command
claude "fix the typescript errors in src/"

# Pipe input
cat error.log | claude "explain this error"

# JSON output
claude --output-format json "list all functions"

Advanced

bash
# Custom model
claude --model claude-opus-4-5 "review this code"

# Debug mode
claude --debug "why is this failing"

# Skip permissions (CI/CD)
claude --dangerously-skip-permissions "run tests"

Environment Variables

Authentication

VariableDescription
ANTHROPIC_API_KEYAPI key for direct access
CLAUDE_CODE_USE_BEDROCKEnable AWS Bedrock
CLAUDE_CODE_USE_VERTEXEnable Google Vertex AI

AWS Bedrock

VariableDescription
AWS_REGIONAWS region
AWS_PROFILEAWS profile name
AWS_ACCESS_KEY_IDAccess key
AWS_SECRET_ACCESS_KEYSecret key

Google Vertex AI

VariableDescription
ANTHROPIC_VERTEX_PROJECT_IDGCP project ID
CLOUD_ML_REGIONVertex AI region
GOOGLE_APPLICATION_CREDENTIALSService account path

Model Configuration

VariableDescription
ANTHROPIC_MODELPrimary model
ANTHROPIC_SMALL_FAST_MODELSmall/fast model
CLAUDE_CODE_MAX_OUTPUT_TOKENSMax output tokens
MAX_THINKING_TOKENSMax thinking tokens
DISABLE_PROMPT_CACHINGDisable caching

MCP

VariableDescription
MAX_MCP_OUTPUT_TOKENSMCP output limit

Configuration Files

User Settings

~/.claude/settings.json:

json
{
  "model": "claude-sonnet-4-5",
  "theme": "dark",
  "permissions": {
    "autoApprove": ["Read", "Glob", "Grep"]
  }
}

Project Settings

.claude/settings.json:

json
{
  "model": "claude-opus-4-5",
  "allowedTools": ["Bash", "Edit", "Write"]
}

MCP Configuration

.mcp.json:

json
{
  "mcpServers": {
    "sqlite": {
      "command": "npx",
      "args": ["@anthropic/mcp-sqlite", "./db.sqlite"]
    }
  }
}

Exit Codes

CodeMeaning
0Success
1General error
2Invalid arguments

Next Steps

Claude Code Documentation Hub