Claude Code

Verified against Claude Code · 2026-07-22

Author a custom slash command Claude Code will run the same way every time

A prompt that generates a well-formed .claude/commands/*.md custom slash command — frontmatter, argument handling, and an explicit output contract — so a repeated workflow becomes one typed command instead of a differently-worded prompt each time.

Claude Code5 fillable variables

The prompt

Ready to copy — highlighted parts are example details you can swap.

Write a custom slash command for Claude Code as a single markdown file, ready to save at .claude/commands/review-pr.md. The filename determines the command name Claude Code exposes, so name the file to match exactly how the command should be invoked, and if it belongs under a namespaced subdirectory rather than the flat commands folder, say so and explain why grouping it improves discovery.

WORKFLOW TO TURN INTO A COMMAND
Whenever a pull request is ready for review, fetch the diff against main, run the project's lint and test commands, and produce a structured review of correctness, tests, and scope — currently done by retyping a long prompt each time.

ARGUMENTS THIS COMMAND ACCEPTS
An optional PR number or branch name; if omitted, review the current branch against main.

STRUCTURE THE FILE AS
1. YAML frontmatter with: a description field stating what the command does and when to reach for it, an argument-hint field showing the expected shape of the passed-in text in the exact form a user would type it, and an allowed-tools field naming only the tools this workflow actually needs — do not grant Bash or Write access to a command that only reads and reports.
2. Below the frontmatter, the command body written as a direct instruction to Claude Code, substituting the passed-in argument wherever it belongs, and using positional references if the workflow genuinely needs more than one distinct value rather than one free-text blob.
3. An explicit output contract at the end of the body: the exact section headers or format the command must produce every time it runs, so invoking it twice on different input produces comparably-shaped output, not two differently organized answers.

CONSTRAINTS
- The command must do one workflow well, not several loosely related ones behind one name. If the workflow described above is actually two distinct jobs, say so and propose two separate command files instead of forcing one.
- If the workflow needs project-specific context that will not exist in every repo this command might later be copied into, such as a specific test command or file path, make that a documented argument or a clearly marked placeholder, not a hardcoded assumption.
- Do not have the command silently take an action with side effects, such as committing, pushing, or deleting, unless No — this command only reads and reports, it never commits or pushes. explicitly says it should — and even then, end the body with an instruction to state what it is about to do before doing it.
- If the workflow would benefit from a model cheaper or faster than the main conversation is using, such as a purely mechanical formatting pass, note that as an optional model field in the frontmatter rather than leaving every invocation on the default model by default.

OUTPUT
The complete markdown file content, frontmatter included, ready to paste as-is. After the file, one sentence on which command already listed in .claude/commands/ currently has commit.md and changelog.md., if any, this new one might overlap or conflict with by name or by purpose.

Customize

Optional — swap in your own details for the highlighted parts above.

Why this works

A Claude Code slash command is not just a saved prompt — it is a file Claude Code discovers by name in .claude/commands/, and the filename is the actual invocation string, so getting review-pr.md right is what makes /review-pr exist at all; a template that does not treat the filename as load-bearing produces a file nobody can actually invoke as intended. The allowed-tools frontmatter field is a real permission boundary enforced by Claude Code itself, not a description of intended behavior — scoping a read-only review command to Read, Grep, and a narrow Bash pattern rather than the full tool set means the command cannot commit, push, or delete even if its own body were somehow read in a way that suggested it should, which is a materially stronger guarantee than a prompt that simply asks nicely not to make changes. This is why the constraint about side effects requiring an explicit allow flag matters: a command is invoked by a short slash instruction with no surrounding conversation to reconsider intent, so a command capable of a destructive action needs the safety built into its own tool grant, not just into wording a future user might skim past. The explicit output contract at the end of the body solves the actual failure mode of ad hoc reusable prompts: because a slash command is invoked fresh with new arguments substituted in each time, the same wording run on Monday and again on Friday can drift into differently structured answers if nothing pins the shape down, which quietly defeats the reason to have made it a command instead of retyping a slightly different version of the same request each time. Requiring the workflow to be one job, not several loosely related ones stacked behind a single name, matters because a command's whole value is that invoking it is unambiguous about what will happen — a command that sometimes reviews and sometimes also drafts a changelog entry, depending on how it is phrased, has reintroduced the exact ambiguity a dedicated command was supposed to remove.

What you get back

--- description: Review the current branch's diff against main for correctness, tests, and scope before opening a PR argument-hint: [optional PR number or branch name] allowed-tools: Read, Grep, Bash(git diff:*), Bash(git log:*) --- Review the diff between the given argument (or the current branch if none) and main. Produce exactly: Correctness / Tests / Scope / Verdict sections, matching the site's code-review rubric. Overlap note: no conflict with commit.md or changelog.md — neither one reviews a diff.

Verified against

Claude Code Sonnet 4.6 · 2026-07-22

Changelog

  • 2026-07-22 Initial publish, verified against Claude Code custom slash commands (Sonnet 4.6).

Building this for real?

This is a free starting point. If you'd rather have custom software built and running for your business, that's Scult's day job.

EXPLORE CUSTOM SOFTWARE
All Claude Code prompts

Check your AI visibility

One URL in, a 0–100 score and the exact fixes out.

RUN THE CHECK

Browse all the tools

15 tools across six categories
13 of them never send your data anywhere

Free · No signup · No trial clock

SEE THE DIRECTORY