Build Custom Slash Commands to Automate Your Repetitive Prompts
If you keep typing the same kind of prompt — "run the tests and fix any failures", "review this for security issues", "add error handling to this function" — turn it into a custom slash command you can invoke in one keystroke.
# Create the commands directory
mkdir -p .claude/commands
Then create a markdown file for each command. The filename becomes the slash command name:
<!-- .claude/commands/fix-tests.md -->
Run the test suite. If any tests fail, read the failing test
and the code it tests, then fix the issue. After fixing, run
the tests again to confirm they pass. Repeat until green.
Now type /fix-tests in any Claude Code session and it expands into that full prompt. No retyping, no forgetting steps.
You can use the $ARGUMENTS placeholder to make commands flexible:
<!-- .claude/commands/review.md -->
Review the file $ARGUMENTS for:
- Security vulnerabilities (injection, XSS, auth bypass)
- Performance issues (N+1 queries, missing indexes)
- Error handling gaps
- Edge cases that aren't covered
List issues by severity with specific line numbers.
Use it as /review src/controllers/PaymentController.php — the file path replaces $ARGUMENTS.
Commands live in your repo, so the whole team shares them. Put personal-only commands in ~/.claude/commands/ instead.
Some useful commands to start with:
/fix-tests— run tests, fix failures, repeat/review— security and quality review of a file/commit— stage, diff, and write a conventional commit message/explain— explain how a file or function works
Custom commands turn your best prompting patterns into team-wide shortcuts.
via Claude Code
Log in to leave a comment.
Turn your most common prompts into reusable slash commands — drop a markdown file into .claude/commands/ and it becomes a /command you and your team can invoke anytime, with consistent instructions every time.
The $ARGUMENTS placeholder in custom slash command files turns a static prompt into a reusable tool — pass different values each time you invoke it, just like a function that takes arguments.
Drop a Markdown file into .claude/commands/ and it becomes a slash command — no config, no code, just a prompt in a file that your whole team can share.