CLI Reference
Complete command-line interface reference for Claude Code.
Installation
macOS / Linux / WSL
bash
curl -fsSL https://claude.ai/install.sh | bashHomebrew
bash
brew install --cask claude-codeWindows PowerShell
powershell
irm https://claude.ai/install.ps1 | iexWindows CMD
cmd
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdNPM
bash
npm install -g @anthropic-ai/claude-codeBasic Usage
Start Interactive Mode
bash
claudeOne-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
| Flag | Description |
|---|---|
-c, --continue | Continue most recent conversation |
-r, --resume [id] | Resume specific session |
--print | Print mode (non-interactive) |
Output Options
| Flag | Description |
|---|---|
-p, --print | Print response and exit |
--output-format <fmt> | Output format (text, json, stream-json) |
--verbose | Verbose output |
--debug | Debug mode with detailed logging |
Model Options
| Flag | Description |
|---|---|
--model <model> | Specify model to use |
--max-tokens <n> | Maximum output tokens |
Permission Options
| Flag | Description |
|---|---|
--dangerously-skip-permissions | Skip permission prompts |
--permission-mode <mode> | Set permission mode |
MCP Options
| Flag | Description |
|---|---|
--mcp-config <file> | MCP configuration file |
--mcp-debug | Debug MCP connections |
Other Options
| Flag | Description |
|---|---|
--help | Show help |
--version | Show 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 -cAutomation
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
| Variable | Description |
|---|---|
ANTHROPIC_API_KEY | API key for direct access |
CLAUDE_CODE_USE_BEDROCK | Enable AWS Bedrock |
CLAUDE_CODE_USE_VERTEX | Enable Google Vertex AI |
AWS Bedrock
| Variable | Description |
|---|---|
AWS_REGION | AWS region |
AWS_PROFILE | AWS profile name |
AWS_ACCESS_KEY_ID | Access key |
AWS_SECRET_ACCESS_KEY | Secret key |
Google Vertex AI
| Variable | Description |
|---|---|
ANTHROPIC_VERTEX_PROJECT_ID | GCP project ID |
CLOUD_ML_REGION | Vertex AI region |
GOOGLE_APPLICATION_CREDENTIALS | Service account path |
Model Configuration
| Variable | Description |
|---|---|
ANTHROPIC_MODEL | Primary model |
ANTHROPIC_SMALL_FAST_MODEL | Small/fast model |
CLAUDE_CODE_MAX_OUTPUT_TOKENS | Max output tokens |
MAX_THINKING_TOKENS | Max thinking tokens |
DISABLE_PROMPT_CACHING | Disable caching |
MCP
| Variable | Description |
|---|---|
MAX_MCP_OUTPUT_TOKENS | MCP 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
| Code | Meaning |
|---|---|
0 | Success |
1 | General error |
2 | Invalid arguments |
Next Steps
- Slash Commands - Interactive commands
- Hooks - Automation
- MCP Guide - Tool integration