Skills are knowledge bundles that give AI agents domain-specific expertise. This tutorial shows you how to create, test, and deploy custom skills for your project.
---name: my-skilldescription: One-line description for skill selectionversion: 1.0.0source: docs/path/to/canonical-source.mdsource_sections: Section 2.3, Appendix Alast_updated: 2026-01-15allowed-tools: Read, Bash, Grep, Write---# My Skill Name**Source**: `docs/path/to/canonical-source.md` (canonical)## When to UseActivate this skill when:- Trigger condition 1- Trigger condition 2**Use skill first**: What to try before escalating.**Spawn sub-agent when**: When to delegate to specialized agent.## Core ContentThe main knowledge for this skill...## Commands\`\`\`bash# Key commands the agent should knowcommand --example\`\`\`## Decision TreeWhen X, do Y...---**Full spec**: [link to canonical source](path/to/source.md)
What single thing should this skill enable? Examples:
Database migration workflow
API documentation generation
Security audit checklist
Performance profiling
Find the canonical source
Skills should reference existing documentation, not duplicate it:
# Check for existing docsls docs/**/*.mdgrep -r "topic" docs/
Create the skill directory
mkdir -p .claude/skills/my-skill
Write the skill definition
cat > .claude/skills/my-skill/SKILL.md << 'EOF'---name: my-skilldescription: Brief description for AI to understand when to useversion: 1.0.0source: docs/reference/my-topic.mdlast_updated: 2026-01-15allowed-tools: Read, Bash---# My SkillContent here...EOF
Here’s a complete example for database migrations:
---name: database-migrationdescription: Database schema migration workflow. Use when creating migrations, running migrations, or handling migration conflicts.version: 1.0.0source: docs/database/migrations.mdlast_updated: 2026-01-15allowed-tools: Read, Bash, Write---# Database Migration Skill**Source**: `docs/database/migrations.md` (canonical)## When to UseActivate this skill when:- Creating new database tables or columns- Modifying existing schema- Handling migration conflicts- Rolling back failed migrations**Use skill first**: Follow the migration checklist below.**Spawn database-expert agent when**: Complex multi-table migrations, data transformations, or production rollbacks.## Migration Checklist1. Check current migration status2. Create migration file with descriptive name3. Write idempotent up/down migrations4. Test locally with fresh database5. Run in staging before production## Commands\`\`\`bash# Check statuspnpm db:migrate:status# Create new migrationpnpm db:migrate:create add_user_preferences# Run pending migrationspnpm db:migrate:up# Rollback last migrationpnpm db:migrate:down\`\`\`## Migration File Pattern\`\`\`sql-- Up migrationCREATE TABLE IF NOT EXISTS user_preferences (id UUID PRIMARY KEY DEFAULT gen_random_uuid(),user_id UUID NOT NULL REFERENCES users(id),theme VARCHAR(20) DEFAULT 'system',created_at TIMESTAMPTZ DEFAULT now());-- Down migrationDROP TABLE IF EXISTS user_preferences;\`\`\`## Decision Tree**Adding a column?**- Nullable? Add with default, no downtime- Non-nullable? Add nullable, backfill, add constraint**Removing a column?**- First: Stop reading from it in code- Then: Remove in next migration---**Full spec**: [migrations.md](docs/database/migrations.md)