Foundations/Getting Started
★ OverviewBeginner14 min

Claude Code Commands — Every Command Explained

A comprehensive reference to every slash command in Claude Code. Grouped by category — session management, project setup, review & quality, and utility — with practical examples showing when and why to use each one.

Quick Reference

  • /help — Show all available commands and keyboard shortcuts
  • /clear — Reset conversation context to free up the context window
  • /compact — Summarize the conversation to reclaim context space without losing important details
  • /init — Generate a CLAUDE.md file for the current project based on codebase analysis
  • /memory — Open and edit your CLAUDE.md memory files directly
  • /review — Run an AI-powered code review on your current changes
  • /cost — Display token usage and estimated cost for the current session
  • /doctor — Diagnose environment issues (API keys, permissions, tool availability)
  • /login and /logout — Manage authentication with your Anthropic account
  • /status — Show current model, context usage, and session info
  • /plan — Enter Plan Mode to reason through a task before writing code
  • /think — Ask Claude to reason step-by-step without taking action

Why Commands Matter

Claude Code is not just a chat interface — it is an agentic coding assistant with a rich command vocabulary. Slash commands give you precise control over the session, the context window, project configuration, and output quality. Learning the commands is the difference between fighting the tool and flowing with it.

Commands vs. Natural Language

You can always ask Claude to do something in plain English, but slash commands are faster, deterministic, and bypass the LLM entirely for operations like clearing context or checking cost. Use commands for session control; use natural language for creative work.

Session Management

These commands control the lifecycle of your conversation with Claude Code. They help you manage context, keep sessions focused, and avoid hitting context-window limits mid-task.

CommandWhat It DoesWhen to Use
/clearWipes the entire conversation history and starts freshWhen you switch to a completely different task or the conversation has become cluttered
/compactSummarizes the conversation into a shorter form, preserving key decisionsWhen the context window is getting full but you still need the conversation's context
/statusShows current model, context usage percentage, and session metadataWhen you want to check how much context you have left before starting a big task
/costDisplays token counts and estimated dollar cost for the sessionPeriodically during long sessions to monitor spend
Typical context management flow during a long session
/compact vs. /clear

/compact keeps a summary of what you discussed — decisions, file paths, architecture choices. /clear erases everything. Use /compact when the conversation is still relevant; use /clear when you are starting something entirely new.

Project Setup

These commands help you configure Claude Code for your specific project. Running them early in a new repo saves time on every subsequent session.

CommandWhat It DoesWhen to Use
/initScans your codebase and generates a CLAUDE.md with project conventions, tech stack, and common patternsFirst time using Claude Code in a new repo
/memoryOpens your CLAUDE.md files for direct editing — supports both project-level and user-level memoryWhen you need to add or update project conventions, coding standards, or preferences
/loginAuthenticate with your Anthropic account or API keyFirst-time setup or after token expiry
/logoutSign out of the current Anthropic accountWhen switching accounts or for security
Setting up Claude Code in a new project
Always Review /init Output

The /init command does a best-effort analysis. It might miss conventions or infer incorrect patterns. Always review and edit the generated CLAUDE.md before committing it to the repo.

Review & Quality

Claude Code includes built-in review capabilities that go beyond simple linting. The /review command performs a holistic code review considering correctness, security, performance, and style.

CommandWhat It DoesWhen to Use
/reviewRuns an AI-powered review on staged or unstaged changes, reporting issues by severityBefore committing code, during PR preparation, or as a second pair of eyes
/review catches issues across multiple dimensions
Pair /review with CLAUDE.md

When your CLAUDE.md includes project-specific conventions (e.g., 'always use Result types for errors'), /review will enforce those conventions in addition to general best practices.

Reasoning & Planning

These commands shift Claude Code into a higher reasoning gear. Instead of immediately writing code, Claude will think through the problem, consider tradeoffs, and propose a plan before acting.

