// Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dependencies, and rust-documentation skills.
| name | writing-skills |
| description | Create and manage Claude Code skills in HASH repository following Anthropic best practices. Use when creating new skills, modifying skill-rules.json, understanding trigger patterns, working with hooks, debugging skill activation, or implementing progressive disclosure. Covers skill structure, YAML frontmatter, trigger types (keywords, intent patterns), UserPromptSubmit hook, and the 500-line rule. Includes validation and debugging with SKILL_DEBUG. Examples include rust-error-stack, cargo-dependencies, and rust-documentation skills. |
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:
UserPromptSubmit Hook (Proactive Suggestions)
.claude/hooks/skill-activation-prompt.tsSKILL_DEBUG=true to see matching logic--validate flag to check configurationLocation: .claude/skills/skill-rules.json
Defines:
"suggest" is implemented)Purpose: Provide comprehensive guidance for specific areas
Characteristics:
"domain""suggest" (advisory, non-blocking)"high" or "medium"Examples in HASH:
rust-error-stack - Error handling with error-stack cratecargo-dependencies - Cargo.toml dependency management patternsrust-documentation - Rust doc comment best practiceswriting-skills - This skill! Meta-guidance for creating skillsWhen to Use:
Guardrail skills with blocking enforcement ("block") are designed but not yet implemented. These would enforce critical patterns and prevent common mistakes.
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.
Basic Template:
{
"my-new-skill": {
"type": "domain",
"enforcement": "suggest",
"priority": "medium",
"promptTriggers": {
"keywords": ["keyword1", "keyword2"],
"intentPatterns": ["(create|add).*?something"]
}
}
}
Test with specific prompt:
echo '{"session_id":"test","prompt":"your test prompt","cwd":".","permission_mode":"auto","transcript_path":""}' | \
yarn workspace @local/claude-hooks run:skill
Validate configuration:
yarn lint:skill
Debug matching logic:
echo '{"session_id":"test","prompt":"your test prompt","cwd":".","permission_mode":"auto","transcript_path":""}' | \
yarn workspace @local/claude-hooks dev:skill
Based on testing:
\\b(keyword)\\b instead of just keywordโ Keep SKILL.md under 500 lines โ Use progressive disclosure with reference files โ Add table of contents to reference files > 100 lines โ Write detailed description with trigger keywords โ Test with 3+ real scenarios before documenting โ Iterate based on actual usage
Currently only SUGGEST enforcement is implemented:
Future: Blocking enforcement ("block") and warning enforcement ("warn") are designed in the schema but not yet implemented.
Yarn Commands:
yarn lint:skill - Validate configurationyarn workspace @local/claude-hooks run:skill - Run skill activation with test promptyarn workspace @local/claude-hooks dev:skill - Run with debug output enabledEnvironment Variables:
SKILL_DEBUG=true - Show detailed matching logic to stderr (automatically set by yarn dev:skill)CLAUDE_PROJECT_DIR - Override project directory (auto-detected if not set)Validation shows:
When creating a new skill, verify:
.claude/skills/{name}/SKILL.mdskill-rules.jsonyarn workspace @local/claude-hooks dev:skill)jq . .claude/skills/skill-rules.jsonyarn lint:skillFor detailed information on specific topics, see:
Complete guide to trigger types (currently implemented):
Note: File path and content pattern triggers are documented but not yet used by the hook.
Complete skill-rules.json schema:
Deep dive into hook internals:
Note: PreToolUse hooks and session state management are documented but not yet implemented.
Comprehensive debugging guide:
SKILL_DEBUG=true)Ready-to-use pattern collection:
Ideas for expanding the skill system:
.claude/skills/{name}/SKILL.md with frontmatter.claude/skills/skill-rules.jsonyarn lint:skill and yarn workspace @local/claude-hooks dev:skillSee trigger-types.md for complete details.
yarn workspace @local/claude-hooks dev:skill - Show detailed matching logicyarn lint:skill - Validate configuration.claude/hooks/skill-activation-prompt.ts for implementationโ 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 hooks manually:
# Test with prompt
echo '{"session_id":"test","prompt":"test","cwd":".","permission_mode":"auto","transcript_path":""}' | \
yarn workspace @local/claude-hooks run:skill
# Validate configuration
yarn lint:skill
# Debug matching
echo '{"session_id":"test","prompt":"test","cwd":".","permission_mode":"auto","transcript_path":""}' | \
yarn workspace @local/claude-hooks dev:skill
See troubleshooting.md for complete debugging guide.
Configuration:
.claude/skills/skill-rules.json - Master configuration.claude/hooks/state/ - Session tracking.claude/settings.json - Hook registrationHooks:
.claude/hooks/skill-activation-prompt.ts - UserPromptSubmit.claude/hooks/error-handling-reminder.ts - Stop event (gentle reminders)All 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