🔥 Launch tonight — Claude Code Power Prompts PDF 50p (just 50p tonight)30 battle-tested prompts · 8-page PDF · paste into CLAUDE.md · flat 50p tonight

Claude Code Commands List

Updated May 2026 · Complete CLI reference

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

claude [prompt]

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"
claude edit <file> [instructions]

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
claude review [path]

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
claude commit [message]

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
claude test [file-or-pattern]

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
claude explain <file-or-symbol>

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

FlagDescription
--model <id>Override default model. Options: claude-opus-4-7, claude-sonnet-4-6, claude-haiku-4-5
--no-confirmSkip 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-runShow what changes would be made without applying them
--verbosePrint debug info including tokens used and which files were read
--versionPrint Claude Code version and exit
--helpShow help for any command

Configuration Commands

claude config <key> [value]

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"
claude auth [login|logout|status]

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

claude context [show|clear|add]

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
claude pr [create|review|describe]

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
Tip: Chain Claude Code with standard Unix tools. For example: git diff HEAD~5 | claude "summarize these changes" pipes git output directly as context.

Environment Variables

VariableDescription
ANTHROPIC_API_KEYYour Anthropic API key. Required.
CLAUDE_MODELDefault model override (same as --model flag)
CLAUDE_MAX_TOKENSDefault max tokens per response
CLAUDE_NO_CONFIRMSet to "1" to skip all confirmations (CI mode)
CLAUDE_CONTEXT_FILEPath to default context file (loaded in addition to CLAUDE.md)
CLAUDE_LOG_LEVELLog verbosity: error, warn, info, debug

→ Next: Slash Commands Reference

← Back to Home