Claude Code Commands List
Claude Code is primarily a CLI tool. This page documents every command, flag, and option. For slash commands (typed inside the Claude Code session), see the Slash Commands reference.
Core Invocation
Launch Claude Code in interactive mode. If prompt is provided, Claude starts working on it immediately without waiting for input. Without a prompt, opens the interactive REPL.
claude # interactive REPL claude "add input validation to login" # start with a task claude --model claude-opus-4-7 "refactor auth"
Open Claude Code focused on a specific file. Claude reads the entire file plus imports, then applies targeted edits.
claude edit src/auth.ts claude edit src/auth.ts "add rate limiting" claude edit . "fix all TypeScript errors" # . = current directory
Code review mode. Claude reads git diff (or the specified path) and produces a structured review with severity ratings.
claude review # review staged changes claude review HEAD~3 # review last 3 commits claude review src/api/ # review a directory claude review --format json # machine-readable output
Write a commit message for staged changes and optionally create the commit. Claude reads the diff and your git log to match your convention.
claude commit # draft a commit message claude commit --create # draft + git commit claude commit "fix auth bug" # use provided message but enrich it
Run tests and, if they fail, attempt to fix the failing code. Claude reads the error output and the related source files.
claude test # run all tests + fix failures claude test src/auth.test.ts # specific test file claude test --watch # watch mode with auto-fix
Get a deep explanation of a file, function, class, or code block. Useful for onboarding to unfamiliar codebases.
claude explain src/queue/worker.ts claude explain "AuthMiddleware" # finds the symbol in your codebase claude explain --brief src/ # one-paragraph summary per file
Global Flags
| Flag | Description |
|---|---|
| --model <id> | Override default model. Options: claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5 |
| --no-confirm | Skip confirmation prompts for file edits. Use carefully — irreversible. |
| --context <file> | Load additional context from a file (supplements CLAUDE.md) |
| --format <type> | Output format: text (default), json, markdown |
| --max-tokens <n> | Cap the response length. Useful for large codebases to reduce cost. |
| --dry-run | Show what changes would be made without applying them |
| --verbose | Print debug info including tokens used and which files were read |
| --version | Print Claude Code version and exit |
| --help | Show help for any command |
Configuration Commands
Read or write Claude Code configuration. Config is stored in ~/.claude/settings.json.
claude config # list all settings claude config model # show current model claude config model claude-opus-4-7 # set default model claude config permissions.autoApprove "Read,Edit"
Manage API key authentication. Claude Code reads ANTHROPIC_API_KEY from environment, but you can also store it via claude auth login.
claude auth status # check current auth state claude auth login # interactive API key setup claude auth logout # remove stored key
Utility Commands
Manage the session context. In long sessions, context can fill up — use this to inspect or trim it.
claude context show # show current context usage claude context clear # start fresh context claude context add file.md # add a file to context
GitHub Pull Request integration (requires gh CLI and auth).
claude pr create # create PR with AI-written description claude pr review 123 # review PR #123 claude pr describe # just write the PR description
git diff HEAD~5 | claude "summarize these changes" pipes git output directly as context.
Environment Variables
| Variable | Description |
|---|---|
| ANTHROPIC_API_KEY | Your Anthropic API key. Required. |
| CLAUDE_MODEL | Default model override (same as --model flag) |
| CLAUDE_MAX_TOKENS | Default max tokens per response |
| CLAUDE_NO_CONFIRM | Set to "1" to skip all confirmations (CI mode) |
| CLAUDE_CONTEXT_FILE | Path to default context file (loaded in addition to CLAUDE.md) |
| CLAUDE_LOG_LEVEL | Log verbosity: error, warn, info, debug |