|
| 1 | +--- |
| 2 | +description: Guide for creating new slash commands |
| 3 | +argument-hint: <command-name> <description> |
| 4 | +--- |
| 5 | + |
| 6 | +## General Guidelines |
| 7 | + |
| 8 | +### Output Style |
| 9 | + |
| 10 | +- **Never explicitly mention TDD** in code, comments, commits, PRs, or issues |
| 11 | +- Write natural, descriptive code without meta-commentary about the development process |
| 12 | +- The code should speak for itself - TDD is the process, not the product |
| 13 | + |
| 14 | +Beads is available for task tracking. Use `mcp__beads__*` tools to manage issues (the user interacts via `bd` commands). |
| 15 | + |
| 16 | +## Plan File Restriction |
| 17 | + |
| 18 | +**NEVER create, read, or update plan.md files.** Claude Code's internal planning files are disabled for this project. Use other methods to track implementation progress (e.g., comments, todo lists, or external tools). |
| 19 | + |
| 20 | +# Slash Command Creator Guide |
| 21 | + |
| 22 | +## How This Command Works |
| 23 | + |
| 24 | +The `/add-command` command shows this guide for creating new slash commands. It includes: |
| 25 | + |
| 26 | +- Command structure and syntax |
| 27 | +- Common patterns and examples |
| 28 | +- Security restrictions and limitations |
| 29 | +- Frontmatter options |
| 30 | + |
| 31 | +**Note for AI**: When creating commands, you CAN use bash tools like `Bash(mkdir:*)`, `Bash(ls:*)`, `Bash(git status:*)` in the `allowed-tools` frontmatter of NEW commands - but ONLY for operations within the current project directory. This command itself doesn't need bash tools since it's just documentation. |
| 32 | + |
| 33 | +## Command Locations |
| 34 | + |
| 35 | +- **Personal**: `~/.claude/commands/` (available across all projects) |
| 36 | +- **Project**: `.claude/commands/` (shared with team, shows "(project)") |
| 37 | + |
| 38 | +## Basic Structure |
| 39 | + |
| 40 | +```markdown |
| 41 | +--- |
| 42 | +allowed-tools: Read, Glob, Grep, Bash(git status:*), Task |
| 43 | +description: Brief description of what this command does |
| 44 | +argument-hint: [required-arg] [optional-arg] |
| 45 | +--- |
| 46 | + |
| 47 | +# Command Title |
| 48 | + |
| 49 | +Your command instructions here. |
| 50 | + |
| 51 | +**User arguments:** |
| 52 | + |
| 53 | +Add-command: $ARGUMENTS |
| 54 | + |
| 55 | +**End of user arguments** |
| 56 | + |
| 57 | +File reference: @path/to/file.js |
| 58 | + |
| 59 | +Bash command output: (exclamation)git status(backticks) |
| 60 | +``` |
| 61 | + |
| 62 | +## ⚠️ Security Restrictions |
| 63 | + |
| 64 | +**Bash Commands (exclamation prefix)**: Limited to current working directory only. |
| 65 | + |
| 66 | +- ✅ Works: `! + backtick + git status + backtick` (in project dir) |
| 67 | +- ❌ Blocked: `! + backtick + ls /outside/project + backtick` (outside project) |
| 68 | +- ❌ Blocked: `! + backtick + pwd + backtick` (if referencing dirs outside project) |
| 69 | + |
| 70 | +**File References (`@` prefix)**: No directory restrictions. |
| 71 | + |
| 72 | +- ✅ Works: `@/path/to/system/file.md` |
| 73 | +- ✅ Works: `@../other-project/file.js` |
| 74 | + |
| 75 | +## Common Patterns |
| 76 | + |
| 77 | +### Simple Command |
| 78 | + |
| 79 | +```bash |
| 80 | +echo "Review this code for bugs and suggest fixes" > ~/.claude/commands/review.md |
| 81 | +``` |
| 82 | + |
| 83 | +### Command with Arguments |
| 84 | + |
| 85 | +**Note for AI**: The example below uses a fullwidth dollar sign ($, U+FF04) to prevent interpolation in this documentation. When creating actual commands, use the regular `$` character. |
| 86 | + |
| 87 | +```markdown |
| 88 | +Fix issue $ARGUMENTS following our coding standards |
| 89 | +``` |
| 90 | + |
| 91 | +### Command with File References |
| 92 | + |
| 93 | +```markdown |
| 94 | +Compare @src/old.js with @src/new.js and explain differences |
| 95 | +``` |
| 96 | + |
| 97 | +### Command with Bash Output (Project Directory Only) |
| 98 | + |
| 99 | +```markdown |
| 100 | +--- |
| 101 | +allowed-tools: Bash(git status:*), Bash(git branch:*), Bash(git log:*) |
| 102 | +--- |
| 103 | +Current status: (!)git status(`) |
| 104 | +Current branch: (!)git branch --show-current(`) |
| 105 | +Recent commits: (!)git log --oneline -5(`) |
| 106 | + |
| 107 | +Create commit for these changes. |
| 108 | +``` |
| 109 | + |
| 110 | +**Note**: Only works with commands in the current project directory. |
| 111 | + |
| 112 | +### Namespaced Command |
| 113 | + |
| 114 | +**Note for AI**: The example below uses a fullwidth dollar sign ($, U+FF04) to prevent interpolation in this documentation. When creating actual commands, use the regular `$` character. |
| 115 | + |
| 116 | +```bash |
| 117 | +mkdir -p ~/.claude/commands/ai |
| 118 | +echo "Ask GPT-5 about: $ARGUMENTS" > ~/.claude/commands/ai/gpt5.md |
| 119 | +# Creates: /ai:gpt5 |
| 120 | +``` |
| 121 | + |
| 122 | +## Frontmatter Options |
| 123 | + |
| 124 | +- `allowed-tools`: Tools this command can use |
| 125 | + - **Important**: Intrusive tools like `Write`, `Edit`, `NotebookEdit` should NEVER be allowed in commands unless the user explicitly requests them. These tools modify files and should only be used when the command's purpose is to make changes. |
| 126 | + - ✅ Safe for most commands: `Read`, `Glob`, `Grep`, `Bash(git status:*)`, `Task`, `AskUserQuestion` |
| 127 | +- `description`: Brief description (shows in /help) |
| 128 | +- `argument-hint`: Help text for arguments |
| 129 | +- `model`: Specific model to use |
| 130 | + |
| 131 | +## Best Practices |
| 132 | + |
| 133 | +### Safe Commands (No Security Issues) |
| 134 | + |
| 135 | +```markdown |
| 136 | +# System prompt editor (file reference only) |
| 137 | +(@)path/to/system/prompt.md |
| 138 | + |
| 139 | +Edit your system prompt above. |
| 140 | +``` |
| 141 | + |
| 142 | +### Project-Specific Commands (Bash OK) |
| 143 | + |
| 144 | +```markdown |
| 145 | +--- |
| 146 | +allowed-tools: Bash(git status:*), Bash(npm list:*) |
| 147 | +--- |
| 148 | +Current git status: (!)git status(`) |
| 149 | +Package info: (!)npm list --depth=0(`) |
| 150 | + |
| 151 | +Review project state and suggest next steps. |
| 152 | +``` |
| 153 | + |
| 154 | +### Cross-Directory File Access (Use @ not !) |
| 155 | + |
| 156 | +```markdown |
| 157 | +# Compare config files |
| 158 | +Compare (@)path/to/system.md with (@)project/config.md |
| 159 | + |
| 160 | +Show differences and suggest improvements. |
| 161 | +``` |
| 162 | + |
| 163 | +## Usage |
| 164 | + |
| 165 | +After creating: `/<command-name> [arguments]` |
| 166 | + |
| 167 | +Example: `/review` or `/ai:gpt5 "explain this code"` |
0 commit comments