A custom command that does the exact same thing every time is useful, but the real power comes from feeding it input. Claude Code gives your command files placeholders that fill in with whatever you type after the command name.
$ARGUMENTS for everything
Use $ARGUMENTS to drop in all the text you pass, as one chunk. Say you have .claude/commands/fix-issue.md:
Look into issue $ARGUMENTS, find the cause, and propose a fix.
Call it like this:
/fix-issue 143 the login form rejects valid emails
Everything after the command name lands where $ARGUMENTS sits.
$1, $2 for positional input
When you want to treat inputs separately, use numbered placeholders. Each one picks up the matching word in order:
Open a PR from branch $1 targeting $2 and summarize the changes.
Then:
/open-pr feature-login main
Here $1 becomes feature-login and $2 becomes main. Positional slots are ideal when your command has a couple of distinct parameters that each mean something specific.
Going further with files and shell
Arguments combine well with two other tricks in command files. You can reference a file with @path so Claude reads it first, and you can inject the output of a shell command with a leading ! line. A review command might pull in a diff with a ! line and take the target branch as $1, so one command gathers real context and adapts to your input at the same time. Start with $ARGUMENTS for simple cases, reach for $1 and $2 when inputs have distinct roles, and your commands stop being rigid scripts and become real tools.
Comments
Be the first to comment.