Claude Code Custom Slash Commands: Automate Your Repetitive Workflows
What Are Custom Slash Commands?
Claude Code lets you create your own commands like /commit, /review-pr, etc.
Put repetitive work into a single command so you never have to write the same instructions again.
How It Works
Just place Markdown files in .claude/commands/:
.claude/
commands/
review.md β /review
deploy-check.md β /deploy-check
db-migrate.md β /db-migrate
Example 1: Code Review Command
.claude/commands/review.md:
# Code Review
Review current changes (`git diff HEAD`):
1. **Bug risks**: Crash or data corruption potential
2. **Security**: OWASP Top 10 perspective
3. **Performance**: N+1 queries, unnecessary loops
4. **Readability**: Variable names, function length, complexity
5. **Tests**: Coverage gaps
Include file:line numbers for each issue.
Severity: π΄ must fix / π‘ recommended / π’ suggestion
claude /review
Example 2: Pre-Deploy Checklist
.claude/commands/deploy-check.md:
# Pre-Deploy Checklist
Before production deployment:
## Automated
- [ ] `npm test` β all tests pass
- [ ] `npm run lint` β zero lint errors
- [ ] `npm run build` β build succeeds
## Manual
- [ ] `.env.production` has all required variables
- [ ] DB migrations have run
- [ ] Rollback plan is ready
If any issue found, stop and report. If all OK, output "Deploy Ready".
Example 3: DB Migration Generator
.claude/commands/db-migrate.md:
# DB Migration Generator
Generate migration for: $ARGUMENTS
1. Check existing migrations in `migrations/`
2. Create new migration with timestamp in filename
3. Write both UP (apply) and DOWN (rollback)
4. Document impact on existing data
5. Output the migration run command
ORM: Prisma (see prisma/schema.prisma)
claude /db-migrate "add last_login_at to users table"
Team Sharing Strategy
.claude/
commands/ β Team shared (git tracked)
review.md
deploy-check.md
~/.claude/
commands/ β Personal (not git tracked)
my-debug.md
Using Arguments
# Run Tests
Run tests for `$ARGUMENTS` module and analyze any failures.
claude /test UserService
claude /test PaymentController
Summary
| Command | Effect |
|---|---|
| /review | Standardize PR quality checks |
| /deploy-check | Automate deployment verification |
| /db-migrate | Consistent migration generation |
| /pr | Unified PR creation flow |
Make a habit of turning repetitive instructions into commandsβit raises the productivity floor for your entire team.
This article is an excerpt from the Claude Code Complete Guide (7 chapters), available on note.com.
myouga (@myougatheaxo) - VTuber axolotl. Sharing practical AI development tips.
Top comments (0)