Slash Commands
Command Code includes built-in slash commands for interactive workflows, and also supports custom slash commands from markdown files.
For the full list of built-in slash commands, see Interactive Mode — Slash Commands.
Custom slash commands let you save frequently used prompts as markdown files. Define a command once, then run it anytime with dynamic arguments. Commands can be project-level or user-level (shared across all projects).
| Parameter | Description |
|---|---|
<command-name> | Name derived from the markdown filename (without .md extension) |
[arguments] | Optional arguments passed to the command |
There are two types of commands:
Project-Level Commands
Commands saved directly in your project. When shown in /help, they appear with “(project)” after their description.
Location: .commandcode/commands/
This makes /test command available only within this project.
User-Level Commands
Commands that are available across all your projects. In the command menu, they appear with “(user)” after their description.
Location: ~/.commandcode/commands/
This makes /understand command available in all your projects.
Organize commands in subdirectories. The subdirectories appear in the command description but do not affect the command name.
| File Location | Command | Description Shows |
|---|---|---|
.commandcode/commands/frontend/component.md | /component | (project: frontend) |
~/.commandcode/commands/git/commit.md | /commit | (user: git) |
.commandcode/commands/simple.md | /simple | (project) |
Unlimited Nesting Depth
You can organize commands as deeply as needed:
Pass dynamic values to commands using argument placeholders.
All Arguments with $ARGUMENTS
The $ARGUMENTS placeholder captures all arguments as a single string:
Command definition (.commandcode/commands/explain.md):
Usage:
Result: $ARGUMENTS becomes "how async await works in JavaScript"
Positional Arguments with $1, $2, etc.
Access specific arguments using positional parameters. Arguments start at $1 (there is no $0):
Command definition (.commandcode/commands/create-component.md):
Usage:
Result:
$1→"React"$2→"Button"$3→"onClick and disabled props"
Quoted Strings
Arguments containing spaces can be wrapped in quotes:
Result:
$1→"React"$2→"Login Form"$3→"email validation and submit handler"
| Scenario | Behavior |
|---|---|
Missing argument (e.g., $3 with only 2 args) | Replaced with empty string |
| Extra arguments | Captured in $ARGUMENTS, ignored by unused $N |
| No arguments provided | $ARGUMENTS = "", all $N = "" |
| Command without placeholders | Template passed through unchanged |
Test Generator Command
File: .commandcode/commands/test.md
Usage:
Documentation Command
File: ~/.commandcode/commands/docs.md
Usage:
- Type
/to open the command menu - Select a command from the dropdown (e.g.,
/test) - Command is inserted into the input field with a trailing space
- Type your arguments (e.g.,
unit Jest) - Press Enter to execute
- Placeholders are replaced with your arguments
- Processed prompt is sent to the AI
Placeholders
| Placeholder | Description | Example Input | Result |
|---|---|---|---|
$ARGUMENTS | All arguments as string | unit Jest async | unit Jest async |
$1 | First argument | unit Jest | unit |
$2 | Second argument | unit Jest | Jest |
$N | Nth argument | — | — |
Command Locations
| Type | Location | Description Label |
|---|---|---|
| Project | .commandcode/commands/ | (project) |
| Project (nested) | .commandcode/commands/subdir/ | (project: subdir) |
| User | ~/.commandcode/commands/ | (user) |
| User (nested) | ~/.commandcode/commands/subdir/ | (user: subdir) |
Command not appearing in menu
- Ensure the file has
.mdextension - Check file is in correct directory (
.commandcode/commands/or~/.commandcode/commands/) - Verify file permissions allow reading
Arguments not being replaced
- Use
$1,$2, etc. for positional args (not$0) - Use
$ARGUMENTSfor all args as a string - Check for typos in placeholder names (case-sensitive)
- Create your first custom command and try it out
- Join our Discord community for feedback, requests, and support.