Blog

Claude Code commands: built-in and custom slash commands

The built-in Claude Code commands worth learning first, grouped by when you use them, plus how to write your own slash commands with arguments and frontmatter.

Alex Mercer

Claude Code commands are slash commands you type at the start of a message, such as /init, /compact or /model, to control the session instead of asking Claude for code. Type / to see every command available to you; the core set covers setup (/init, /memory), context (/context, /compact, /clear), steering (/model, /plan) and recovery (/rewind, /resume), and you can add your own by saving a Markdown file in .claude/commands/.

For the wider setup, see our practical guide to using Claude Code. Command details come from Anthropic's commands reference and skills docs as of October 12, 2026. Commands change between versions, and many entries in the reference name the version they need, so /help is the final word for yours.

How slash commands work

  • Claude Code recognizes a command only when it starts your message. Text after the name becomes its arguments, as in /plan fix the auth bug.

  • A command you send while Claude is responding runs after the current turn. A few, such as /status, /tasks and /usage, run right away.

  • The / menu matches names and aliases, from the start of a name or from a word inside it, so /adddir finds /add-dir and /new finds /clear.

  • Availability depends on your platform, plan and environment. /desktop, for example, only shows on macOS and x64 Windows when you're signed in with a Claude subscription.

  • Some commands stay out of the menu until you type the full name, such as /heapdump.

  • Entries like /batch, /loop and /debug are bundled skills, prompts handed to Claude through the same mechanism as custom commands. Most built-in commands run fixed logic instead.

The built-in commands to learn first

The full reference has more than a hundred entries. These are the ones that come up in everyday work, grouped by when you'd use them, so this section doubles as a Claude Code cheat sheet.

Set up a project

Command

What it does

/init

Generates a starter CLAUDE.md from your codebase

/memory

Opens your CLAUDE.md files for editing and turns auto memory on or off

/permissions

Manages allow, ask and deny rules for tools. Alias: /allowed-tools

/mcp

Manages MCP server connections and OAuth sign-in

/config

Opens settings for theme, model, output style and more. /config model=sonnet sets a value without opening the panel. Alias: /settings

/import

Brings instruction files, MCP servers, commands, subagents and skills over from Codex, Gemini CLI or Cursor

The docs suggest this order for a first session in a repo: /init, then /memory to refine the file, /mcp for any servers the project needs, and /permissions for your approval rules. For what belongs in the file /init writes, see our guide to CLAUDE.md and AGENTS.md.

Manage context

Command

What it does

/context

Shows what's filling the context window as a colored grid, with suggestions for context-heavy tools and memory bloat

/compact [instructions]

Summarizes the conversation so far to free space. Optional instructions steer the summary

/clear

Starts a new conversation with empty context while keeping project memory. Aliases: /new, /reset

/btw [question]

Asks a side question without adding it to the conversation

When a conversation gets long, /context shows what's using the window and /compact frees space while you stay on the same task. When you move to a new task, /clear starts fresh.

Steer the model and the work

Command

What it does

/model [model]

Switches the model and saves it as your default. In the picker, press s to switch for this session only

/effort [level]

Sets how much reasoning Claude applies: low to xhigh, max (this session only) or auto

/plan [description]

Enters plan mode, optionally with a task: /plan fix the auth bug

/goal [condition]

Keeps Claude working across turns until the condition is met. /goal clear removes it

/loop [interval] [prompt]

Reruns a prompt while the session stays open, such as /loop 5m check if the deploy finished

When you pick a model, data on the code each one writes can help. cubic's Bug Bench ranks models used inside Claude Code by relative bug rate: counted bugs per AI-attributed line in code reviewed by cubic, divided by the rate across all AI-attributed lines, so 1.00 is average and lower is better. Claude Fable 5.1 has the lowest rate inside Claude Code (1.09), statistically tied with Claude Sonnet 5.5 (1.24), meaning their 95% confidence intervals overlap. Sonnet 5.5 is the newer of the two, so its rate rests on fewer weeks of data. The data is observational: teams choose their models, so a rate reflects the code each model was used for as well as the model. Bug Bench's Claude Opus 5.5 vs Claude Sonnet 5.5 comparison goes deeper on that choice. Whichever model you pick, review its code before it merges. Our guide to AI code review explains how AI review works, and how successful teams ship AI-generated code to production covers what happens after the code is written.

Undo, branch and resume

Command

What it does

/rewind

Rolls code and conversation back to a checkpoint, or summarizes from a chosen message. Aliases: /checkpoint, /undo

/resume [session]

