Claude Code slash commands, and how to write your own

The built-in Claude Code slash commands worth knowing, how the / menu works, and how to write a custom command as a Markdown file with arguments.

· 5 min read

Slash commands are what you type at the start of a Claude Code message to control the session: /clear empties the context, /compact summarizes it, /permissions edits your rules, /init writes a CLAUDE.md. Type / alone to see everything available to you. You can also write your own as a Markdown file, though in current Claude Code a custom command is really a skill.

#How do slash commands work?

A command is only recognized at the start of your message; whatever follows the name becomes its arguments. Type / and the menu filters as you type. If you send a command while Claude is still answering, it is queued and runs after the current turn, except for a few that run immediately without interrupting (/status, /tasks and /usage among them).

The menu mixes three kinds of entries: built-in commands, bundled skills that ship with Claude Code (such as /loop, /simplify, /debug, /batch), and your own commands and skills. You can even chain several skills in one message, for example /skill-a /skill-b do XYZ, which loads both and passes the trailing text to each.

The exact list changes between versions, so treat /help and the commands reference as the source of truth. These are the ones most people use.

#Which built-in commands are worth learning?

Managing the conversation

CommandWhat it does
/clearNew conversation with empty context. Pass a name to label the old one in the /resume picker.
/compactFree up context while continuing the same conversation, by summarizing it.
/resumeReopen a previous conversation.
/rewindRoll the conversation and/or the code back to an earlier point (aliases /checkpoint, /undo).
/contextShow how full the context window is, as a colored grid, with suggestions.
/btwAsk a side question without adding it to the conversation.

The context ones matter most. They are the difference between a session that stays sharp and one that forgets what you said an hour ago; the reasons are in Claude Code's context window.

Setting up the project

CommandWhat it does
/initGenerate a starting CLAUDE.md. See how to write one.
/memoryEdit CLAUDE.md files and turn auto memory on or off.
/permissionsManage allow, ask and deny rules in an interactive dialog.
/modelSwitch model and save it as the default for new sessions.
/configOpen settings, or set a value directly, like /config verbose=true.
/add-dir <path>Give the session access to another directory.

Extending and checking

CommandWhat it does
/skillsList available skills; you can filter by name, description or source.
/hooksView hook configurations.
/mcpManage MCP server connections.
/agentsCreate or manage subagents.
/plan [description]Enter plan mode, optionally with a first task.
/review, /security-reviewReview the current diff, or the branch's changes for security issues.
/doctorRun a setup checkup; /doctor prompt-audit audits your instruction files.
/usageShow plan usage (/cost is an alias).
/help, /powerupHelp, and short interactive lessons.

#How do you write your own slash command?

Create a Markdown file. The file name becomes the command name. A project command goes in .claude/commands/ and is shared with your team through git. This one is .claude/commands/fix-issue.md:

---
description: Fix a GitHub issue end to end
argument-hint: [issue-number]
---

Fix GitHub issue $ARGUMENTS.

1. Read the issue with `gh issue view $ARGUMENTS`.
2. Find the code responsible and explain the cause in two sentences.
3. Make the smallest fix and add a failing-then-passing test.
4. Run `npm test` and `npm run lint`; fix what you broke.
5. Summarize what changed. Do not commit.

Now /fix-issue 482 expands the file with 482 in place of $ARGUMENTS. A few rules of thumb:

  • Write it as a prompt you would be happy to type, including the steps, the checks and what "done" means.
  • Say what not to do (here, commit), so a command you run often has no side effects you did not intend.
  • $ARGUMENTS is everything typed after the name. If you use no placeholder at all, Claude Code appends the arguments to the end for you.

#Is a custom command different from a skill?

Today they are the same thing. The official docs state that custom commands have been merged into skills: .claude/commands/deploy.md and .claude/skills/deploy/SKILL.md both create /deploy, existing command files keep working, and if both exist with the same name the skill wins.

What a skill adds is a folder: supporting files and scripts next to the instructions, more frontmatter fields, and Claude loading the skill by itself when your request matches its description. A bare command file cannot have supporting files. A good rule: keep a one-file prompt as a command, and move it to a skill the day you want a bundled script or automatic loading. The details are in Claude Code skills.

If you do not want Claude to run a command on its own initiative, add disable-model-invocation: true to its frontmatter. That is what you want for anything with side effects, like deploys.

#Where do named arguments and shell output fit?

Both come from the skill format, and since commands and skills are now one mechanism, the safest place to use them is a SKILL.md. Positional access is $0, $1 (zero-based), or you declare names:

---
description: Migrate a component between languages
arguments: [component, from, to]
---

Migrate the $component component from $from to $to.

/migrate-component SearchBar JavaScript TypeScript fills all three. Quote multi-word values. A line like !git diff HEAD runs the shell command before Claude sees the prompt and pastes its output in, which is how you give a command fresh context without asking Claude to run it.

#A short list of commands people write

  • /standup: summarize yesterday's commits across your branches.
  • /changelog: draft release notes from the commits since the last tag.
  • /pr-description: write a pull request body from the branch diff.
  • /test-plan: list the cases a change needs, without writing code.
  • /explain: walk through a file for someone new to it.

Pick the one prompt you retype most this week and turn it into a file. For the habits around prompts themselves, see how to prompt Claude Code.

#In Relais

Relais' composer takes / for commands and skills like the terminal does, and @ to mention a file. Sessions are plain Claude Code sessions. Relais also has its own session templates, Markdown files in .relais/templates/ that set standing rules, skills, model and permissions for a session. See features.

Claude Code,
better organized.

$14.99 a month, everything included. Mac and Linux, on your Claude Pro or Max plan. Cancel any time.