Claude Code Custom Commands

Built-in slash commands manage your session. Custom slash commands go further by packaging your own favorite prompts into short, reusable shortcuts. A long instruction you type every day becomes a single word beginning with a slash.

The Speed-Dial Idea

Your phone stores a long phone number under one short contact name. A custom slash command works the same way. You save a detailed prompt once and call it with a short name whenever you need it.

Without a command:
"Review the current changes for bugs, unclear names,
 missing tests, and security risks. List findings by severity."

With a command:
/review

How Custom Commands Are Stored

Each command is a Markdown file. The file name becomes the command name. Two folders hold them.

FolderScope
.claude/commands/ (inside a project)Available in that project; shared with the team through version control
~/.claude/commands/ (home folder)Available in every project on your computer

Create Your First Command

  1. Create the folder .claude/commands in your project.
  2. Add a file named review.md.
  3. Write your prompt inside the file.
  4. Start a Claude Code session and type /review.

The file content might look like this:

Review the files I changed since the last commit.
Check for bugs, unclear names, and missing tests.
List each finding with a severity of high, medium, or low.
Suggest a fix for every high-severity finding.

Typing /review now sends that entire prompt.

Passing Arguments

Commands become flexible when they accept input. The placeholder $ARGUMENTS inside the file receives whatever you type after the command name.

File: .claude/commands/explain.md
-----------------------------------
Explain how $ARGUMENTS works in this project.
Use simple language and show the key files.

You type:
/explain the login system

Claude Code replaces $ARGUMENTS with "the login system" before it runs the prompt.

Adding a Description

A short description appears in the slash menu and helps teammates find the command. Place it at the top of the file between two lines of three dashes.

---
description: Review recent changes for bugs and risks
---
Review the files I changed since the last commit...

Organizing With Sub-Folders

Sub-folders group related commands. A file at .claude/commands/git/summary.md groups the command under a git label in the menu. Large teams rely on this structure to keep dozens of commands tidy.

Command Ideas Worth Building

  • /review checks recent changes for problems.
  • /tests writes tests for a named file.
  • /explain describes a feature in plain language.
  • /changelog drafts release notes from recent commits.
  • /cleanup removes unused imports and dead code.

Good Habits

One Job Per Command

A focused command produces predictable results. Split a giant command into smaller ones.

Clear Output Format

Tell Claude Code exactly how to present results, such as a table or a short list.

Share With the Team

Commit the commands folder so every teammate runs the same trusted prompts.

A Complete Example

A developer creates tests.md with the text "Write unit tests for $ARGUMENTS. Cover normal input, empty input, and invalid input. Run the tests and report the results." Typing /tests cart.js sends the full request about the cart file. The developer saves two minutes on every use. Over a month, those minutes add up to hours, and every teammate who shares the command gains the same benefit.

Name commands with short, memorable words. A name like review sticks in memory, while check-all-recent-changes-for-problems invites typos. Revisit the folder every few weeks and retire commands nobody uses.

Key Points

  • A custom command is a Markdown file that holds a saved prompt.
  • The file name becomes the command name.
  • Project commands travel with the repository; personal commands live in the home folder.
  • The $ARGUMENTS placeholder accepts input after the command name.
  • Focused commands with clear output formats work best.