cli-reference
# Claude Code CLI Reference
What this skill does
# Claude Code CLI Reference Complete reference for the Claude Code command-line interface. ## Installation ### System Requirements - macOS 13.0+, Windows 10 1809+, Ubuntu 20.04+, Debian 10+, Alpine 3.19+ - 4GB+ RAM - Internet connection required - Shell: Bash, Zsh, PowerShell, CMD - Windows: Git for Windows required ### Methods ```bash # Native (Recommended) curl -fsSL https://claude.ai/install.sh | bash # Homebrew (macOS) brew install --cask claude-code # WinGet (Windows) winget install Anthropic.ClaudeCode # npm (legacy) npm install -g @anthropic-ai/claude-code # Direct invocation npx @anthropic-ai/claude-code # Update to latest npm update -g @anthropic-ai/claude-code ``` ### Initial Login ```bash claude # First run opens browser for login ``` Supports: Claude Pro, Teams, Enterprise, Console, Bedrock, Vertex AI, Foundry. Credentials stored at `~/.claude.json`. ## Basic Usage ```bash # Interactive mode (default) claude # Start with initial prompt claude "explain this codebase" # Non-interactive / print mode claude -p "what does this function do?" # Pipe input cat file.ts | claude -p "review this code" # Resume last conversation claude --continue # Resume specific conversation claude --resume <session-id> ``` ## CLI Flags ### Session Management Flags | Flag | Short | Description | |------|-------|-------------| | `--help` | `-h` | Show help message | | `--version` | `-v` | Show version number | | `--print` | `-p` | Non-interactive mode: print response and exit | | `--verbose` | | Enable verbose/debug logging | | `--debug [category]` | | Debug logging for specific category | | `--model` | `-m` | Override model (e.g., `sonnet`, `opus`, `haiku`) | | `--continue` | `-c` | Resume most recent conversation | | `--resume` | `-r` | Resume specific conversation by ID | | `--fork-session` | | Create new session from current context | | `--teleport` | | Resume a web session locally | | `--remote "task"` | | Create cloud session | | `--worktree` | `-w` | Run in isolated git worktree | ### Output & Format Flags | Flag | Description | |------|-------------| | `--output-format` | Output format: `text` (default), `json`, `stream-json` | | `--max-turns` | Maximum conversation turns in non-interactive mode | | `--max-budget-usd` | Spending limit per session | | `--no-input` | Skip initial user input (for piped content) | | `--input-format` | Input format: `text` (default), `stream-json` | | `--json-schema` | Structured output with JSON schema (print mode) | ### Permission & Security Flags | Flag | Description | |------|-------------| | `--dangerously-skip-permissions` | Skip all permission prompts (use with caution) | | `--allowedTools` | Comma-separated list of allowed tools | | `--disallowedTools` | Comma-separated list of disallowed tools | | `--permission-mode` | Permission mode: `default`, `plan`, `acceptEdits`, `dontAsk`, `bypassPermissions` | | `--permission-prompt-tool` | MCP tool for handling permission prompts | ### Configuration Flags | Flag | Description | |------|-------------| | `--system-prompt` | Override entire system prompt (use with `-p`) | | `--append-system-prompt` | Append text to system prompt | | `--system-prompt-file` | Load system prompt from file | | `--append-system-prompt-file` | Append system prompt from file | | `--mcp-config` | Path to MCP config JSON file | | `--settings` | Load settings from file or JSON string | | `--agents` | Define custom agents as JSON | | `--plugin-dir` | Load plugin from directory (repeatable) | | `--add-dir` | Add additional working directories to context | | `--init` | Run initialization hooks | | `--maintenance` | Run maintenance hooks | ### PR & Review Flags | Flag | Description | |------|-------------| | `--from-pr <url>` | Load PR context from GitHub URL | | `--fallback-model` | Fallback model if primary unavailable | ### Agent Team Flags | Flag | Description | |------|-------------| | `--teammate-mode` | Run as part of an agent team | | `--chrome` | Enable Chrome browser for agent | | `--no-chrome` | Disable Chrome browser | | `--strict-mcp-config` | Fail on invalid MCP config | | `--setting-sources` | Show which file each setting comes from | | `--include-partial-messages` | Include partial messages in stream output | | `--betas` | Enable beta features | | `--no-session-persistence` | Disable session persistence | | `--allow-dangerously-skip-permissions` | Allow skipping permissions programmatically | ### Auth CLI ```bash claude auth login # Login to Anthropic claude auth logout # Logout claude auth status # Show auth status claude agents # Manage agent teams claude update # Update Claude Code claude mcp add-json <name> <json> # Add MCP from JSON blob claude mcp add-from-claude-desktop # Import from Claude Desktop ``` ### Session ID Flags | Flag | Description | |------|-------------| | `--session-id` | Set specific session ID | | `--conversation-id` | Set conversation ID within session | ## Environment Variables ### Authentication | Variable | Description | |----------|-------------| | `ANTHROPIC_API_KEY` | API key for Anthropic direct access | | `ANTHROPIC_AUTH_TOKEN` | OAuth/bearer token for API access | | `CLAUDE_CODE_API_KEY` | Alternative API key variable | ### Provider Selection | Variable | Description | |----------|-------------| | `CLAUDE_CODE_USE_BEDROCK` | `1` to use AWS Bedrock | | `CLAUDE_CODE_USE_VERTEX` | `1` to use Google Vertex AI | | `ANTHROPIC_BASE_URL` | Custom API base URL | ### AWS Bedrock Configuration | Variable | Description | |----------|-------------| | `ANTHROPIC_BEDROCK_BASE_URL` | Bedrock endpoint URL | | `AWS_REGION` | AWS region for Bedrock | | `AWS_ACCESS_KEY_ID` | AWS access key | | `AWS_SECRET_ACCESS_KEY` | AWS secret key | | `AWS_SESSION_TOKEN` | AWS session token (for temporary creds) | | `AWS_PROFILE` | AWS profile name | | `ANTHROPIC_MODEL` | Override model ID for Bedrock | ### Google Vertex Configuration | Variable | Description | |----------|-------------| | `ANTHROPIC_VERTEX_PROJECT_ID` | GCP project ID | | `CLOUD_ML_REGION` | GCP region | | `ANTHROPIC_VERTEX_BASE_URL` | Custom Vertex endpoint | ### Model Overrides | Variable | Description | |----------|-------------| | `ANTHROPIC_MODEL` | Override default model ID | | `ANTHROPIC_DEFAULT_SONNET_MODEL` | Override Sonnet model ID | | `ANTHROPIC_DEFAULT_OPUS_MODEL` | Override Opus model ID | | `CLAUDE_CODE_EFFORT_LEVEL` | Reasoning effort: `low`, `medium`, `high` | ### Behavior Configuration | Variable | Description | |----------|-------------| | `DISABLE_AUTOMEMORY` | `1` to disable auto-memory | | `DISABLE_AUTOUPDATER` | `1` to disable auto-updates | | `DISABLE_BUG_COMMAND` | `1` to disable /bug command | | `CLAUDE_CODE_MAX_OUTPUT_TOKENS` | Override max output tokens | | `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC` | `1` to disable telemetry | | `CLAUDE_CODE_ENABLE_TELEMETRY` | Enable OpenTelemetry | | `CLAUDE_CODE_SKIP_DOCTOR` | `1` to skip doctor checks | | `CLAUDE_CODE_DISABLE_FAST_MODE` | Disable fast Opus mode | | `CLAUDE_CODE_SIMPLE` | Use minimal system prompt | | `CLAUDE_CODE_DISABLE_1M_CONTEXT` | Disable large context window | | `CLAUDE_CODE_SHELL` | Override shell detection | | `BASH_DEFAULT_TIMEOUT_MS` | Bash command timeout in ms | | `MAX_MCP_OUTPUT_TOKENS` | MCP tool output token limit | | `SLASH_COMMAND_TOOL_CHAR_BUDGET` | Skill character budget | ### Directory Overrides | Variable | Description | |----------|-------------| | `CLAUDE_CONFIG_DIR` | Custom config directory location | | `CLAUDE_CODE_TMPDIR` | Override temporary directory | ### Cloud Provider: Microsoft Foundry | Variable | Description | |----------|-------------| | `CLAUDE_CODE_USE_FOUNDRY` | `1` to use Microsoft Foundry | ### Agent Teams & Advanced | Variable | Description | |----------|-------------| | `CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS` | Enable agent teams feature | | `CLAUDE_CODE_TEAM_NAME` | Team name for agent te
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.