Reopens an earlier conversation by ID or name, or from a picker. Alias: /continue

/branch [name]

Branches the conversation at this point so you can try another direction. The original stays available in /resume

/rename [name]

Names the session and shows the name on the prompt bar, so it's easy to resume by name

/diff

Shows the changes in your working tree, including Claude's edits

Run work in parallel

Command

What it does

/tasks

Lists the session's background work, including subagents that have finished. Also available as /bashes

/subtask <task>

Hands a side task to a background subagent that inherits the conversation; its result comes back here

/fork [prompt]

Copies the conversation into a new background session while you keep working in this one

/background [prompt]

Detaches the session to keep running in the background and frees your terminal. Alias: /bg

/batch <instruction>

Splits a large change into 5 to 30 independent units and, once you approve the plan, runs each in its own worktree

Check your setup and usage

Command

What it does

/help

Shows help and the commands available to you

/status

Shows version, model, account and connectivity

/usage

Shows session cost, plan usage limits and activity stats. Aliases: /cost, /stats

/doctor

Diagnoses installation and configuration problems and can fix them, asking before it changes anything. Alias: /checkup

/skills

Lists available skills

/hooks

Shows your hook configuration

Lesser-known commands worth trying

  • /powerup: short interactive lessons on Claude Code features, with animated demos.

  • /recap: a one-line summary of the current session.

  • /insights: an HTML report on your recent sessions on this machine, including where things go wrong and features to try.

  • /team-onboarding: a guide for a new teammate, built from your last 30 days of Claude Code usage.

  • /copy [N]: copies the last response, or the Nth-latest one, to the clipboard.

  • /export [filename]: saves the conversation as plain text.

Other things you can type at the prompt

  • ! at the start runs a shell command directly, adds its output to the session and has Claude respond to it.

  • @ opens file path autocomplete, so you can point Claude at a file.

  • ? on an empty prompt toggles the shortcut help panel.

  • MCP servers can expose prompts as commands. They're listed as /servername:promptname (MCP), and typing /mcp__servername__promptname also runs one.

  • Plugins add commands namespaced by plugin, as /plugin-name:skill-name.

Claude Code CLI commands you run in the terminal

"Claude Code commands" can also mean the claude CLI itself. The CLI reference lists every subcommand and flag. These are the everyday ones:

Command

What it does

claude

Starts an interactive session

claude "query"

Starts a session with a first prompt

claude -p "query"

Runs a query non-interactively, then exits

cat logs.txt | claude -p "explain"

Processes piped input

claude -c

Continues the most recent conversation in this directory

claude -r "<session>" "query"

Resumes a session by ID or name

claude update

Updates to the latest version

claude doctor

Prints installation and settings diagnostics without starting a session

claude mcp

Configures MCP servers

Custom slash commands

A custom command is a Markdown file whose contents become the prompt when you type its name. Save .claude/commands/deploy.md and /deploy exists.

Custom commands have been merged into skills. A file at .claude/commands/deploy.md and a skill at .claude/skills/deploy/SKILL.md both create /deploy and work the same way. Command files keep working, but the docs recommend a skill for new work, because a skill is a folder that can also hold supporting files such as reference docs and scripts. Everything below applies to both, and our guide to Claude Code skills covers the rest.

Where custom commands live

File

Command

Who gets it

.claude/commands/fix-issue.md

/fix-issue

Everyone in the repo, once you commit it

~/.claude/commands/fix-issue.md

/fix-issue

You, in every project

.claude/commands/frontend/component.md

/frontend:component

Subfolders become a : namespace

.claude/skills/fix-issue/SKILL.md

/fix-issue

The skill version, shared the same way

When names collide:

  • A skill and a command file with the same name: the skill runs.

  • The same skill name in your personal and project folders: the personal one runs.

  • A skill with the same name as a built-in command: in a local terminal session, yours replaces the built-in but not its aliases. A project usage skill replaces /usage, while /cost still runs the built-in.

If a new command doesn't show up in the / menu, run /reload-skills. It re-scans skill and command directories without a restart.

Pass arguments

Placeholder

Expands to

$ARGUMENTS

Everything typed after the command name

$ARGUMENTS[0] or $0

The first argument; $1 is the second, and so on

$name

A named argument from the arguments frontmatter list, by position

Arguments split shell-style, so quote multi-word values: /my-command "hello world" second sets $0 to hello world and $1 to second. If a file has no placeholder, Claude Code appends ARGUMENTS: <your input> to the end so Claude still sees what you typed. A missing indexed argument such as $2 stays in the text as written, while a missing named argument becomes an empty string. Write \$1.00 for a literal dollar amount.

