DEV Community

Sangmin Lee
Sangmin Lee

Posted on • Originally published at claudeguide.io

Claude Code Slash Commands: Complete Reference Guide

Originally published at claudeguide.io/claude-code-slash-commands-reference

Claude Code Slash Commands: Complete Reference Guide

Claude Code's slash commands control session state, context management, and built-in workflows. The most important ones: /clear (reset context), /compact (summarise context to free up space), /init (generate CLAUDE.md for a project), and /review (structured code review). Type / in Claude Code to see the full list in 2026. This guide explains each command, what it does internally, and when to use it.


Session management commands

/clear

Clears the current conversation context. Claude starts fresh with no memory of the current session.

When to use:

  • You've been working on one task and are switching to a different, unrelated task
  • The context has become confused or contradictory after a long session
  • You want to give Claude a clean state to approach a problem fresh

What it doesn't clear: file system state (files you've written/modified still exist). /clear only resets the conversation history.


/compact

Summarises the current conversation into a compressed context. Frees up context window space for more work.

When to use:

  • Claude is warning you that context is getting long
  • You've completed one phase of a task and are starting the next
  • You want to continue working without starting completely fresh (unlike /clear)

How it works: Claude generates a summary of the conversation so far and replaces the full history with the summary. Subsequent work continues from the summary context. Some detail is lost in compression — the more specific the earlier work, the more important it is to verify after compacting.


/cost

Shows the token usage and estimated cost for the current session.

When to use: monitoring spend during long sessions, especially before starting a potentially expensive operation.


Project setup commands

/init

Reads your project and generates a CLAUDE.md file with project context, directory structure, dev commands, and conventions.

When to use: first time using Claude Code on an existing project. Run this before starting work — it creates the context file that makes all subsequent Claude Code sessions more productive.

What it generates:

  • Project description (inferred from README and code)
  • Directory structure with descriptions
  • Key commands (install, dev, build, test)
  • Technology stack
  • Conventions inferred from the code

Always review and edit the generated CLAUDE.md — Claude's inferences are a starting point, not a final document.


/doctor

Checks your Claude Code installation and configuration for issues.

When to use:

  • After installing or upgrading Claude Code
  • When Claude Code is behaving unexpectedly
  • When investigating permission or configuration issues

Outputs a diagnostic report: Node version, SDK version, API key status, configuration files found.


Development workflow commands

/review

Runs a structured code review of your recent changes.

When to use: before committing or creating a pull request. Equivalent to asking a senior developer to review your diff.

What it reviews:

  • Correctness (bugs, logic errors)
  • Security concerns
  • Performance issues
  • Code style and conventions
  • Missing error handling
  • Test coverage gaps

Tip: run /review after a focused coding session, not during — it evaluates the complete diff, not individual lines.


/vim

Enables Vim keybindings in the Claude Code input field.

When to use: if you prefer Vim navigation for editing your prompts. Toggle with /vim to enable, /vim again to disable.


Context and memory commands

/memory

Manages Claude Code's persistent memory files. Claude Code can maintain notes across sessions in ~/.claude/memory/.

When to use:

  • After establishing important project preferences you want Claude to remember
  • For preferences that apply across multiple sessions (not just the current one)

Output and format commands

/output

Changes the output mode. Options include:

  • markdown — formatted markdown output (default)
  • plain — plain text without markdown formatting
  • json — structured JSON output

When to use: when piping Claude Code output to other tools that expect plain text or JSON.


Custom commands (CLAUDE.md slash commands)

You can define project-specific slash commands in your CLAUDE.md:

## Custom commands

/deploy: Run `vercel --prod --yes` after confirming the build passes
/check: Run typecheck, lint, and tests in sequence. Report any failures.
/ship: Run /check, then create a commit, then /deploy
Enter fullscreen mode Exit fullscreen mode

When you type /deploy in Claude Code, it executes the described workflow. This is the most powerful customisation feature — you define repeatable workflows once, then invoke them with a single command.

Examples of useful custom commands:


markdown
## Custom commands

/sync: Pull latest from main, rebase current branch, and report any conflicts

/audit: Check for unused dependencies, deprecated APIs, and TODO comments. 
        Report findings grouped by severity.

/docs: Update the JSDoc comments for any functions modified in the last commit.

/perf: Run the build and report bundle sizes. Flag any that increased by 

[→ Get Power Prompts 300 — $29](https://shoutfirst.gumroad.com/l/agfda?utm_source=claudeguide&utm_medium=article&utm_campaign=claude-code-slash-commands-reference)

*30-day money-back guarantee. Instant download.*
Enter fullscreen mode Exit fullscreen mode

Top comments (0)