Custom Slash Command Builder for Repeated Claude Code Tasks

Turns a task you repeat into a custom slash command file with frontmatter, arguments, restricted allowed tools and a fixed output format.

You get: Working code with an explanation

More like this

Ready to use: no blanks to fill in.

The prompt

custom-slash-command-builder-for-repeated-claude-code-tasks.md
You are an expert in Claude Code custom slash commands. Ask me two short questions first: what task I repeat, and what I usually pass in (a file, a ticket number, a branch). Check the repo for an existing .claude/commands folder and for scripts the command should call. Then write the command file. Rules: 1) Use Markdown with frontmatter containing description, argument-hint, and allowed-tools limited to the minimum, such as specific Bash(git diff:*) patterns instead of unrestricted Bash. 2) Use $ARGUMENTS or $1 and $2 for inputs, and state what to do when an argument is missing. 3) The body gives numbered steps, names real commands and paths, and ends with a fixed output format such as a summary, a checklist and a next-step line. 4) Mark anything you assumed. Output: assumptions, the file path, the full file in one code block, two example invocations with expected output shapes, how to test it, risks such as overly broad permissions, and next actions.

Example output

AI-written example
---
description: Review the changes on a branch against its base and return a fixed-format summary, checklist and next step
argument-hint: [branch] [base-branch, default main]
allowed-tools: Bash(git diff:*), Bash(git log:*), Bash(git merge-base:*), Bash(git status:*), Bash(git rev-parse:*), Read, Grep, Glob
---

# Branch review

Inputs: branch = `$1`, base = `$2` (default `main`).

## Steps

1. If `$1` is empty, stop and reply: "Usage: /branch-review <branch> [base-branch]. No branch given." Do nothing else.
2. If `$2` is empty, use `main` as the base.
3. Run `git rev-parse --verify $1`. If it fails, stop and tell me the branch does not exist locally.
4. Run `git merge-base $2 $1` and save the commit hash.
5. Run `git diff --stat <merge-base>..$1` to see which files changed.
6. Run `git log --oneline <merge-base>..$1` to read the commit messages.
7. For each changed file under `src/` or `app/`, run `git diff <merge-base>..$1 -- <file>` and read the diff. Skip lockfiles and generated files such as `package-lock.json` and `dist/`.
8. Use Grep and Glob to check whether each changed module has a matching test file in `tests/` or `__tests__/`. Use Read to open any test file you find.
9. Do not edit files, commit, or run tests. This command is read-only.

## Output format (use exactly this)

**Summary**
- Branch: `$1` vs `<base>`
- Commits: <count>
- Files changed: <count> (+<added> / -<removed>)
- Purpose: <one sentence>

**Checklist**
- [ ] Changes match the commit messages
- [ ] No leftover debug code (`console.log`, `print(`, `TODO`, `debugger`)
- [ ] New or changed logic has tests
- [ ] No secrets or hardcoded credentials
- [ ] Error paths handled

Mark each item `[x]` or `[ ]` and add a short note with `file:line` for any failure.

**Next step:** <one sentence: approve, request specific changes, or run a named test command>

<!--
FILE PATH: .claude/commands/branch-review.md

ASSUMPTIONS
- Source lives in src/ or app/ and tests in tests/ or __tests__/.
- Base branch is main unless passed as $2.
- No existing .claude/commands/branch-review.md, and no helper scripts to call.

EXAMPLE INVOCATIONS
/branch-review feature/csv-export
  -> Summary block, 5-item checklist with notes, one-line next step, diffed against main.
/branch-review fix/login-timeout develop
  -> Same shape, diffed against develop.
/branch-review
  -> Single usage line, no tools run.

HOW TO TEST
1. Create a throwaway branch with a small change and a stray console.log.
2. Run /branch-review <branch> and confirm the debug-code item is flagged with file:line.
Generated from this prompt by AI. Your results will vary.

Tips and common edits

Use it when you retype the same prompt in Claude Code, such as reviewing a diff or triaging a failing test. Be ready to name the task and its typical arguments.

Questions about this prompt

More in Claude Code

Agent Run Post-Mortem: Trace Root Cause and Prompt or Tool Fixes

Analyzes a pasted agent trace to find the first real failure and proposes exact prompt rewrites or tool changes, each with a test.

Characterization Tests Before a Refactor

Writes tests that lock in a module's current behavior, including edge cases and quirks, so you can refactor safely.

Checkpoint and Rollback Manager with Compensation Steps and Failure Injection Tests

Guides Claude Code to implement checkpoint snapshots, rollback modes, and compensating actions for side-effecting agent phases, then prove them with failure-injection tests. Helps you decide the rollback strategy per phase.

Claude Code Behavior-Preserving Refactor with Characterization Tests and Staged Commits

Guides Claude Code to refactor a module safely by first pinning current behavior with characterization tests, then applying small reversible steps with verification after each. Delivers a diff, risk register, and rollback plan.

Claude Code Feature Implementation Plan and Build from a Ticket with Repo Convention Discovery

Has Claude Code investigate how similar features are built in the repository, produce an implementation plan with acceptance tests, then implement it in verified increments. Surfaces risks, open questions, and next actions before and after coding.

Claude Code Hook Writer: Auto-Run Lint, Typecheck or Tests After Edits

Produces a PostToolUse hook entry for settings.json, the script it calls and a concrete procedure to test that the check runs after file edits.

Claude Code Plan-Then-Implement a Feature With Approval Checkpoints

Makes Claude Code explore the repo, write a step-by-step plan for your approval, then build the feature in small verified steps, stopping at each checkpoint for your go-ahead.

Claude Code Root-Cause Bug Investigation with Failing Test and Minimal Patch

Directs Claude Code to reproduce a bug, trace it to a root cause using repository evidence, write a failing regression test, and apply the smallest safe fix. Ends with a verified diff, risks, and next actions.

Codebase Tour for a Specific Task

Explores a repo through the lens of your task and explains the architecture, key files and data flow, then says where to start.

Coding Agent Task Brief with Guardrails, Test Plan, and Rollback Steps

Creates a scoped brief for an AI coding agent that limits file changes, defines tests, and includes a rollback plan and review checklist.

DAG Scheduler with Fan-Out/Fan-In Barriers and Resumable Run Ledger for Agent Pipelines

Guides Claude Code to build or refactor a dependency-aware DAG scheduler for agent phases, with cycle validation, bounded parallelism, join policies, retries, and an append-only run ledger so interrupted runs resume without redoing finished nodes.

Dependency Graph Planner for a Multi-Agent Software Release Workflow

Turns a list of release tasks into a dependency graph with parallel batches, critical path, shared-resource conflicts, and agent assignments. Supports the decision on what to run now versus wait on.