Claude Code Command Cheat Sheet: Master All CLI Commands and Workflows
This comprehensive guide walks you through Claude Code’s market dominance, core design philosophy, step‑by‑step installation, a complete reference of basic and advanced CLI commands, slash commands, keyboard shortcuts, work modes, and real‑world workflows, helping developers unlock the full power of the AI‑driven programming assistant.
Core Value and Design Philosophy
Claude Code (released by Anthropic in 2025) is a terminal‑based AI programming assistant that can read project files, run shell commands, and manipulate Git directly. Its advantage stems from three design pillars:
Multi‑Agent Parallel Architecture – ~40 built‑in tools and a 46 000‑line query engine enable sub‑agents to collaborate on complex tasks.
Progressive Context Management – Hierarchical memory with smart compression keeps context quality high while dramatically reducing token usage.
Deep Repository Operations – Native support for cross‑file edits, Git workflow integration, and fine‑grained permission control.
Installation & Environment Setup
Claude Code requires Node.js 18 or newer. Verify the runtime: node --version Installation scripts for macOS/Linux/WSL:
# Stable version
curl -fsSL https://claude.ai/install.sh | bash
# Latest version
curl -fsSL https://claude.ai/install.sh | bash -s latest
# Homebrew (macOS)
brew install --cask claude-codeWindows (requires Git for Windows or WSL):
# CMD / PowerShell
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmdOptional NPM installation (works on all platforms): npm install -g @anthropic-ai/claude-code After installation, confirm the binary is available: claude --version The first launch walks you through authentication and workspace configuration.
Basic CLI Commands
claude– Start an interactive REPL in the current directory (daily multi‑turn development). claude "task description" – Launch with a one‑shot question and begin analysis immediately (quick query). claude -p "query" – Execute a single command, print the result, then exit (scripting / CI‑CD). claude -c – Continue the most recent conversation in the current directory (resume after a restart).
Example session:
# Interactive mode
claude
> Please analyze the project’s code structure
# One‑shot query
claude "Explain the authentication flow"
# One‑off execution (append output to a log)
claude -p "Check code style issues" >> review.log
# Resume previous session
claude -cAdvanced Options
--add-dir <paths>– Add extra work directories (essential for monorepos). Example:
claude --add-dir ../lib ../apps --model sonnet|opus|haiku– Select the model for the current session. Example:
claude --model opus --verbose– Enable detailed logs of tool execution. Example:
claude --verbose --dangerously-skip-permissions– Bypass all permission prompts (use only in sandbox experiments). Example:
claude --dangerously-skip-permissionsSlash Commands (Core Operations)
Session & Context Management
/help– Show all available commands and shortcuts (when you forget a command). /clear – Fully reset conversation history (switch to a completely different task). /compact – Compress history while retaining a core summary (use when token usage approaches the limit). /context – Visualize current token usage (monitor consumption). /resume – Restore a previous session (multi‑task parallelism). /rewind (ESC × 2) – Undo the last AI‑generated change (quick rollback).
Git & Code Operations
/commit– Analyze staged changes and auto‑generate a conventional commit message (e.g., feat: add JWT authentication ). /review – Inspect current changes for bugs, style violations, and potential issues (pre‑PR review). /diff – Show the current git diff (understand what changed). /branch – Create or switch Git branches (branch management). /pr_comments – Fetch open PR review comments (process code‑review feedback).
Memory & Configuration
/init– Generate an initial CLAUDE.md knowledge base (first‑time project onboarding). /memory – Edit the persistent CLAUDE.md file (update project rules or personal preferences). /model – Switch the model mid‑session (Sonnet / Opus / Haiku) based on task complexity. /config – View or modify runtime configuration (tune parameters). /cost – Show token usage and estimated cost for the session (cost control).
Diagnostics & Authentication
/doctor– Check environment, authentication, and network connectivity (when you encounter connection issues). /login – Log in to an Anthropic account (first use or account switch). /logout – Log out of the current account (switch accounts). /version – Display the installed version (verify you are up‑to‑date). /upgrade – Upgrade to the latest release (gain new features).
Integration & Extension
/mcp– Manage Model Context Protocol connections to external services (GitHub, databases, etc.). /skills – List and manage reusable skill packages (install custom skills). /hooks – Configure automation hooks (e.g., run prettier after file writes).
Keyboard Shortcuts for Speed
Ctrl+C– Interrupt the current generation or command (AI goes off‑track). Ctrl+D – Safely exit Claude Code (end session). Ctrl+L – Clear the screen while preserving context (visual clutter). Ctrl+T – Toggle the task list and view background jobs (monitor AI‑created tasks). Ctrl+R – Reverse‑search command history (find previous commands quickly). Shift+Tab – Cycle through the three work modes (Default → Auto‑Accept → Plan). ESC × 2 – Rewind the last AI change (undo). Ctrl+B – Send the current task to the background (e.g., compile while continuing the conversation). Shift+Enter – Insert a newline in the input box without sending (multi‑line prompts). Ctrl+U – Delete the entire input line (quick edit).
Three Work Modes
Default – Every file edit or command requires explicit confirmation (tight control for production).
Auto‑Accept – File modifications are applied automatically; shell commands still need confirmation (rapid iteration when you trust routine actions).
Plan – Read‑only mode; Claude only analyzes and proposes plans (design phase before committing changes).
Switch modes with Shift+Tab.
Advanced Features: Skills, Agents, MCP
Skills (Reusable Toolkits)
Skills are packaged capabilities that can be invoked like plugins. A typical example is a “Run Tests” skill that automatically detects the project structure, runs the test suite, parses the output, and returns a concise failure summary. To create a custom skill, place a SKILL.md file under ~/.claude/skills/.
Agents (Autonomous AI Entities)
Agents can independently plan, execute, reflect, and iterate to achieve a goal. Example workflow: “Fix this GitHub issue” → read the issue description → run tests → locate the bug → generate a fix → open a PR with an explanatory comment.
Model Context Protocol (MCP)
MCP lets Claude Code connect to external services (GitHub, databases, etc.) via the /mcp command. In practice, replace MCP with CLI + Skills when possible to save token budget.
Pros & Cons
Advantages
Strong multi‑agent capabilities – 67 % win rate over Cursor in code‑quality benchmarks.
Cross‑file refactoring – understands large codebases and performs consistent changes.
Low memory footprint via hierarchical compression.
Deep Git integration – auto‑generated commit messages, code review, PR management.
Easy model switching (Sonnet for everyday work, Opus for complex architecture, Haiku for quick exploration).
Drawbacks
Steep learning curve – many commands and shortcuts to master.
Terminal‑only interface – no GUI, which may deter developers unfamiliar with CLI tools.
Token cost can be high in heavy‑usage scenarios; requires conscious token budgeting.
Limited native Windows support; requires WSL or Git Bash.
Ideal Use Cases
Large‑scale project development – cross‑file refactoring, architecture analysis, complex bug hunting.
Automated workflows – CI/CD integration, code review, PR automation.
Multi‑task parallelism – background task handling for concurrent jobs.
Monorepo or micro‑service environments – --add-dir enables multi‑directory awareness.
Practical End‑to‑End Workflow (Spring Boot Auth Module Example)
# Navigate to project
cd my-spring-boot-project
# Start Claude Code
claude
# Initialise project knowledge base
/init
# Add project‑specific rules (e.g., coding style, security policies)
/memory
# Switch to Plan mode and ask for a design document
Shift+Tab # Cycle to Plan mode
> Design a JWT authentication module and output a design document.
# Review the design, then switch to Auto‑Accept for implementation
Shift+Tab # Cycle to Auto‑Accept mode
> Implement according to the design.
# Review changes and commit
/diff
/review
/commit
# Run compilation in background while continuing discussion
Ctrl+B # Send compilation task to background
# When the conversation grows long, check token usage and compress
/context
/compact retain authentication design
# Or start a fresh task
/clearConclusion
Mastering roughly 30 % of the most frequently used commands (session management, Git automation, model switching, and skill handling) covers over 80 % of everyday development scenarios. Start with session commands ( /init, /compact, /clear, claude -c), add Git helpers ( /commit, /review), then explore model selection ( /model) and extensions ( /skills, /mcp). With these tools Claude Code becomes a true all‑round development partner.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
