Custom Skills
Create reusable slash commands to automate repetitive workflows.
What are Skills?
Skills are reusable command templates that combine voice commands, prompts, and actions. Instead of repeating complex instructions, you create a skill once and invoke it with a simple slash command.
Built-in Skills
/commitGit OperationsCreates a well-formatted git commit with conventional commit syntax, runs pre-commit checks, and adds co-author attribution.
/protectCode ProtectionAnalyzes code and adds @protected, @immutable, or @maintainable annotations based on usage patterns.
/publishPublishingHandles version bumping, changelog generation, and publishing to npm or other registries.
/sprint-planSprint PlanningGenerates a new sprint TOML file with AI-analyzed tasks, phases, and dependencies.
/protection-auditAnalysisScans codebase for functions that should be protected based on dependency analysis.
Creating Custom Skills
Skills are defined in markdown files in the .claude/commands/ directory:
# .claude/commands/review.md # Code Review Review the current file or selection for: 1. **Code Quality** - Clean code principles - SOLID violations - Code smells 2. **Performance** - N+1 queries - Unnecessary re-renders - Memory leaks 3. **Security** - Input validation - SQL injection risks - XSS vulnerabilities Provide actionable suggestions with code examples.
Now you can use /review to run this analysis.
Skills with Arguments
Skills can accept arguments using placeholders:
# .claude/commands/test.md # Generate Tests Generate comprehensive tests for: $ARGUMENTS Include: - Unit tests for each public method - Edge cases (null, empty, boundary values) - Integration tests if applicable - Mocks for external dependencies Use the project's existing test framework and patterns.
Usage: /test UserService.ts
Skill File Structure
project/ ├── .claude/ │ └── commands/ │ ├── commit.md # /commit │ ├── review.md # /review │ ├── test.md # /test │ ├── docs.md # /docs │ └── deploy.md # /deploy ├── src/ └── ...
The filename (without .md) becomes the slash command name.
Best Practices
Be Specific
Include exact instructions, not vague guidelines. The more specific, the more consistent results.
Include Examples
Show the expected output format. AI follows examples better than descriptions.
Reference Project Patterns
Tell AI to "follow existing patterns in src/" rather than defining patterns from scratch.
Version Control Skills
Commit .claude/commands/ to git so the whole team uses the same skills.
Complete Example: /api Skill
# .claude/commands/api.md
# Create API Endpoint
Create a new API endpoint for: $ARGUMENTS
## Requirements
1. **Location**: `app/api/[endpoint]/route.ts`
2. **Structure**:
- Input validation with Zod
- Error handling with standard format
- TypeScript types for request/response
3. **Security**:
- Auth check using `getServerSession`
- Rate limiting consideration
- Input sanitization
4. **Pattern to follow**:
See `app/api/users/route.ts` for reference
## Output Format
```typescript
import { NextResponse } from 'next/server';
import { z } from 'zod';
// ... rest of implementation
```