Create and manage Claude Code skills following Anthropic best practices...
Comprehensive guide for creating and managing skills in Claude Code with auto-activation system, following Anthropic's official best practices including the 500-line rule and progressive disclosure pattern.
Automatically activates when you mention:
1. UserPromptSubmit Hook (Proactive Suggestions)
claude-skill-activationLocation: The skill-rules.json path is determined by:
.claude/settings.json for file path parameter$CLAUDE_PROJECT_DIR/.claude/skills/skill-rules.jsonHow to find your path:
.claude/settings.json → hooks.UserPromptSubmit[].commandclaude-skill-activation/path/to/claude-skill-activation ~/.claude/skill-rules.json
→ Your path is ~/.claude/skill-rules.jsonDefines:
Purpose: Enforce critical best practices that prevent errors
Characteristics:
"guardrail""block""critical" or "high"Examples:
database-verification - Verify table/column names before Prisma queriesfrontend-dev-guidelines - Enforce React/TypeScript patternsWhen to Use:
Purpose: Provide comprehensive guidance for specific areas
Characteristics:
"domain""suggest""high" or "medium"Examples:
backend-dev-guidelines - Node.js/Express/TypeScript patternsfrontend-dev-guidelines - React/TypeScript best practiceserror-tracking - Sentry integration guidanceWhen to Use:
Location: .claude/skills/{skill-name}/SKILL.md
Template:
---
name: my-new-skill
description: Brief description including keywords that trigger this skill. Mention topics, file types, and use cases. Be explicit about trigger terms.
---
# My New Skill
## Purpose
What this skill helps with
## When to Use
Specific scenarios and conditions
## Key Information
The actual guidance, documentation, patterns, examples
Best Practices:
See SKILL_RULES_REFERENCE.md for complete schema.
⚠️ CRITICAL: The skill-rules.json file MUST have top-level version and skills fields!
Complete File Template (for NEW file):
{
"version": "1.0",
"skills": {
"my-new-skill": {
"type": "domain",
"enforcement": "suggest",
"priority": "medium",
"promptTriggers": {
"keywords": ["keyword1", "keyword2"],
"intentPatterns": ["(create|add).*?something"]
}
}
}
}
Adding to Existing File:
If skill-rules.json already exists with other skills, add your new skill inside the skills object:
{
"version": "1.0",
"skills": {
"existing-skill": { ... },
"my-new-skill": { ← Add here
"type": "domain",
"enforcement": "suggest",
"priority": "medium",
"promptTriggers": {
"keywords": ["keyword1", "keyword2"],
"intentPatterns": ["(create|add).*?something"]
}
}
}
}
# Auto-detects configuration and tests skill activation
test-skill-activation "your test prompt"
# With custom session ID
test-skill-activation -s custom-session "your test prompt"
Based on testing:
If you already have a skill file (SKILL.md) and want to add triggers for it:
See Configuration File section above for path discovery instructions.
cat ~/.claude/skill-rules.json # Use your actual path from Step 1
Use the JSON templates from Quick Start Step 2 above:
test-skill-activation "your test prompt"
Example: Database column name verification
Example: Frontend development guidelines
Rarely used - most skills are either BLOCK or SUGGEST.
Purpose: Don't nag repeatedly in same session
How it works:
State File: .claude/hooks/state/skills-used-{session_id}.json
When creating a new skill, verify:
.claude/skills/{name}/SKILL.mdskill-rules.jsonjq . skill-rules.jsonFor detailed information on specific topics, see in the references folder:
Complete guide to all trigger types:
Complete skill-rules.json schema:
Deep dive into hook internals:
Comprehensive debugging guide:
Ready-to-use pattern collection:
Future enhancements and ideas:
.claude/skills/{name}/SKILL.md with frontmatterversion + skills wrapper!).claude/settings.json hook commandskills object (⚠️ MUST have version + skills wrapper!)echo '{"session_id":"test","prompt":"..."}' | $HOOK_CMDSee TRIGGER_TYPES.md for complete details.
✅ 500-line rule: Keep SKILL.md under 500 lines ✅ Progressive disclosure: Use reference files for details ✅ Table of contents: Add to reference files > 100 lines ✅ One level deep: Don't nest references deeply ✅ Rich descriptions: Include all trigger keywords (max 1024 chars) ✅ Test first: Build 3+ evaluations before extensive documentation ✅ Gerund naming: Prefer verb + -ing (e.g., "processing-pdfs")
test-skill-activation "your test prompt"
See TROUBLESHOOTING.md for complete debugging guide.
Configuration:
skill-rules.json - Master configuration (path determined by hook command in settings.json).claude/hooks/state/ - Session tracking.claude/settings.json - Hook registration (check here for skill-rules.json path)Hooks:
claude-skill-activation <path>) - UserPromptSubmitAll Skills:
.claude/skills/*/SKILL.md - Skill content filesSkill Status: COMPLETE - Restructured following Anthropic best practices ✅ Line Count: < 500 (following 500-line rule) ✅ Progressive Disclosure: Reference files for detailed information ✅
Next: Create more skills, refine patterns based on usage