Frontmatter

YAML frontmatter between --- lines at the top of the file configures the command. Every field is optional, and a command file accepts all the skill fields except name and paths. The ones you'll use most:

Field

What it does

description

What the command does and when to use it. Claude reads it to decide when to run the command itself

argument-hint

Hint shown in autocomplete, like [issue-number]

arguments

Names for positional arguments, used as $name

disable-model-invocation

true stops Claude from running the command on its own

allowed-tools

Tools Claude can use without asking during the turn that runs the command, such as Bash(git commit *)

model

Model to use for the rest of that turn

effort

Effort level while the command is active

context

fork runs the command in a subagent that doesn't see your conversation history

  • Claude can run your commands too. By default, both you and Claude can invoke a command, and Claude decides from the description. For anything with side effects, like committing or deploying, set disable-model-invocation: true.

  • allowed-tools only adds permissions. The grant covers the turn that runs the command and clears with your next message, and every other tool stays available under your normal permissions. Workspace trust doesn't gate it, so read the allowed-tools of commands checked into a repo before you run Claude Code there.

Pull in live data with !command

Write !`command` at the start of a line, or after a space, and Claude Code runs the command before Claude sees the file and puts the output in its place. For multi-line scripts, open a fenced block with ```! instead.

  • A failing command aborts the whole invocation. With the default bash shell, any non-zero exit counts, except exit code 1 from search and comparison commands. Append || true to a command you expect to exit non-zero.

  • Injected commands never prompt. Claude Code checks them against your permission rules, and outside auto mode anything that isn't allowed aborts the run, so pre-approve them with allowed-tools.

  • Setting "disableSkillShellExecution": true turns injection off for skills and custom commands from user, project, plugin and added directories.

Three example commands to copy

1. Fix a GitHub issue by number

Save as .claude/commands/fix-issue.md and run /fix-issue 482. It needs the gh CLI, signed in.

---
description: Fix a GitHub issue by number
argument-hint: "[issue-number]

---
description: Fix a GitHub issue by number
argument-hint: "[issue-number]

---
description: Fix a GitHub issue by number
argument-hint: "[issue-number]

Claude runs gh with its normal tools here, so it asks first unless your permission rules already allow it.

2. Commit with a message written from the diff

Save as .claude/commands/commit.md and run /commit, or /commit closes #482 to add context.

---
description: Commit the current changes with a Conventional Commits message
argument-hint: "[extra context]

---
description: Commit the current changes with a Conventional Commits message
argument-hint: "[extra context]

---
description: Commit the current changes with a Conventional Commits message
argument-hint: "[extra context]

The two ! lines run before Claude reads the prompt, so it starts from the real diff. allowed-tools pre-approves them, plus git add and git commit, for that turn only.

3. Scaffold a component with named arguments

Save as .claude/commands/frontend/component.md. The subfolder makes it /frontend:component, so run /frontend:component PriceTag ui.

---
description: Scaffold a React component with a test
argument-hint: "<ComponentName> <folder>"
arguments: [name, folder]

---
description: Scaffold a React component with a test
argument-hint: "<ComponentName> <folder>"
arguments: [name, folder]

---
description: Scaffold a React component with a test
argument-hint: "<ComponentName> <folder>"
arguments: [name, folder]

$name and $folder take the first and second arguments. To turn any of these into a skill, move the file to .claude/skills/<command-name>/SKILL.md, and the folder name (or a name field) becomes the command.

FAQ

What are some useful Claude Code commands?

Start with /init to create a CLAUDE.md, /context and /compact to manage the context window, and /clear between tasks. Add /model and /plan to steer the work and /rewind to undo it. /help lists everything available in your version.

What are some secret commands in Claude Code?

There's no secret set, but Claude Code keeps a few commands out of the / menu by design, such as /heapdump, which writes a memory snapshot for diagnosing high memory use. They run once you type the full name. Others are just easy to miss: /btw for side questions, /powerup for interactive lessons and /insights for a report on your recent sessions.

Can Claude Code run my custom slash commands on its own?

Yes. By default both you and Claude can invoke a custom command or skill, and Claude uses its description to decide when one fits. Add disable-model-invocation: true to the frontmatter of commands with side effects, so only you can trigger them.

How do I use Claude Code effectively?

Anthropic's best practices page starts with giving Claude a way to verify its work, such as tests it can run, and with exploring and planning before it writes code. From there, keep CLAUDE.md short, manage context with /clear and /compact, and use /rewind to course-correct early when a session drifts.

Table of contents