2025-08-04
Turn Your Best AI Prompts into Reusable Commands
You’ve documented your patterns with CLAUDE.md files. Claude checks them automatically. Your code is consistent now.
But you’re still typing the same TDD instructions every time you implement something. What if that perfect prompt could be a simple command? What if we could express our intentions for work this way?
/implement #45
/implement Add password reset with email confirmation
/implement docs/features/search.md
/implement Fix users can't remove items from cart
Each command captures your workflow once, then applies it consistently every time.
The Problem: Great Documentation, Repetitive Instructions
You’ve done the hard work. Root CLAUDE.md with project conventions. Specialized CLAUDE.md files in each directory. Clear patterns and anti-patterns documented. Claude checks these files automatically.
But you’re still repeating yourself:
- “Follow TDD - write the test first”
- “Check the patterns in app/models/CLAUDE.md”
- “Find similar examples with grep”
Same workflow instructions, every single time.
Documentation tells Claude what your patterns are. But not how to apply them consistently. You need to capture your workflow, not just your patterns.
The Solution: Custom Slash Commands
From Anthropic’s docs, custom commands are prompt templates stored as Markdown files. They’re for repeated workflows you use often, stored in .claude/commands/
, and can include $ARGUMENTS
for dynamic input.
Think of it this way: CLAUDE.md files define what your patterns are. Commands define how to apply them. Together, they make consistency automatic.
The Complete /implement Command
Save this as .claude/commands/implement.md
:
---
description: Implement features from issues, PRDs, or direct requests
argument-hint: "#123" or "path/to/plan.md" or "feature description"
allowed-tools: Read, Write, Edit, MultiEdit, Bash, TodoWrite, Grep
---
# Implement $ARGUMENTS
## Step 1: Understand the Request
Look at $ARGUMENTS and figure out what the user wants:
- If it's a number with #, it's a GitHub issue - use `gh issue view` to read it
- If it's a file path, read that file
- Otherwise, it's a direct request - use it as-is
## Step 2: Follow Our TDD Process
Follow the patterns documented in CLAUDE.md files:
1. Write failing test first
2. Implement just enough to pass
3. Verify test passes
Always check relevant CLAUDE.md files for patterns and examples.
Breaking It Down
The frontmatter controls how your command appears and behaves:
- description: What appears in the command menu when you type
/
- argument-hint: Shows users the expected input format
- allowed-tools: Grants permissions the command needs to work
Step 1 handles input intelligently. $ARGUMENTS
is Anthropic’s built-in way to pass parameters. Simple conditional instructions guide different behaviors. No complex parsing needed.
Step 2 reinforces your workflow. It tells Claude to check CLAUDE.md (which it already does), provides clear sequential steps, and keeps the workflow consistent every time.
The Magic of $ARGUMENTS
One command, infinite flexibility.
GitHub Issue
/implement #45
- $ARGUMENTS becomes “#45”
- Command fetches and implements the issue
PRD File
/implement docs/prd/search.md
- $ARGUMENTS becomes “docs/prd/search.md”
- Command reads and implements from PRD
Direct Request
/implement Add user avatars
- $ARGUMENTS becomes “Add user avatars”
- Command implements the feature
How the Command Works in Practice
Simple model addition
/implement Add published_at timestamp to Article
The command will:
- Use “Add published_at timestamp to Article” as the task
- Check CLAUDE.md files automatically
- Write test for published_at behavior first
- Create migration and update model
- Verify test passes
Bug fix from issue
/implement #45
The command will:
- Run
gh issue view 45
to get details - Read: “Users can’t remove items from cart”
- Check CLAUDE.md files for patterns
- Write failing test first
- Implement fix
- Verify test passes
Complete feature from PRD
/implement docs/features/wishlists.md
The command will:
- Read the PRD file for requirements
- Check CLAUDE.md files throughout
- Implement with TDD for each component
- Follow all your documented patterns
Making It Natural
Add to your root CLAUDE.md:
## Natural Language Implementation
When users say:
- "Create X" → Treat as `/implement X`
- "Add Y" → Treat as `/implement Y`
- "Fix Z" → Treat as `/implement Z`
The /implement command will handle the TDD workflow.
Now “Create a User model” triggers your complete workflow without typing /implement
.
Refining Your Workflow
Your initial commands and documentation won’t be perfect. That’s expected.
When you notice patterns you don’t like:
/analyze-workflow
This command:
- Checks recent changes against your patterns
- Identifies what went wrong
- Suggests improvements to commands and CLAUDE.md
- Asks before applying changes
Example Refinement Session
/implement Add notification system with audit trail
Result: Test file with 281 lines, nested describes, business logic in model.
/analyze-workflow
Output:
## Pattern Violations Found:
1. **Model Test Anti-Patterns**:
- ❌ Nested validation describes
- ❌ Test file too long (281 lines)
- ❌ Using create! instead of fixtures
### Root Cause Analysis:
- No line limit guidance in test/CLAUDE.md
- Examples don't show flat validation structure
### Suggested Improvements:
1. Update test/CLAUDE.md:
- Add "50-100 line target" for model tests
- Show flat validation examples
Would you like me to apply these improvements? (yes/no)
The iteration process:
- Run your command - See what it produces
- Identify issues - What patterns were violated?
- Analyze root cause - Why did it happen?
- Update guidance - Improve commands or CLAUDE.md
- Test again - Verify improvements work
Your patterns evolve with your codebase. Team preferences emerge over time. Edge cases reveal missing guidance. Continuous improvement beats perfect first attempts.
Why This Works
Commands reference your existing patterns. Documentation ensures consistency. Commands stay focused on workflow.
Your command provides:
markdown
"Follow the patterns documented in CLAUDE.md files"
This simple instruction builds on Claude’s existing behavior. No complex conditional logic. Works for any implementation type.
Getting Started
Step 1: Create the Command
mkdir -p .claude/commands
Copy the complete command from above into .claude/commands/implement.md
Step 2: Try It
/implement Add Product model with name and price
Watch as it follows your instructions:
- Checks patterns
- Writes tests first
- Implements correctly
Step 3: Refine It
When you see output you don’t like:
/analyze-workflow
Apply suggested improvements and try again.
Results and Impact
Before commands:
- 5-10 minutes explaining each time
- Sometimes forget TDD
- Inconsistent implementations
- Mental fatigue from repetition
After commands:
- Consistent implementations
- TDD every single time
- Follows your patterns
- Mental energy for real problems
Once /implement
works, create more:
/debug - Systematic debugging process
/refactor - Apply patterns to existing code
/review - Check against CLAUDE.md patterns
/test - Add tests to existing code
Each leverages your CLAUDE.md foundation.
Key Takeaways
Commands are saved prompts - Anthropic designed them as reusable templates. $ARGUMENTS provides flexibility. Natural language instructions work best.
They complete your documentation - CLAUDE.md = the patterns. Commands = the workflow. Together = consistency.
Simple instructions work - Clear steps get consistent results. Build on Claude’s existing behaviors. No complex logic needed.
Iteration is expected - Start simple. Refine based on output. Use /analyze-workflow to improve systematically.
Try It Yourself
The setup is simple:
mkdir -p .claude/commands
Then copy the /implement
command from above into .claude/commands/implement.md
.
That’s it. Next time you need to implement something, just type /implement
followed by what you want.
Remember: your first command won’t be perfect. That’s fine. Use /analyze-workflow
when you see output you don’t like, and refine from there.
The real power comes from combining this with your CLAUDE.md files. Documentation defines the patterns. Commands apply them. No more typing the same instructions every time.