How to Build a Claude Code Slash Command Library (Exact Template Inside)

You type the same 30-second instruction to Claude Code 20 times a week.

That’s roughly 10 hours a month spent re-typing context that should be a single command.

Most devs never set up the shortcut system because they think it’s complicated. It’s not.

Here’s the full template to fix this👇

What slash commands actually are

A slash command is a saved prompt living in a single file. When you type /review, Claude loads that file as the prompt and runs it with whatever arguments you passed.

That’s the whole concept. No plugins. No build step. No registry. Just Markdown files in a folder.

Two locations matter:

Filename becomes the command name. review.md becomes /review. Subfolders become namespaces: .claude/commands/team/review.md becomes /team:review.

The basic template

Every slash command follows the same structure: YAML frontmatter on top, prompt body below.

Each frontmatter field is optional, but the description matters most. It’s what Claude reads to pick the right command, and it’s what shows in the menu when you type /.

allowed-tools scopes what the command can do. Tighter scope means faster, safer commands. A doc updater doesn’t need Bash. A reviewer doesn’t need Write.

model is optional. Use haiku for routine work, sonnet for most things, opus for security and complex reasoning.

The 7 ready-to-ship commands

Drop any of these into .claude/commands/{name}.md and you have it.

  1. /review

  2. /test

  3. /migrate

  4. /audit

  5. /doc

  6. /triage

  7. /refactor

How to invoke them

Three ways:

Type / and Claude shows the full menu with descriptions. Pick one, autocomplete fills the rest.

Type the full command directly: /review or /audit src/api/auth.ts. Arguments come after a space.

For namespaced commands in subfolders: /team:review runs .claude/commands/team/review.md.

Arguments come in as 1, 3 for positional. So /migrate axios to fetch gives you 2=to, ARGUMENTS=“axios to fetch”.

Common mistakes that kill your slash commands

Description too vague. “Review code” tells Claude nothing about when to use it. “Review the current diff for bugs, security, and style issues” is what you want.

allowed-tools too loose. If you leave tools off the list, the command inherits everything. That’s fine for trusted commands. For ones that touch sensitive paths or run shell commands, scope it tight.

Using ARGUMENTS. ARGUMENTS.

Wrong location. Project commands in .claude/commands/, global commands in ~/.claude/commands/. Put it in the wrong place and it doesn’t show up.

Not committing project commands to git. .claude/commands/ should be in your repo. Your teammates get the same shortcuts the moment they clone.

The 15-minute breakdown

3 minutes: pick the one task you do 5+ times a week. Copy the matching template above.

3 minutes: tweak the prompt for your stack. Your test framework, your linter, your conventions.

2 minutes: save to .claude/commands/{name}.md.

2 minutes: run it on a real task to confirm it works.

5 minutes: build the next one.

Done. One specialist command instead of one re-typed prompt. Build one a day for a week and you’ll have 7 commands handling 80% of your routine work, and the long instructions you used to retype every session become a single keystroke.

Thanks for reading!

I share daily notes on AI, finance, and vibe coding in my Telegram channel: https://t.me/zodchixquant


원문: https://x.com/0x_rody/status/2063549084695158936?s=52