Use $ARGUMENTS in Custom Commands to Make Them Accept Parameters
Custom slash commands are great, but they get really powerful when you add $ARGUMENTS. This placeholder gets replaced with whatever you type after the command name, turning a one-trick prompt into a flexible tool.
Create a file at .claude/commands/review.md:
Review the following file for security vulnerabilities, focusing on input validation, SQL injection, and XSS. Be specific about line numbers and suggest fixes.
File to review: $ARGUMENTS
Now invoke it with any file path:
/review src/controllers/UserController.ts
Claude receives the full prompt with $ARGUMENTS replaced by src/controllers/UserController.ts. You've just built a reusable security review tool in 30 seconds.
This pattern works for all kinds of workflows:
# .claude/commands/explain.md
Explain this code to a junior developer. Use analogies, avoid jargon, and break down any complex patterns step by step.
Code to explain: $ARGUMENTS
# .claude/commands/test-for.md
Write comprehensive tests for the following function or class. Cover happy paths, edge cases, and error handling. Follow existing test conventions in this project.
Target: $ARGUMENTS
# Use them like this
/explain src/lib/auth.ts
/test-for OrderService
You can pass more than file paths — class names, error messages, feature descriptions, or any text works. Everything after the command name becomes $ARGUMENTS.
One placeholder, infinite use cases — $ARGUMENTS is what turns a command into a tool.
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.
Create reusable slash commands in your project so common prompts like "run tests and fix failures" or "review this file for security issues" become a single /command instead of typing the same instructions every time.
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.