|
| 1 | +# Commands |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Commands are pre-defined workflows that orchestrate multiple agents, skills, and MCP servers to accomplish common development tasks. They provide automation, consistency, and reduced cognitive overhead for recurring scenarios. |
| 6 | + |
| 7 | +## What Are Commands? |
| 8 | + |
| 9 | +Commands in Claude Code are executable workflows that: |
| 10 | + |
| 11 | +- **Automate**: Chain multiple steps without manual intervention |
| 12 | +- **Orchestrate**: Coordinate agents, skills, and external tools |
| 13 | +- **Standardize**: Ensure consistent approaches to common tasks |
| 14 | +- **Optimize**: Reduce back-and-forth by following proven patterns |
| 15 | + |
| 16 | +Think of commands as "macros" for development workflows. |
| 17 | + |
| 18 | +## Available Commands |
| 19 | + |
| 20 | +| Command | Description | Agent Flow | When to Use | |
| 21 | +|---------|-------------|------------|-------------| |
| 22 | +| [/quick-implement](./quick-implement.md) | Zero-interruption implementation | Implementer → Tester | Small, well-defined tasks you want done autonomously | |
| 23 | + |
| 24 | +## Command Registry |
| 25 | + |
| 26 | +### Development Workflow Commands |
| 27 | + |
| 28 | +- **[/quick-implement](./quick-implement.md)**: Rapid implementation with minimal interruption |
| 29 | + - Understand → Implement → Test → Commit → Report |
| 30 | + - Best for: Small features, bug fixes, simple refactors |
| 31 | + - Autonomous: Yes (no checkpoints) |
| 32 | + |
| 33 | +### Planned Commands (Examples) |
| 34 | + |
| 35 | +The `examples/` directory contains templates for additional commands: |
| 36 | + |
| 37 | +- **[/research-and-design](./examples/research-and-design.md)**: Research → Architecture → Review |
| 38 | + - Best for: New features requiring design decisions |
| 39 | + |
| 40 | +- **[/bug-hunt](./examples/bug-hunt.md)**: Debug → Fix → Test → Review |
| 41 | + - Best for: Investigating and resolving bugs |
| 42 | + |
| 43 | +- **[/refactor-safely](./examples/refactor-safely.md)**: Analyze → Refactor → Test → Review |
| 44 | + - Best for: Code improvement with safety checks |
| 45 | + |
| 46 | +## When to Use Commands |
| 47 | + |
| 48 | +### Use Commands When: |
| 49 | + |
| 50 | +1. **Repetitive workflows**: You find yourself following the same agent sequence repeatedly |
| 51 | +2. **Time-sensitive tasks**: You want fast execution without manual coordination |
| 52 | +3. **Standard scenarios**: The task fits a well-known pattern |
| 53 | +4. **Autonomous execution**: You trust the workflow to run without intervention |
| 54 | +5. **Learning**: You're new and want guided workflows |
| 55 | + |
| 56 | +### Don't Use Commands When: |
| 57 | + |
| 58 | +1. **Complex/novel tasks**: The situation is unique or experimental |
| 59 | +2. **Exploratory work**: You're not sure what approach to take yet |
| 60 | +3. **High-stakes changes**: Security, data migrations, or irreversible operations |
| 61 | +4. **Need control**: You want to review each step before proceeding |
| 62 | +5. **Custom workflows**: The task requires a non-standard agent sequence |
| 63 | + |
| 64 | +## How Commands Work |
| 65 | + |
| 66 | +### Command Structure |
| 67 | + |
| 68 | +Each command defines: |
| 69 | + |
| 70 | +1. **Name and Description**: What the command does |
| 71 | +2. **Prerequisites**: What must be true before running |
| 72 | +3. **Agent Flow**: Which agents execute in which order |
| 73 | +4. **MCP Servers**: Which external tools are used |
| 74 | +5. **Workflow Steps**: Detailed execution sequence |
| 75 | +6. **Success Criteria**: How to know if the command succeeded |
| 76 | +7. **Error Handling**: What to do when things go wrong |
| 77 | + |
| 78 | +### Command Execution |
| 79 | + |
| 80 | +When you invoke a command: |
| 81 | + |
| 82 | +``` |
| 83 | +User: /quick-implement "Add validation to login form" |
| 84 | + ↓ |
| 85 | +Command parses task and context |
| 86 | + ↓ |
| 87 | +Agent 1 (Implementer) executes with context |
| 88 | + ↓ |
| 89 | +Agent 2 (Tester) receives handoff and executes |
| 90 | + ↓ |
| 91 | +Command completes and reports results |
| 92 | +``` |
| 93 | + |
| 94 | +### Autonomous vs Interactive |
| 95 | + |
| 96 | +Commands can be: |
| 97 | + |
| 98 | +- **Autonomous**: Run start-to-finish without asking questions (e.g., `/quick-implement`) |
| 99 | +- **Interactive**: Pause for user input at checkpoints (e.g., `/research-and-design`) |
| 100 | +- **Hybrid**: Autonomous with optional interrupt points |
| 101 | + |
| 102 | +## Commands and Agents |
| 103 | + |
| 104 | +Commands orchestrate [agents](../agents/README.md) in specific sequences: |
| 105 | + |
| 106 | +- Commands define **which agents** run |
| 107 | +- Commands define **in what order** agents run |
| 108 | +- Commands pass **context** between agents |
| 109 | +- Commands enforce **quality gates** between stages |
| 110 | + |
| 111 | +Example from `/quick-implement`: |
| 112 | + |
| 113 | +```markdown |
| 114 | +## Agent Flow |
| 115 | + |
| 116 | +1. **Implementer Agent (Analysis Mode)** |
| 117 | + - Input: Task description |
| 118 | + - Output: Implementation plan |
| 119 | + |
| 120 | +2. **Implementer Agent (Execution Mode)** |
| 121 | + - Input: Implementation plan |
| 122 | + - Output: Working code |
| 123 | + |
| 124 | +3. **Tester Agent** |
| 125 | + - Input: New code |
| 126 | + - Output: Passing tests |
| 127 | +``` |
| 128 | + |
| 129 | +## Commands and Skills |
| 130 | + |
| 131 | +Commands can specify which [skills](../skills/README.md) agents should apply: |
| 132 | + |
| 133 | +```markdown |
| 134 | +## Required Skills |
| 135 | + |
| 136 | +- `language/javascript` - For JavaScript implementation |
| 137 | +- `tools/git` - For version control operations |
| 138 | +- `core/test-generation` - For creating tests |
| 139 | +``` |
| 140 | + |
| 141 | +This ensures agents have the right knowledge for the task. |
| 142 | + |
| 143 | +## Commands and MCP Servers |
| 144 | + |
| 145 | +Commands can leverage [MCP servers](../mcp-servers/README.md) for extended capabilities: |
| 146 | + |
| 147 | +```markdown |
| 148 | +## MCP Servers Used |
| 149 | + |
| 150 | +- `filesystem` - For reading/writing code files |
| 151 | +- `github` - For creating commits and PRs |
| 152 | +- `web-search` - For researching solutions (optional) |
| 153 | +``` |
| 154 | + |
| 155 | +## Creating Custom Commands |
| 156 | + |
| 157 | +To create a new command: |
| 158 | + |
| 159 | +1. **Start with the template**: Use [command template](./template.md) |
| 160 | +2. **Define the workflow**: Map out agent sequence and steps |
| 161 | +3. **Identify dependencies**: Note required skills and MCP servers |
| 162 | +4. **Set boundaries**: Clearly state when to use and when NOT to use |
| 163 | +5. **Test thoroughly**: Run through various scenarios |
| 164 | +6. **Document examples**: Provide concrete usage examples |
| 165 | +7. **Add to registry**: Update this README |
| 166 | + |
| 167 | +### Command Naming Conventions |
| 168 | + |
| 169 | +- Use kebab-case: `/command-name` |
| 170 | +- Start with verb: `/quick-implement`, `/research-and-design` |
| 171 | +- Be specific: `/refactor-safely` not just `/refactor` |
| 172 | +- Keep short: Aim for 2-3 words maximum |
| 173 | + |
| 174 | +## Command Examples |
| 175 | + |
| 176 | +### Simple Command (Single Agent) |
| 177 | + |
| 178 | +```markdown |
| 179 | +# /format-code |
| 180 | + |
| 181 | +## Description |
| 182 | +Formats all code files in the current directory using language-specific formatters. |
| 183 | + |
| 184 | +## Agent Flow |
| 185 | +Implementer (Tool Execution Mode) |
| 186 | + |
| 187 | +## Workflow |
| 188 | +1. Detect languages in project |
| 189 | +2. Run appropriate formatters |
| 190 | +3. Report formatting changes |
| 191 | +``` |
| 192 | + |
| 193 | +### Complex Command (Multiple Agents) |
| 194 | + |
| 195 | +```markdown |
| 196 | +# /release-prep |
| 197 | + |
| 198 | +## Description |
| 199 | +Prepares codebase for release: updates, tests, docs, changelog. |
| 200 | + |
| 201 | +## Agent Flow |
| 202 | +Refactorer → Tester → Documenter → Reviewer |
| 203 | + |
| 204 | +## Workflow |
| 205 | +1. Refactorer: Clean up code, remove TODOs |
| 206 | +2. Tester: Ensure 100% test pass rate |
| 207 | +3. Documenter: Update changelog and docs |
| 208 | +4. Reviewer: Final quality check |
| 209 | +``` |
| 210 | + |
| 211 | +## Best Practices |
| 212 | + |
| 213 | +### When Using Commands |
| 214 | + |
| 215 | +1. **Read the description**: Understand what the command does before using |
| 216 | +2. **Check prerequisites**: Ensure requirements are met |
| 217 | +3. **Provide clear input**: Give commands precise, actionable descriptions |
| 218 | +4. **Trust the process**: Avoid interrupting autonomous commands |
| 219 | +5. **Review the output**: Always check the results |
| 220 | + |
| 221 | +### When Creating Commands |
| 222 | + |
| 223 | +1. **Solve a real problem**: Create commands for actual recurring needs |
| 224 | +2. **Make it autonomous**: Minimize user interaction where possible |
| 225 | +3. **Handle errors gracefully**: Account for failure scenarios |
| 226 | +4. **Document thoroughly**: Include examples and anti-patterns |
| 227 | +5. **Keep it focused**: One command = one workflow |
| 228 | +6. **Version carefully**: Breaking changes should be documented |
| 229 | + |
| 230 | +## Troubleshooting |
| 231 | + |
| 232 | +### Command Fails to Execute |
| 233 | + |
| 234 | +- Check prerequisites are met |
| 235 | +- Verify required MCP servers are configured |
| 236 | +- Ensure you have necessary permissions |
| 237 | +- Review command documentation for requirements |
| 238 | + |
| 239 | +### Command Produces Unexpected Results |
| 240 | + |
| 241 | +- Review the task description you provided |
| 242 | +- Check if the scenario matches "when to use" criteria |
| 243 | +- Examine intermediate outputs from agents |
| 244 | +- Consider using manual agent workflow instead |
| 245 | + |
| 246 | +### Command Asks Too Many Questions |
| 247 | + |
| 248 | +- The task may be ambiguous or complex |
| 249 | +- Consider using a more interactive workflow |
| 250 | +- Break the task into smaller, clearer pieces |
| 251 | +- Review "when NOT to use" section |
| 252 | + |
| 253 | +## Examples |
| 254 | + |
| 255 | +See [examples directory](../examples/README.md) for detailed command usage: |
| 256 | + |
| 257 | +- [Command Integration Examples](../examples/integrations/commands-with-mcp.md) |
| 258 | +- [Workflow Examples](../examples/workflows/) |
| 259 | + |
| 260 | +## Additional Resources |
| 261 | + |
| 262 | +- [Command Template](./template.md) - Template for creating new commands |
| 263 | +- [Agents](../agents/README.md) - Understanding agent capabilities |
| 264 | +- [Skills](../skills/README.md) - Capabilities commands can leverage |
| 265 | +- [MCP Servers](../mcp-servers/README.md) - External tool integrations |
| 266 | +- [Orchestration Patterns](../orchestration.md) - Agent coordination strategies |
0 commit comments