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.

AI CLI·53 commands·Last updated 2026-08-05
Back to AI CLI

Install & Auth 7

npm install -g @anthropic-ai/claude-code
Install Claude Code globally via npm
claude --version
Print the installed version
npm update -g @anthropic-ai/claude-code
Upgrade to the latest version
claude update
Update to the latest version from within the CLI
claude auth login
Interactive sign-in to your Anthropic account
claude auth status
Show current authentication status
claude auth logout
Sign out

Launch & Run 6

claude
Start 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 -c
Continue 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 ../backend
Grant 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 plan
Start in plan mode (read-only, no file changes)
claude --dangerously-skip-permissions
Skip all permission prompts (trusted environments only, use with caution)
claude -w feat/login
Start 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 --verbose
Show full turn-by-turn tool output

Session Slash Commands 7

/clear
Clear conversation history for a fresh task
/compact
Summarize the conversation to free context window space
/context
Visualize context window usage and optimization tips
/resume
Reopen a past session by name or from a picker
/branch
Fork the conversation to try a different direction
/rewind
Roll code and conversation back to a checkpoint
/exit
Quit the REPL

Project & Dev Slash Commands 10

/init
Generate a starter CLAUDE.md for the project
/memory
Edit CLAUDE.md files and manage auto-memory
/mcp
Manage MCP server connections interactively
/agents
Configure subagent settings
/permissions
Set allow/ask/deny rules for tools
/hooks
View hook configurations
/plan
Enter plan mode before a large change
/model
Switch the active model
/diff
Open the interactive diff viewer
/code-review --fix
Review 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 list
List configured MCP servers
claude mcp get <name>
Show a server configuration
claude mcp remove <name>
Remove an MCP server
claude mcp add-from-claude-desktop
Import MCP servers from Claude Desktop

Prompt File References 3

Review @./src/components/Button.tsx
Reference a single file with @ in the prompt
Compare @src/old.js with @src/new.js
Reference multiple files to compare
Explain the structure of @./src
Reference 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