Claude Code CLI Cheatsheet - Anthropic AI Coding Agent Full Reference
All Claude Code terminal AI coding agent commands in one place — from install & auth to print/resume sessions, permission modes, and MCP — organized by scenario. Copy and go.
Back to AI CLIInstall & Auth 7
npm install -g @anthropic-ai/claude-codeInstall Claude Code globally via npm
claude --versionPrint the installed version
npm update -g @anthropic-ai/claude-codeUpgrade to the latest version
claude updateUpdate to the latest version from within the CLI
claude auth loginInteractive sign-in to your Anthropic account
claude auth statusShow current authentication status
claude auth logoutSign out
Launch & Run 6
claudeStart an interactive REPL in the current directory
claude "Refactor the user-auth module to use the new session API"Start a session with an initial prompt
cat error.log | claude -p "Explain this error and suggest a fix"Pipe content in and process it in print mode
claude -cContinue the most recent conversation (--continue)
claude -r "abc123" "Finish the PR"Resume a specific conversation by session ID (--resume)
claude -c -p "Check for type errors"Continue the recent conversation in print mode for automation
CLI Flags 13
claude -p -m claude-sonnet-4 "Write a Python function to parse CSV"Set the model and run in print mode
claude -p --output-format json "List all TODO comments in this project"Output JSON for scripting and parsing
claude -p --max-turns 5 "Refactor the auth module"Cap agentic turns to prevent runaway operations
claude --max-budget-usd 2 "Implement the login page"Cap API spend in -p mode
claude --add-dir ../frontend ../backendGrant file access to extra working directories
claude --system-prompt "You are a security auditor"Replace the entire system prompt
claude --append-system-prompt "Use TypeScript strict mode"Append instructions to the default system prompt
claude --permission-mode planStart in plan mode (read-only, no file changes)
claude --dangerously-skip-permissionsSkip all permission prompts (trusted environments only, use with caution)
claude -w feat/loginStart in an isolated git worktree (--worktree)
claude --effort high "Design the cache layer architecture"Set reasoning effort: low/medium/high/xhigh/max
claude --bg "Run the test suite"Start as a background agent and return immediately
claude --verboseShow full turn-by-turn tool output
Session Slash Commands 7
/clearClear conversation history for a fresh task
/compactSummarize the conversation to free context window space
/contextVisualize context window usage and optimization tips
/resumeReopen a past session by name or from a picker
/branchFork the conversation to try a different direction
/rewindRoll code and conversation back to a checkpoint
/exitQuit the REPL
Project & Dev Slash Commands 10
/initGenerate a starter CLAUDE.md for the project
/memoryEdit CLAUDE.md files and manage auto-memory
/mcpManage MCP server connections interactively
/agentsConfigure subagent settings
/permissionsSet allow/ask/deny rules for tools
/hooksView hook configurations
/planEnter plan mode before a large change
/modelSwitch the active model
/diffOpen the interactive diff viewer
/code-review --fixReview the current diff (optionally auto-fix)
MCP Server Management 7
claude mcp add --transport http <name> <url>Add an HTTP MCP server (recommended transport)
claude mcp add <name> -- <args...>Add a stdio MCP server; command follows --
claude mcp add-json '<json>'Add a complex MCP server from JSON config
claude mcp listList configured MCP servers
claude mcp get <name>Show a server configuration
claude mcp remove <name>Remove an MCP server
claude mcp add-from-claude-desktopImport MCP servers from Claude Desktop
Prompt File References 3
Review @./src/components/Button.tsxReference a single file with @ in the prompt
Compare @src/old.js with @src/new.jsReference multiple files to compare
Explain the structure of @./srcReference a whole directory for context
💡 Tips
- For scripts and CI prefer `claude -p --output-format json`: print mode + JSON is the de-facto standard for automation.
- Cap long tasks or bounded budgets with both `--max-turns` and `--max-budget-usd` to avoid runaway API spend.
- Give Claude context with `@file` / `@dir` references — more accurate and maintainable than pasting file contents into the prompt.
- Before big changes, enter read-only `/plan` mode to confirm the approach, then grant permissions to execute — far less rework.
Official References
Commands are compiled from the official docs below. Click to verify the latest usage.
Maintained by LaoHand
Publicly updated on Aug 5, 2026, continuously proofread against official docs.
Found an error? Report it
Wrong command or description? Open an issue to help us fix it.
Found an error? Report it