CommandWhat It DoesWhen to Use
/planEnters Plan Mode — Claude reads your codebase, reasons about the task, and outputs a step-by-step plan before writing any codeComplex features, refactors, or any task touching 3+ files
/thinkAsks Claude to reason step-by-step about a question without modifying filesArchitecture decisions, debugging, or when you want analysis without action
Using /plan and /think for deliberate, reasoned work
Plan First, Execute Second

For any task that touches more than two or three files, start with /plan. The upfront reasoning cost is tiny compared to the cost of undoing a poorly thought-through change across your codebase.

Utility Commands

These commands handle diagnostics, help, and other operational needs that keep Claude Code running smoothly.

CommandWhat It DoesWhen to Use
/helpLists all available commands, keyboard shortcuts, and usage tipsWhen you forget a command or want to discover new features
/doctorRuns diagnostic checks — API connectivity, file permissions, tool availability, config validityWhen Claude Code is behaving unexpectedly or after environment changes
/bugFiles a bug report with Anthropic, automatically including relevant session contextWhen you encounter a reproducible bug in Claude Code itself
/fastToggles between the default model and a faster, cheaper model for simpler tasksWhen you need quick answers for simple questions and want to save tokens
/doctor is your first debugging step when things go wrong

Command Chaining Patterns

While commands cannot be literally chained with pipes, experienced Claude Code users develop reliable sequences — command patterns they run in a predictable order for common workflows.

1

New Project Setup

/login (if needed) then /init to generate CLAUDE.md, then /memory to review and refine it

2

Pre-Commit Review

/review to catch issues, fix them, then /cost to see how much the session used

3

Context Recovery

/status to check context usage, /compact if above 60%, /clear if you are starting a new task entirely

4

Complex Feature

/plan to outline the approach, implement step by step, /review before committing, /compact to reclaim context

Build Muscle Memory

The most productive Claude Code users have a small set of command sequences they run automatically. Start with the pre-commit sequence: /review then fix then commit. It catches surprising issues.

Complete Quick Reference

CommandCategoryOne-Liner
/helpUtilityShow all commands and shortcuts
/clearSessionWipe conversation and start fresh
/compactSessionSummarize conversation to save context
/initSetupGenerate CLAUDE.md from codebase analysis
/memorySetupEdit CLAUDE.md memory files
/reviewQualityAI-powered code review on changes
/costSessionShow token usage and cost
/doctorUtilityDiagnose environment problems
/loginSetupAuthenticate with Anthropic
/logoutSetupSign out
/statusSessionShow model, context, session info
/bugUtilityFile a bug report
/fastUtilityToggle faster/cheaper model
/planReasoningEnter Plan Mode for complex tasks
/thinkReasoningReason step-by-step without acting

Best Practices

Best Practices

Do

  • Run /init when you first open Claude Code in a new repository
  • Use /compact proactively before the context window fills up — check with /status
  • Use /plan before any task that touches more than two or three files
  • Run /review before every commit as a quality gate
  • Use /think when you want analysis or architecture advice without code changes
  • Check /cost periodically during long sessions to avoid surprise bills
  • Run /doctor as a first step when Claude Code behaves unexpectedly

Don’t

  • Don't use /clear when you need the conversation context — use /compact instead
  • Don't skip /init and rely on generic behavior — project-specific context dramatically improves output
  • Don't ignore /review suggestions without understanding them — they often catch real bugs
  • Don't forget to review the CLAUDE.md generated by /init before committing it
  • Don't use /plan for trivial one-file changes — it adds overhead without value
  • Don't run /compact after every message — only when context is getting full

Key Takeaways

  • Slash commands give you deterministic control over session lifecycle, project setup, and quality checks
  • /compact and /clear manage your most precious resource: the context window
  • /init and /memory are the foundation of project-specific AI assistance
  • /plan and /think shift Claude into deliberate reasoning mode for complex tasks
  • /review is a surprisingly effective pre-commit quality gate
  • /doctor should be your first stop when troubleshooting
  • Building command sequences into your workflow makes Claude Code dramatically more effective

Video on this topic

Claude Code Commands in 60 Seconds

tiktok