Claude Code Commands Reference


A technical reference for all built-in slash commands available in Claude Code.

---

Session Management


| Command | Description |
|---------|-------------|
| /clear | Clears the entire conversation history. Your files and CLAUDE.md are preserved, but all conversational context is deleted. Use when switching tasks. |
| /compact [instructions] | Compresses the conversation into a structured summary, reducing context usage by 50–70%. Optionally pass focus instructions (e.g., /compact focus on refactoring). Best used when context exceeds ~80,000 tokens. |
| /exit | Exits the Claude Code REPL session. |
| /resume | Resume a previous conversation from where you left off. |
| /rewind | Rewinds the conversation and/or code changes to a previous state. Use cautiously — repeated use can remove multiple exchanges. |

---

Project Initialization & Memory


| Command | Description |
|---------|-------------|
| /init | Analyzes your codebase (package files, configs, structure) and generates a CLAUDE.md file tailored to your project. Run once per project. Warning: Running on a project with an existing CLAUDE.md may overwrite your customizations — back up first. |
| /memory | Opens your CLAUDE.md memory files for direct editing. Changes persist across sessions. |

---

Context & Cost Monitoring


| Command | Description |
|---------|-------------|
| /context | Visualizes current context window usage as a colored grid. Shows loaded files, skills, and remaining capacity. Also warns if skills have been excluded due to character budget limits. |
| /cost | Displays cumulative token usage (input/output) and estimated cost in dollars for the current session. Check regularly to manage API spend. |
| /usage | Shows plan usage limits and rate limit status. Available on subscription plans only. |

---

Model & Configuration


| Command | Description |
|---------|-------------|
| /model | Switch between available models (e.g., Sonnet 4.5, Opus 4.6, Haiku 4.5) during a session. |
| /config | Opens the Settings interface (Config tab) for editing Claude Code configuration. |
| /permissions | View or update tool permissions — controls what Claude is allowed to do (file edits, bash commands, etc.). |
| /output-style [style] | Set the output style. Options include Explanatory, Learning, or Custom. Can also be selected from a menu. |
| /privacy-settings | View and update your privacy settings. |

---

Code Review & Quality


| Command | Description |
|---------|-------------|
| /review | Requests a code review of your current changes. Claude analyzes your code for quality, bugs, and improvements. |
| /security-review | Performs a complete security review of pending changes on the current branch. |
| /pr-comments | View pull request comments from GitHub/GitLab. |

---

Authentication


| Command | Description |
|---------|-------------|
| /login | Switch Anthropic accounts or re-authenticate. |
| /logout | Sign out from your Anthropic account. |

---

Diagnostics & Troubleshooting


| Command | Description |
|---------|-------------|
| /doctor | Runs a health check on your Claude Code installation. First command to run when experiencing unexpected behavior. |
| /status | Opens the Settings interface (Status tab) showing version, model, account, and connectivity info. |
| /help | Displays all available slash commands (built-in + custom) with descriptions. Use /help for details on a specific command. |
| /bug | Reports a bug to Anthropic — sends your current conversation for analysis. |

---

Agents & Tasks


| Command | Description |
|---------|-------------|
| /agents | Manage custom AI subagents for specialized tasks (e.g., code review agent, architecture agent). |
| /bashes | List and manage background tasks running in the session. |
| /todos | List current todo items tracked in the session. |

---

Integrations


| Command | Description |
|---------|-------------|
| /install-github-app | Sets up Claude GitHub Actions for a repository. Enables automatic PR reviews. Adds a claude-code-review.yml config you can customize. |
| /mcp | Manage MCP (Model Context Protocol) server connections. View status, authenticate with OAuth-enabled servers, and browse available tools/prompts. |
| /plugin | Manage Claude Code plugins — install, enable, disable, or remove plugins from marketplaces. |
| /ide | Manage IDE integrations (VS Code, JetBrains) and show connection status. |
| /hooks | Opens an interactive interface for managing hook configurations. Hooks are shell commands that execute on tool events (PreToolUse, PostToolUse, Notification, Stop). |

---

Utilities


| Command | Description |
|---------|-------------|
| /add-dir | Add additional working directories to the current session. Useful for monorepos or multi-project work. |
| /export [filename] | Export the current conversation to a file or clipboard. Useful for documentation or sharing. |
| /sandbox | Enable sandboxed bash tool with filesystem and network isolation. Reduces permission prompts while improving safety. |
| /vim | Enter vim mode for alternating insert and command modes. |
| /terminal-setup | Install Shift+Enter key binding for newlines (iTerm2 and VS Code terminals only). |
| /statusline | Set up Claude Code's status line UI in the terminal. |
| /release-notes | View release notes for the current Claude Code version. |

---

Custom Slash Commands


You can create your own slash commands by placing Markdown files in specific directories.

Locations


| Scope | Directory | Visibility |
|-------|-----------|------------|
| Project | .claude/commands/ | Shared with your team via version control |
| Personal | ~/.claude/commands/ | Available across all your projects |

Creating a Command

bash

Project command

mkdir -p .claude/commands
echo "Analyze this code for performance issues:" > .claude/commands/optimize.md

Personal command

mkdir -p ~/.claude/commands
echo "Review this code for security vulnerabilities:" > ~/.claude/commands/security-check.md

Using Arguments

markdown

.claude/commands/fix-issue.md

Fix issue #$ARGUMENTS following our coding standards


Usage: /fix-issue 123 high-priority

For individual positional arguments, use $1, $2, etc.:
markdown

.claude/commands/review-pr.md

Review PR #$1 with priority $2 and assign to $3


Usage: /review-pr 456 high alice

Frontmatter Options


Custom commands support YAML frontmatter for additional configuration:
markdown

---
allowed-tools: Bash(git add:), Bash(git status:), Bash(git commit:*)
argument-hint: [message]
description: Create a git commit
model: claude-3-5-haiku-20241022
disable-model-invocation: false
---

Create a git commit with message: $ARGUMENTS


| Field | Purpose | Default |
|-------|---------|---------|
| allowed-tools | Tools the command can use | Inherits from conversation |
| argument-hint | Hint shown during autocomplete | None |
| description | Brief description | First line of the prompt |
| model | Specific model to use | Inherits from conversation |
| disable-model-invocation | Prevent Claude from auto-invoking this command | false |

Special Prefixes


| Prefix | Purpose | Example |
|--------|---------|---------|
| ! | Execute bash commands (output included in context) | !\`git status\`` |
| @ | Reference file contents | @src/utils/helpers.js |

---

Keyboard Shortcuts (Interactive Mode)


| Shortcut | Action |
|----------|--------|
| Ctrl+C | Cancel current operation |
| Ctrl+R | Search command history |
| Tab | Toggle thinking mode |
| Shift+Tab | Toggle between modes (press twice for Plan Mode) |
| EscEsc | Rewind last exchange |
| Cmd+T | Extended thinking |
| Cmd+P | Model picker |
| Ctrl+G | Open external editor |
| # + text | Quick memory add (inline) |
| @ + path | File autocomplete |
| ! + command | Direct bash execution |

---

Recommended Command Workflows

Starting a new project:


/login → /init → /model → start working

Mid-session context management:


/cost → /compact → /cost

Troubleshooting:


/doctor → /clear → /login

End of session:


/cost → /memory → /logout


---
Source: Claude Code Official Docs — Last updated: February 2026