Custom Commands & Skills
Extend your AI coding agent with reusable slash commands that automate complex workflows.
What Are Slash Commands?
Slash commands are shortcuts that trigger predefined AI workflows:
/review → Run a comprehensive code review
/test → Generate tests for the current file
/docs → Generate documentation
/fix → Analyze and fix the current error
/refactor → Suggest and apply refactoring
/security → Security audit of recent changes
Instead of typing a detailed prompt every time, you type a short command and the agent executes a pre-built workflow.
The benefits:
- Consistent quality (same prompt every time)
- Team standardization (everyone reviews code the same way)
- Speed (one command vs. a paragraph of instructions)
- Composability (commands can call other commands)
Building a /review Command
Create a code review command with a SKILL.md file:
# /review — Code Review
## System Prompt
You are a senior software engineer performing a thorough code review.
Focus on bugs, security, performance, and maintainability.
## Steps
1. Read the git diff of staged or recent changes
2. For each changed file, analyze:
- Logic errors and potential bugs
- Security vulnerabilities (OWASP Top 10)
- Performance concerns
- Code style and readability
3. Rate overall quality (1-10)
4. List specific issues with severity
## Output Format
### Code Review Summary
- **Quality Score:** X/10
- **Files Reviewed:** N
### Issues Found
For each issue:
- **File:** path/to/file.js:LINE
- **Severity:** Critical | High | Medium | Low
- **Issue:** Description
- **Fix:** Suggested solution
### Positive Highlights
- What's done well (acknowledge good code!)
Building a /test Command
Automated test generation:
# /test — Generate Tests
## System Prompt
You are a testing specialist. Generate comprehensive tests
that cover happy paths, error cases, and edge cases.
## Steps
1. Read the target file (current file or specified file)
2. Identify all public functions and methods
3. For each function, generate tests for:
- Happy path (normal input → expected output)
- Error cases (invalid input → appropriate error)
- Edge cases (empty, null, boundary values)
- Integration points (mocked dependencies)
4. Use the project's testing framework (read AGENTS.md)
5. Run the tests and fix any failures
## Constraints
- Match existing test patterns in the project
- Use descriptive test names: "should [expected behavior] when [condition]"
- Mock external dependencies, never call real APIs
- Aim for 90%+ coverage of the target file
Building a /docs Command
Documentation that stays in sync:
# /docs — Generate Documentation
## System Prompt
You are a technical writer who values clarity and accuracy.
## Modes
### Mode 1: Single file (default)
- Read the current file
- Generate JSDoc/TSDoc for all exported functions
- Add module-level documentation
### Mode 2: API reference (/docs api)
- Scan all route files
- Generate endpoint documentation
- Include request/response schemas and examples
### Mode 3: Architecture (/docs arch)
- Analyze project structure
- Generate architecture overview
- Include dependency diagram (as ASCII art)
## Output Rules
- Keep descriptions under 2 sentences
- Always include @param, @returns, @throws
- Add @example with realistic usage
- Match existing documentation style in the project
SKILL.md Plugin System
Skills are reusable, shareable prompt packages:
Directory structure:
.claude/skills/
review/
SKILL.md ← The skill definition
test/
SKILL.md
docs/
SKILL.md
security-audit/
SKILL.md
deploy-check/
SKILL.md
SKILL.md anatomy:
name: Security Audit command: /security description: Run a security audit on recent changes author: your-team version: 1.2.0
Security Audit
Trigger
Run when: manually invoked or on PR creation
System Prompt
[Detailed instructions for the AI]
Tools Required
- File system (read source code)
- Terminal (run dependency audit)
- Git (read recent changes)
Output
[Expected format] ```
Composing Commands
Commands become powerful when they chain together:
The /ship command — a complete pre-merge workflow:
# /ship — Pre-Merge Checklist
## Steps
1. Run /review on all changed files
- If quality score < 7: stop and report issues
2. Run /test to generate missing tests
- If coverage < 80%: stop and report gaps
3. Run /security on all changes
- If any Critical issues: stop immediately
4. Run /docs to update documentation
5. If all checks pass:
- Stage all changes
- Create a commit with a descriptive message
- Report: "Ready to merge! ✓ Review ✓ Tests ✓ Security ✓ Docs"
This single command replaces a 30-minute manual checklist.
Sharing Skills Across Teams
Skills become a team knowledge base:
Team-wide skill repository:
company-ai-skills/ ← Shared Git repo
code-review/SKILL.md ← Standardized reviews
test-generation/SKILL.md ← Test standards
incident-response/SKILL.md ← On-call playbook
onboarding/SKILL.md ← New developer setup
deploy/SKILL.md ← Deployment checklist
Benefits:
- New team members get expert-level AI tools immediately
- Best practices are encoded, not just documented
- Updates propagate to everyone automatically
- Knowledge doesn't leave when people do
Installation:
# Clone team skills into your project
git clone company-ai-skills .claude/skills
Skills are the bridge between individual AI expertise and organizational knowledge. One person discovers the best prompt for code review — the whole team benefits.
---quiz question: What is the main advantage of slash commands over typing prompts manually? options:
- { text: "They use fewer API tokens", correct: false }
- { text: "Consistent quality, team standardization, and speed — the same optimized workflow every time", correct: true }
- { text: "They work without an internet connection", correct: false } feedback: Slash commands encode your best prompts into reusable workflows. Every team member gets the same quality review, the same thorough tests, and the same documentation standard — without needing to remember the optimal prompt.
---quiz question: How does the /ship command demonstrate command composition? options:
- { text: "It runs faster than individual commands", correct: false }
- { text: "It chains /review, /test, /security, and /docs together with quality gates between each step", correct: true }
- { text: "It replaces all other commands", correct: false } feedback: The /ship command composes individual skills into a complete pre-merge workflow with quality gates — if review score is too low, it stops. If tests fail, it stops. This replaces a manual 30-minute checklist with a single command.
---quiz question: Why should teams share skill definitions in a common repository? options:
- { text: "Because skills don't work in individual projects", correct: false }
- { text: "New members get expert-level tools immediately, best practices propagate automatically, and knowledge persists when people leave", correct: true }
- { text: "To reduce the number of API keys needed", correct: false } feedback: Shared skills encode organizational knowledge into reusable AI workflows. New team members are immediately productive with expert-level tools, and the knowledge persists even when the person who created it leaves.