# Claude Code has over a hundred commands. You only need 27

> The 27 Claude Code commands that matter, grouped by moment of the day and with a pro tip each, plus how to write your own without the most common security holes.

- URL: https://stocasticparrot.ai/en/tutorials/claude-code-commands/
- Author: Danilo Giudice
- Published: 2026-11-07

There are [over 100 commands](https://code.claude.com/docs/en/commands) in Claude Code, and some were new even to me, but they’re the handbook for anyone who works from the terminal. I gathered the 27 that matter, grouped by category and function, with the pro tip 💡 I use most. **The spoiler:** if you make it to the end, every moment of the day has its own command, and you can write your own without opening the most common security holes.

If you already know the commands, jump from one 💡 to the next.

Three prefixes matter in the Claude Code prompt, explained on the [interactive mode page](https://code.claude.com/docs/en/interactive-mode): `/` runs a command, `!` sends the line straight to the shell (the output goes into the session and Claude comments on it), and `@` mentions a file. Did you know that a command only counts at the start of the message? Whatever you type after it is its argument. And some commands are *skills*: they don’t run fixed logic, they give the model a set of written instructions. In step 7 you write one of your own.

## 1. First session in a project

### /init

Run it the first time you open Claude Code in a project. It reads the code and writes a starter `CLAUDE.md`, the instructions file Claude Code loads in every session. Treat the file as a draft: you run the command once, then it’s yours to maintain.

Inside Claude Code:
```
/init
```

> 💡 Pro tip: **With `CLAUDE_CODE_NEW_INIT=1`, the setup turns interactive.** Run `CLAUDE_CODE_NEW_INIT=1 claude` and `/init` also walks you through skills, hooks (commands that run on their own at certain events), and personal memory files. If it finds a Codex or Gemini CLI configuration, it offers to import it.

### /memory

Opens your `CLAUDE.md` files for editing and manages auto-memory, the notes Claude Code writes on its own. You need it when an instruction has to change and you don’t remember which file it’s in.

Inside Claude Code:
```
/memory
```

> 💡 Pro tip: **If Claude “remembers” something wrong, look here.** `/memory` lets you read the auto-memory entries and turn it on or off. `CLAUDE.md` is re-read on every request: if it has become a novel, in [Claude Code hygiene](https://stocasticparrot.ai/en/explainers/claude-code-hygiene/) I explain how to put it on a diet.

### /permissions

Alias: `/allowed-tools`.

Opens the permission rules, explained on the [permissions page](https://code.claude.com/docs/en/permissions): allow (the tool runs without asking), ask (it asks every time), deny (forbidden). You’ll also find the working directories and the recent auto mode blocks (in auto mode, a classifier lets tools through, not you). Open it when the same confirmation keeps coming back: an allow rule removes it.

Inside Claude Code:
```
/permissions
```

> 💡 Pro tip: **You can block a single skill.** Add a deny rule, `Skill(deploy)`, and Claude can no longer run the `deploy` skill on its own. A `Skill` rule with no name blocks them all.

### /mcp

Manages MCP servers, the programs that connect Claude Code to external services like GitHub or Jira, and their OAuth logins, as the [MCP page](https://code.claude.com/docs/en/mcp) explains. With no arguments, it shows the servers and their status: if an external service stops responding, look here first.

Inside Claude Code:
```
/mcp
```

> 💡 Pro tip: **Reconnect a server without leaving the session.** If GitHub disconnected, run `/mcp reconnect github`; if they all disconnected, `/mcp reconnect all`. With `enable` and `disable` you turn them on and off.

## 2. While you work

While Claude is working, a command goes into a queue and runs at the end of the turn. Some run right away, including `/btw`, `/model`, `/effort`, and `/usage`.

### /plan

Before touching a file, Claude explores the project and hands you a work plan: in plan mode it normally doesn’t change the source files, and the plan is saved as a file in `~/.claude/plans/`. If you write the task after the command, it starts right away. Use it before a change that touches many files, and to get an unfamiliar project explained without risking edits. According to the [model configuration page](https://code.claude.com/docs/en/model-config), with the `opusplan` model Opus plans and Sonnet executes. When the plan is ready, `Ctrl+G` opens it in your editor so you can rewrite it; then you choose: Claude starts in auto mode, starts but you confirm every edit, or stays in plan mode and you ask for corrections.

Inside Claude Code:
```
/plan move the form validation into a shared module
```

> 💡 Pro tip: **Plan mode doesn’t mean read-only.** To explore, Claude can run shell commands. And if you started Claude Code with `--dangerously-skip-permissions`, the block on edits becomes just an instruction: the [permission modes page](https://code.claude.com/docs/en/permission-modes) says so.

### /context

Shows, in a colored grid, what fills the context, meaning everything the model has in front of it on every request. It adds suggestions when something takes up too much space. Run it when you have to decide whether to keep going, compact, or start over. With `all`, it opens the full-screen detail, item by item.

Inside Claude Code:
```
/context all
```

> 💡 Pro tip: **Look at the “Skills” row.** The descriptions of the skills Claude can run on its own sit in the context on every request. You control the context, so check it often: [Claude Code hygiene](https://stocasticparrot.ai/en/explainers/claude-code-hygiene/) shows how to measure and trim it.

### /compact

Summarizes the conversation so far and frees up context. After the command you can write what the summary must keep: that way you decide what survives. Run it when you finish a part of the work and want to keep going in the same session.

Inside Claude Code:
```
/compact keep the plan and the test commands
```

> 💡 Pro tip: **Compact by hand, before auto-compaction does it for you.** That’s the summary Claude Code makes on its own when the window is almost full, without asking what to keep. You control the context: I keep auto-compaction off, [here’s why](https://stocasticparrot.ai/en/explainers/auto-compaction/) and [here’s how](https://stocasticparrot.ai/en/tutorials/turn-off-auto-compaction/).

### /btw

A quick question (*by the way*) about the session, even while Claude is working, without stopping it. The answer appears in a box you can close, and it doesn’t become part of the conversation: the context stays as it was. Use it to ask where things stand, or to have a step explained again.

Inside Claude Code:
```
/btw which file were you editing?
```

> 💡 Pro tip: **It has no tools.** It doesn’t read files or run commands: it answers only with what’s already in the conversation. If you need more, press `f` and the question becomes a subagent, another instance of Claude that works in parallel, with all the tools.

### /model

Changes the model and saves it as the default for new sessions. With no argument, it opens a picker; with the model’s name, it goes straight to it. Use it when the task calls for a more powerful model, or when a lighter one is enough.

Inside Claude Code:
```
/model
```

> 💡 Pro tip: **In the picker, `s` changes it for this session only.** Handy for a hard task, without touching the default. If you change it while Claude is answering, it applies from the next request.

### /effort

Sets the model’s *effort*, meaning how much work it puts in before answering you: from `low` to `xhigh`, then `max` and `auto`. Raise it for a hard bug, lower it for quick questions. If you change it mid-turn, it applies from the next message.

Inside Claude Code:
```
/effort high
```

> 💡 Pro tip: **`max` lasts for this session only.** You won’t find it in the next one. And if you don’t remember which level you’re on, `/effort status` prints it.

### /usage

Aliases: `/cost`, `/stats`.

Shows session costs, your plan’s limits, and usage statistics on a single screen. It runs right away, even while Claude is working: check it when you’re getting close to the limits, or before you start a long job.

Inside Claude Code:
```
/usage
```

> 💡 Pro tip: **It tells you where the usage goes.** With a Claude plan it breaks it down by skill, subagent, plugin, and MCP server, and suggests changes for long contexts and cache misses (context re-read from scratch) once they reach 10%, as the [costs page](https://code.claude.com/docs/en/costs) explains.

### /goal

You tell it when the work is done, and Claude keeps going on its own until it is. After each turn a second model reads the conversation and checks the condition: if it isn’t true yet, Claude carries on. The [goal page](https://code.claude.com/docs/en/goal) recommends it for long jobs with a verifiable end, like migrating a module to a new API until every call compiles and the tests pass.

It also runs from a script, with no interface, using `claude -p "/goal …"`, and it survives resuming the session. `/goal clear` removes it. The second model doesn’t run commands or open files: write a condition that Claude’s output can prove. The goal doesn’t change permissions: you need auto mode, the terminal’s default (from a script, add `--permission-mode auto`).

Inside Claude Code:
```
/goal npm test passes with no errors and no existing test was modified; or stop after 20 turns
```

> 💡 Pro tip: **“Stop after 20 turns” is judged by the second model.** It relies on the conversation, where Claude reports its progress every turn. For a hard cap on turns or spending from a script, use `--max-turns` and `--max-budget-usd`, covered in the [CLI reference](https://code.claude.com/docs/en/cli-reference).

## 3. In parallel

### /background

Alias: `/bg`.

Detaches the session and lets it work on its own: the terminal is free again, and you can even close it. The text after the command is the last instruction before detaching; if Claude was answering, the answer carries on. Its background commands, subagents, and `/loop`s move with it.

From the shell, `claude agents` shows all the background sessions on one screen: which are working and which are waiting for your answer. It’s still a *research preview*, as the [agent view page](https://code.claude.com/docs/en/agent-view) explains. Two warnings. Every session counts against your plan’s limits like a normal one. And the one you detach with `/background` doesn’t move to a separate copy: it keeps editing the files where it was, and if you edit them in the meantime, you risk conflicts.

Inside Claude Code:
```
/background run all the tests and fix the ones that fail
```

> 💡 Pro tip: **There’s a gesture too: left arrow, on an empty line.** Background sessions show up in `/resume` with the label “bg”.

### /tasks

Alias: `/bashes`.

Shows and manages this session’s background work: long-running commands and subagents, including finished ones. It runs right away, even while Claude is answering. Open it when you want to know what’s still running, or to stop something you no longer need.

Inside Claude Code:
```
/tasks
```

> 💡 Pro tip: **It’s not Claude’s to-do list.** That one opens with `Ctrl+T`. Here you only find the work running behind the scenes.

### /subtask

Sends a subagent off in parallel. It starts with the whole conversation as it is now, so you don’t have to explain anything again. It works in the background while you keep going, and its steps stay out of your context: when it’s done, only the result comes back into the conversation. The example from the [subagents page](https://code.claude.com/docs/en/sub-agents) is the one below: the subagent writes the tests for the changes made so far, while you keep implementing. While it works, it shows up in a panel under the prompt: `Enter` opens its transcript and lets you write to it; `x` stops it. Watch the files it touches: `/rewind` usually doesn’t undo its changes, and the documentation doesn’t say it works in a separate copy.

Inside Claude Code:
```
/subtask write the unit tests for the parser changes made so far
```

> 💡 Pro tip: **Until July 2026, `/fork` did this.** The [changelog](https://code.claude.com/docs/en/changelog) for 2.1.212 says so. If an old guide tells you to use `/fork` to send a subagent, it means `/subtask`. Today `/fork` does something else: you’ll find it in step 5.

### /batch

Takes a large change that cuts across the whole project and splits it among many subagents working in parallel, as the [commands page](https://code.claude.com/docs/en/commands) says. First it explores the code and breaks the work into 5–30 independent units. Then it launches one subagent per unit, each in its own worktree, meaning a separate working copy of the repository, so they don’t get in each other’s way. Each subagent does its part, runs the tests, and opens a PR (a proposed change), or tells you how it went. If the parts depend on each other, it’s not the right tool.

Inside Claude Code:
```
/batch migrate src/ from JavaScript to TypeScript
```

> 💡 Pro tip: **Before launching the subagents, it shows you the plan and waits for your go-ahead.** Read it carefully: each unit becomes a subagent that uses tokens, and you review the PRs. You need a git repository, or a `WorktreeCreate` hook that creates the working copies.

### /loop

Alias: `/proactive`.

Acts as your lookout: it repeats a prompt at intervals to watch something that changes on its own, like a deploy or a PR.

- With an interval (`10m`, `2h`, `1d`), the pace is fixed.
- Without an interval, Claude picks it, from one minute to an hour: short if a build is finishing, long if all is quiet.
- Without a prompt, it looks after the branch’s PR: review comments, failed automated checks, conflicts.
- Instead of the prompt, you can pass one of your skills: `/loop 20m /review-pr 1234`.

It only runs while the session is open, or in the background with `/bg`. Resume it and fixed-interval loops come back. Either way, a loop expires after 7 days, says the [scheduled tasks page](https://code.claude.com/docs/en/scheduled-tasks). Each pass is a turn that uses tokens.

Inside Claude Code:
```
/loop 5m check if the deploy has finished and tell me how it went
```

> 💡 Pro tip: **`Esc` doesn’t stop a fixed-interval loop.** Neither does `Ctrl+C`: ask Claude to cancel it, for example “cancel the deploy loop.” `Esc` only stops the loop with no interval, while it waits for the next pass.

## 4. Before you ship

### /diff

Shows the changes you haven’t committed yet, including Claude’s, and breaks them down turn by turn too. Check it before every commit, to see what really changed.

Inside Claude Code:
```
/diff
```

> 💡 Pro tip: **The per-turn view doesn’t come from git.** It comes from the edits Claude makes with its own tools: a file changed by a shell command only shows up in “Current”.

### /code-review

Alias: `/review`.

Gives you a reviewer that didn’t watch the code being written: it runs in the background, in a subagent that can’t see the conversation, as the [local review page](https://code.claude.com/docs/en/code-review-local) and the [skills page](https://code.claude.com/docs/en/skills) explain. It looks for bugs and reports back when it’s done.

- With no arguments, it looks at the changes on your branch, including uncommitted ones; otherwise you give it a PR, as in the example below (level `high`, PR 1234), a commit range, or a folder.
- Levels go from `low` (fewer results, fewer false positives) to `max`, which widens the search.
- With `--fix` it applies the fixes, which go through your permissions; with `--comment` it posts results as PR comments.

Changes from a background `--fix` can’t be undone with `/rewind`: for those you need git.

Inside Claude Code:
```
/code-review high 1234
```

> 💡 Pro tip: **`ultra` moves the review to the cloud, and it costs.** Every bug is reproduced and verified. As of November 2026, the [ultrareview page](https://code.claude.com/docs/en/ultrareview) lists three free one-time runs on Pro, Max, and Ultra plans, then usually $5–25 per review. It needs a claude.ai login.

### /security-review

Looks for vulnerabilities in your branch’s changes: injection (outside input that ends up inside a command or a query), authentication problems, and exposed data. `/code-review` looks for correctness bugs; this one looks for security holes. Run it before opening a PR, especially if you touched the login or user data.

Inside Claude Code:
```
/security-review
```

> 💡 Pro tip: **It needs a remote named `origin`.** A remote is the link to the online repository: `/security-review` compares your branch with the main branch of `origin`, and without that remote it won’t start.

## 5. Between sessions

### /clear

Aliases: `/new`, `/reset`.

Opens a new conversation with an empty context: nothing you and Claude said reaches the next request. The project memory stays, and the previous conversation stays on disk: you pick it back up with `/resume`. As long as you haven’t closed Claude Code, you can also get back to it from the `/rewind` menu.

Inside Claude Code:
```
/clear
```

> 💡 Pro tip: **Name the conversation you’re leaving.** With `/clear login-fixed` you’ll find it in `/resume` under that name. Watch out: it also removes an active `/goal`. Here’s what I do: one task, one session. You control the context, and [hygiene](https://stocasticparrot.ai/en/explainers/claude-code-hygiene/) starts here.

### /resume

Alias: `/continue`.

Picks up an earlier conversation, with all its context. With no argument it opens the list of sessions; with a name or an ID it goes straight to it. Use it for jobs that last several days: yesterday’s session resumes where you left off. From the shell, you do the same with `claude --resume` and the name.

Inside Claude Code:
```
/resume login-fixed
```

> 💡 Pro tip: **It works with background sessions too.** If the one you’re looking for is still running, `/resume` attaches you to it and sends the one you’re in to the background.

### /branch

Creates a branch of the conversation (not of git) from this point and moves you onto it. Use it to try one path without losing the other: for example, halfway through the work you want to see where a Redis approach leads.

Inside Claude Code:
```
/branch try-redis
```

> 💡 Pro tip: **The original stays where it is.** You go back to it with `/resume`, from the point where you created the branch. If the new path leads nowhere, all you lose is the branch.

### /fork

Copies the conversation into a new background session, and you stay here. If you add a prompt, the copy starts right away with it. It’s a session of its own, with its own row in `claude agents` and, normally, its own worktree. Use it when a task has to move forward on its own, with all the current context.

Inside Claude Code:
```
/fork write the tests for the payments module
```

> 💡 Pro tip: **Before following a guide on `/fork`, check its date.** In 2026 it changed meaning twice: until March it was the name of `/branch`, until July it launched the subagent that is now called `/subtask`.

## 6. When something goes wrong

### /rewind

Aliases: `/undo`, `/checkpoint`.

Lets you try the boldest path: if it goes badly, you go back. Claude Code saves a checkpoint at every message you send, as the [checkpointing page](https://code.claude.com/docs/en/checkpointing) explains. You pick the message, then what to do:

- restore the code, the conversation, or both to that point; with code only, files go back as they were, and the conversation keeps the reason the path was wrong;
- with “Summarize from here” you summarize from that message onward, for example a long debugging session, with the initial instructions intact; with “Summarize up to here” you summarize what comes before.

If you roll the conversation back, your earlier prompt reappears in the input field: you fix it and resend. `Esc` `Esc` gets you there too, but only on an empty line.

Inside Claude Code:
```
/rewind
```

> 💡 Pro tip: **It doesn’t roll back files touched only by a Bash command.** Checkpoints cover the files Claude edits with its file tools, and usually not those of subagents. For everything else, git is your safety net.

### /doctor

Alias: `/checkup`.

When something is wrong and you don’t know where to begin, start here. It checks the installation, settings, extensions, and `CLAUDE.md`, and proposes fixes that it applies once you say yes. If `claude` won’t start at all, the [troubleshooting guide](https://code.claude.com/docs/en/troubleshooting) says to run `claude doctor` from the shell, which only does the diagnosis.

Inside Claude Code:
```
/doctor
```

> 💡 Pro tip: **`/doctor prompt-audit` checks your instructions.** It flags the ones written for old models, the ones that point to missing files or commands, and files that contradict each other, as the [memory page](https://code.claude.com/docs/en/memory) explains. You can also point it to a file: `/doctor prompt-audit CLAUDE.md`.

### /bug

Alias: `/share`.

Reports a bug to Anthropic, even while Claude is working. Before sending, a screen lets you choose how much of the conversation to attach, and nothing is sent unless you say yes. For product suggestions there’s `/feedback`, which has been a separate command since 2.1.212.

Inside Claude Code:
```
/bug the status bar disappears after /clear
```

> 💡 Pro tip: **With a provider other than Anthropic, the report isn’t sent.** The same goes without Anthropic credentials: Claude Code saves it in `~/.claude/feedback-bundles/`, and sending it is up to you.

## 7. Create your own command

A command of your own is a skill: a file of instructions with a name. You put it in `.claude/skills/<name>/SKILL.md` if it applies to the project, or in `~/.claude/skills/<name>/SKILL.md` if it applies to you in every project. The old files in `.claude/commands/` still work; if the same name exists in both places, the skill wins. All the fields are on the [skills page](https://code.claude.com/docs/en/skills).

At the end of a task, I update my HANDOFF.md. This skill prepares the draft:

`.claude/skills/handoff/SKILL.md`:
```
---
description: Prepare a handoff note on the work done in this session, to copy into HANDOFF.md
argument-hint: "[topic]"
disable-model-invocation: true
allowed-tools: Bash(git status *)
---

Prepare a handoff note on the work done today on $0.

The files changed, according to git:

!`git status --short`

Write what is done, what is left to do, and the command to pick the work back up.
Do not modify any file: just show me the text.
```

The command’s name is the folder’s name, so you run it like this:

Inside Claude Code:
```
/handoff "login refactor"
```

`$0` is the first argument, `$1` the second, and `$ARGUMENTS` takes them all together. The quotes keep several words together: without them, `$0` would be just “login”. The line that starts with `!` runs before the text reaches Claude, and in its place Claude finds git’s output. If the command fails, for example outside a repository, the whole skill stops.

> 💡 Pro tip: **`allowed-tools` grants permission in advance, it doesn’t restrict.** The listed tools run without asking, and the others stay available. The folder trust check doesn’t stop it: before opening Claude Code in a cloned repository, read the `allowed-tools` and the `!` blocks of its skills.

> 💡 Pro tip: **Arguments go into `!` blocks without quotes.** The only defense is the permission check on the final command: narrow `allowed-tools`, never `Bash(*)`. That’s why my example’s `!` block uses no arguments. The documentation doesn’t say this: it comes from the code of Claude Code 2.1.319.

> 💡 Pro tip: **Decide who can run it.** With `disable-model-invocation: true`, only you can (think of a `deploy`). With `user-invocable: false`, only Claude can. Give it a built-in command’s name and it replaces that command, but aliases stay: with your own `usage` skill, `/cost` still opens the original.

One last thing: the cost. The description of every skill Claude can run on its own sits in the context: together they get 1% of the window, and each one is cut off at 1,536 characters. Past the budget, the skills you use least lose their descriptions first. `/skill-doctor` tells you which ones you don’t use and how much they cost you. With `disable-model-invocation: true`, as in the example, the description stays out. The rest of the diet is in [Claude Code hygiene](https://stocasticparrot.ai/en/explainers/claude-code-hygiene/).

Over a hundred commands, 27 that matter. Starting tomorrow, at least one for every moment of the day. That’s it.

## Sources

Verified on November 6 and 7, 2026, against the official documentation and the code of Claude Code 2.1.319. Commands change often: the date matters.

- Anthropic, Claude Code documentation, [Commands](https://code.claude.com/docs/en/commands): the list of commands, the six moments of the day, and what `/batch` is for.
- Anthropic, Claude Code documentation, [Interactive mode](https://code.claude.com/docs/en/interactive-mode): the prefixes, the command queue, and the shortcuts.
- Anthropic, Claude Code documentation, [Configure permissions](https://code.claude.com/docs/en/permissions): the allow, ask, and deny rules.
- Anthropic, Claude Code documentation, [Choose a permission mode](https://code.claude.com/docs/en/permission-modes): what Claude does in plan mode, how the plan is approved, and the mode a session starts in.
- Anthropic, Claude Code documentation, [Model configuration](https://code.claude.com/docs/en/model-config): `opusplan`, which plans with Opus and executes with Sonnet.
- Anthropic, Claude Code documentation, [Manage costs effectively](https://code.claude.com/docs/en/costs): how `/usage` breaks down consumption and the suggestions it gives.
- Anthropic, Claude Code documentation, [Connect Claude Code to tools via MCP](https://code.claude.com/docs/en/mcp): MCP servers.
- Anthropic, Claude Code documentation, [Keep Claude working toward a goal](https://code.claude.com/docs/en/goal): `/goal`, how to write the condition, and auto mode.
- Anthropic, Claude Code documentation, [CLI reference](https://code.claude.com/docs/en/cli-reference): the `--max-turns` and `--max-budget-usd` caps.
- Anthropic, Claude Code documentation, [Manage multiple agents with agent view](https://code.claude.com/docs/en/agent-view): `/background`, `claude agents`, and what moves to the background.
- Anthropic, Claude Code documentation, [Create custom subagents](https://code.claude.com/docs/en/sub-agents): `/subtask` and subagents that inherit the conversation.
- Anthropic, Claude Code documentation, [Run prompts on a schedule](https://code.claude.com/docs/en/scheduled-tasks): `/loop`, its pacing, the expiry, and how to stop it.
- Anthropic, Claude Code documentation, [Review locally with `/code-review`](https://code.claude.com/docs/en/code-review-local): `/code-review`’s targets, levels, `--fix`, and `--comment`.
- Anthropic, Claude Code documentation, [Find bugs with ultrareview](https://code.claude.com/docs/en/ultrareview): `/code-review ultra` and its pricing.
- Anthropic, Claude Code documentation, [Checkpointing](https://code.claude.com/docs/en/checkpointing): what `/rewind` restores and what it doesn’t, and the two summaries.
- Anthropic, Claude Code documentation, [Troubleshooting](https://code.claude.com/docs/en/troubleshooting): `/doctor` and `claude doctor`.
- Anthropic, Claude Code documentation, [How Claude remembers your project](https://code.claude.com/docs/en/memory): `/doctor prompt-audit`.
- Anthropic, Claude Code documentation, [Extend Claude with skills](https://code.claude.com/docs/en/skills): skills, arguments, `!` blocks, `allowed-tools`, precedence, and skills that run in a subagent.
- Anthropic, [Claude Code changelog](https://code.claude.com/docs/en/changelog), up to 2.1.318 (November 4, 2026): the dates of the name changes and the worktree of `/fork` copies.
