Slash Commands
Claude Code has a set of built-in slash commands — shortcuts that trigger specific behaviours without needing a full natural language prompt. These cover common session management tasks and useful code tools.
Core Commands
/init
Generates a CLAUDE.md file for the current project. Claude Code explores the codebase, identifies key files, commands, and conventions, and writes a structured CLAUDE.md. Run this once when setting up Claude Code for a new project — it gives Claude useful context in every future session.
/compact
Compresses the conversation history to save context window space. Claude Code summarises prior exchanges and replaces them with a condensed version. Use this in long sessions when the context window starts to fill up — prevents the earliest conversation turns from being dropped.
/clear
Clears the conversation history and starts a fresh context in the same session. Use when switching to an unrelated task mid-session or when accumulated context is creating confusion. CLAUDE.md is re-read after /clear.
/help
Lists all available slash commands with brief descriptions. Also shows shortcuts for current session settings.
Code & Review Commands
/review
Runs a code review of the current changes (unstaged + staged git changes by default). Produces a structured review covering correctness, security, and style. Equivalent to asking "Review my current changes" but with a consistent format.
/pr
Generates a pull request description from the current branch's changes. Reads the commit history and diff, then writes a summary, change list, and testing notes. Copy this into your GitHub/GitLab PR description as a starting point.
/commit
Generates a git commit message from the current staged changes. Follows conventional commit format by default. Review the message before running git commit with it.
Memory & Config Commands
/memory
Opens the memory management interface — shows current memory files, lets you add, edit, or remove memory entries. Use this to inspect what Claude Code remembers about your project and working preferences.
/config
Opens or shows the current Claude Code settings — model selection, permission modes, allowed tools. Most settings are better managed in settings.json directly, but /config provides a quick view.
Custom Slash Commands
You can define your own slash commands in CLAUDE.md or settings.json. Custom commands are shortcuts to frequently used prompts:
// In settings.json
"customSlashCommands": [
{
"name": "lint-fix",
"description": "Run eslint --fix on all changed files",
"prompt": "Run eslint --fix on all files modified in the current git diff"
}
]Custom commands defined in CLAUDE.md are project-specific. Commands defined in your global settings.json apply across all projects.
Checklist: Do You Understand This?
/init— generates CLAUDE.md for the project; run once when setting up Claude Code on a new codebase/compact— compresses conversation history to save context; use in long sessions/clear— fresh context without ending the session; use when switching to an unrelated task/review,/pr,/commit— code-focused commands for review and git workflow- Custom slash commands can be defined per-project (CLAUDE.md) or globally (settings.json)