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).
/<command-name> [arguments]
| 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/
# Create a project-level command
mkdir -p .commandcode/commands
echo "Generate unit tests for this code following our testing conventions" > .commandcode/commands/test.md
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/
# Create a user-level command
mkdir -p ~/.commandcode/commands
echo "I am currently being onboarded on this project, help me understand it." > ~/.commandcode/commands/understand.md
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:
.commandcode/commands/
├── frontend/
│ ├── react/
│ │ ├── hooks/
│ │ │ └── use-auth.md → /use-auth (project: frontend/react/hooks)
│ │ └── components/
│ │ └── button.md → /button (project: frontend/react/components)
│ └── vue/
│ └── composable.md → /composable (project: frontend/vue)
├── backend/
│ └── api/
│ └── endpoint.md → /endpoint (project: backend/api)
└── simple.md → /simple (project)
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):
Explain the following concept in simple terms: $ARGUMENTS
Usage:
/explain how async await works in JavaScript
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):
Create a $1 component named $2 with the following features: $3
Usage:
/create-component React Button "onClick and disabled props"
Result:
$1→"React"$2→"Button"$3→"onClick and disabled props"
Quoted Strings
Arguments containing spaces can be wrapped in quotes:
/create-component React "Login Form" "email validation and submit handler"
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
Write $1 tests for the following code using $2.
Requirements:
- Cover edge cases and error scenarios
- Add descriptive test names
- Follow testing best practices
Usage:
/test unit Jest
Documentation Command
File: ~/.commandcode/commands/docs.md
Generate documentation for this $1.
Include:
- Description and purpose
- Parameters/props with types
- Usage examples
- Return values if applicable
Usage:
/docs function
- 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.