6━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
7🎯 SKILL ACTIVATED: skill-developer
8━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
9
10# Skill Developer Guide
11
12## Purpose
13
14Comprehensive 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.
15
16## When to Use This Skill
17
18Automatically activates when you mention:
19- Creating or adding skills
20- Modifying skill triggers or rules
21- Understanding how skill activation works
22- Debugging skill activation issues
23- Working with skill-rules.json
24- Hook system mechanics
25- Claude Code best practices
26- Progressive disclosure
27- YAML frontmatter
28- 500-line rule
29
30---
31
32## System Overview
33
34### Two-Hook Architecture
35
36**1. UserPromptSubmit Hook** (Proactive Suggestions)
37- **File**: .claude/hooks/skill-activation-prompt.ts
38- **Trigger**: BEFORE Claude sees user's prompt
39- **Purpose**: Suggest relevant skills based on keywords + intent patterns
40- **Method**: Injects formatted reminder as context (stdout → Claude's input)
41- **Use Cases**: Topic-based skills, implicit work detection
42
43**2. Stop Hook - Error Handling Reminder** (Gentle Reminders)
44- **File**: .claude/hooks/error-handling-reminder.ts
45- **Trigger**: AFTER Claude finishes responding
46- **Purpose**: Gentle reminder to self-assess error handling in code written
47- **Method**: Analyzes edited files for risky patterns, displays reminder if needed
48- **Use Cases**: Error handling awareness without blocking friction
49
50**Philosophy Change (2025-10-27):** We moved away from blocking PreToolUse for Sentry/error handling. Instead, use gentle post-response reminders that don't block workflow but maintain code quality awareness.
51
52### Configuration File
53
54**Location**: .claude/skills/skill-rules.json
55
56Defines:
57- All skills and their trigger conditions
58- Enforcement levels (block, suggest, warn)
59- File path patterns (glob)
60- Content detection patterns (regex)
61- Skip conditions (session tracking, file markers, env vars)
62
63---
64
65## Skill Types
66
67### 1. Guardrail Skills
68
69**Purpose:** Enforce critical best practices that prevent errors
70
71**Characteristics:**
72- Type: "guardrail"
73- Enforcement: "block"
74- Priority: "critical" or "high"
75- Block file edits until skill used
76- Prevent common mistakes (column names, critical errors)
77- Session-aware (don't repeat nag in same session)
78
79**Examples:**
80- database-verification - Verify table/column names before Prisma queries
81- frontend-dev-guidelines - Enforce React/TypeScript patterns
82
83**When to Use:**
84- Mistakes that cause runtime errors
85- Data integrity concerns
86- Critical compatibility issues
87
88### 2. Domain Skills
89
90**Purpose:** Provide comprehensive guidance for specific areas
91
92**Characteristics:**
93- Type: "domain"
94- Enforcement: "suggest"
95- Priority: "high" or "medium"
96- Advisory, not mandatory
97- Topic or domain-specific
98- Comprehensive documentation
99
100**Examples:**
101- backend-dev-guidelines - Node.js/Express/TypeScript patterns
102- frontend-dev-guidelines - React/TypeScript best practices
103- error-tracking - Sentry integration guidance
104
105**When to Use:**
106- Complex systems requiring deep knowledge
107- Best practices documentation
108- Architectural patterns
109- How-to guides
110
111---
112
113## Quick Start: Creating a New Skill
114
115### Step 1: Create Skill File
116
117**Location:** .claude/skills/{skill-name}/SKILL.md
118
119**Template:**
120```markdown
121---
122name: my-new-skill
123description: Brief description including keywords that trigger this skill. Mention topics, file types, and use cases. Be explicit about trigger terms.
124---
125
126# My New Skill
127
128## Purpose
129What this skill helps with
130
131## When to Use
132Specific scenarios and conditions
133
134## Key Information
135The actual guidance, documentation, patterns, examples
136```
137
138**Best Practices:**
139- ✅ **Name**: Lowercase, hyphens, gerund form (verb + -ing) preferred
140- ✅ **Description**: Include ALL trigger keywords/phrases (max 1024 chars)
141- ✅ **Content**: Under 500 lines - use reference files for details
142- ✅ **Examples**: Real code examples
143- ✅ **Structure**: Clear headings, lists, code blocks
144
145### Step 2: Add to skill-rules.json
146
147See [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md) for complete schema.
148
149**Basic Template:**
150```json
151{
152 "my-new-skill": {
153 "type": "domain",
154 "enforcement": "suggest",
155 "priority": "medium",
156 "promptTriggers": {
157 "keywords": ["keyword1", "keyword2"],
158 "intentPatterns": ["(create|add).*?something"]
159 }
160 }
161}
162```
163
164### Step 3: Test Triggers
165
166**Test UserPromptSubmit:**
167```bash
168echo '{"session_id":"test","prompt":"your test prompt"}' | \
169 npx tsx .claude/hooks/skill-activation-prompt.ts
170```
171
172**Test PreToolUse:**
173```bash
174cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
175{"session_id":"test","tool_name":"Edit","tool_input":{"file_path":"test.ts"}}
176EOF
177```
178
179### Step 4: Refine Patterns
180
181Based on testing:
182- Add missing keywords
183- Refine intent patterns to reduce false positives
184- Adjust file path patterns
185- Test content patterns against actual files
186
187### Step 5: Follow Anthropic Best Practices
188
189✅ Keep SKILL.md under 500 lines
190✅ Use progressive disclosure with reference files
191✅ Add table of contents to reference files > 100 lines
192✅ Write detailed description with trigger keywords
193✅ Test with 3+ real scenarios before documenting
194✅ Iterate based on actual usage
195
196---
197
198## Enforcement Levels
199
200### BLOCK (Critical Guardrails)
201
202- Physically prevents Edit/Write tool execution
203- Exit code 2 from hook, stderr → Claude
204- Claude sees message and must use skill to proceed
205- **Use For**: Critical mistakes, data integrity, security issues
206
207**Example:** Database column name verification
208
209### SUGGEST (Recommended)
210
211- Reminder injected before Claude sees prompt
212- Claude is aware of relevant skills
213- Not enforced, just advisory
214- **Use For**: Domain guidance, best practices, how-to guides
215
216**Example:** Frontend development guidelines
217
218### WARN (Optional)
219
220- Low priority suggestions
221- Advisory only, minimal enforcement
222- **Use For**: Nice-to-have suggestions, informational reminders
223
224**Rarely used** - most skills are either BLOCK or SUGGEST.
225
226---
227
228## Skip Conditions & User Control
229
230### 1. Session Tracking
231
232**Purpose:** Don't nag repeatedly in same session
233
234**How it works:**
235- First edit → Hook blocks, updates session state
236- Second edit (same session) → Hook allows
237- Different session → Blocks again
238
239**State File:** .claude/hooks/state/skills-used-{session_id}.json
240
241### 2. File Markers
242
243**Purpose:** Permanent skip for verified files
244
245**Marker:** // @skip-validation
246
247**Usage:**
248```typescript
249// @skip-validation
250import { PrismaService } from './prisma';
251// This file has been manually verified
252```
253
254**NOTE:** Use sparingly - defeats the purpose if overused
255
256### 3. Environment Variables
257
258**Purpose:** Emergency disable, temporary override
259
260**Global disable:**
261```bash
262export SKIP_SKILL_GUARDRAILS=true # Disables ALL PreToolUse blocks
263```
264
265**Skill-specific:**
266```bash
267export SKIP_DB_VERIFICATION=true
268export SKIP_ERROR_REMINDER=true
269```
270
271---
272
273## Testing Checklist
274
275When creating a new skill, verify:
276
277- [ ] Skill file created in .claude/skills/{name}/SKILL.md
278- [ ] Proper frontmatter with name and description
279- [ ] Entry added to skill-rules.json
280- [ ] Keywords tested with real prompts
281- [ ] Intent patterns tested with variations
282- [ ] File path patterns tested with actual files
283- [ ] Content patterns tested against file contents
284- [ ] Block message is clear and actionable (if guardrail)
285- [ ] Skip conditions configured appropriately
286- [ ] Priority level matches importance
287- [ ] No false positives in testing
288- [ ] No false negatives in testing
289- [ ] Performance is acceptable (<100ms or <200ms)
290- [ ] JSON syntax validated: jq . skill-rules.json
291- [ ] **SKILL.md under 500 lines** ⭐
292- [ ] Reference files created if needed
293- [ ] Table of contents added to files > 100 lines
294
295---
296
297## Reference Files
298
299For detailed information on specific topics, see:
300
301### [TRIGGER_TYPES.md](TRIGGER_TYPES.md)
302Complete guide to all trigger types:
303- Keyword triggers (explicit topic matching)
304- Intent patterns (implicit action detection)
305- File path triggers (glob patterns)
306- Content patterns (regex in files)
307- Best practices and examples for each
308- Common pitfalls and testing strategies
309
310### [SKILL_RULES_REFERENCE.md](SKILL_RULES_REFERENCE.md)
311Complete skill-rules.json schema:
312- Full TypeScript interface definitions
313- Field-by-field explanations
314- Complete guardrail skill example
315- Complete domain skill example
316- Validation guide and common errors
317
318### [HOOK_MECHANISMS.md](HOOK_MECHANISMS.md)
319Deep dive into hook internals:
320- UserPromptSubmit flow (detailed)
321- PreToolUse flow (detailed)
322- Exit code behavior table (CRITICAL)
323- Session state management
324- Performance considerations
325
326### [TROUBLESHOOTING.md](TROUBLESHOOTING.md)
327Comprehensive debugging guide:
328- Skill not triggering (UserPromptSubmit)
329- PreToolUse not blocking
330- False positives (too many triggers)
331- Hook not executing at all
332- Performance issues
333
334### [PATTERNS_LIBRARY.md](PATTERNS_LIBRARY.md)
335Ready-to-use pattern collection:
336- Intent pattern library (regex)
337- File path pattern library (glob)
338- Content pattern library (regex)
339- Organized by use case
340- Copy-paste ready
341
342### [ADVANCED.md](ADVANCED.md)
343Future enhancements and ideas:
344- Dynamic rule updates
345- Skill dependencies
346- Conditional enforcement
347- Skill analytics
348- Skill versioning
349
350---
351
352## Quick Reference Summary
353
354### Create New Skill (5 Steps)
355
3561. Create .claude/skills/{name}/SKILL.md with frontmatter
3572. Add entry to .claude/skills/skill-rules.json
3583. Test with npx tsx commands
3594. Refine patterns based on testing
3605. Keep SKILL.md under 500 lines
361
362### Trigger Types
363
364- **Keywords**: Explicit topic mentions
365- **Intent**: Implicit action detection
366- **File Paths**: Location-based activation
367- **Content**: Technology-specific detection
368
369See [TRIGGER_TYPES.md](TRIGGER_TYPES.md) for complete details.
370
371### Enforcement
372
373- **BLOCK**: Exit code 2, critical only
374- **SUGGEST**: Inject context, most common
375- **WARN**: Advisory, rarely used
376
377### Skip Conditions
378
379- **Session tracking**: Automatic (prevents repeated nags)
380- **File markers**: // @skip-validation (permanent skip)
381- **Env vars**: SKIP_SKILL_GUARDRAILS (emergency disable)
382
383### Anthropic Best Practices
384
385✅ **500-line rule**: Keep SKILL.md under 500 lines
386✅ **Progressive disclosure**: Use reference files for details
387✅ **Table of contents**: Add to reference files > 100 lines
388✅ **One level deep**: Don't nest references deeply
389✅ **Rich descriptions**: Include all trigger keywords (max 1024 chars)
390✅ **Test first**: Build 3+ evaluations before extensive documentation
391✅ **Gerund naming**: Prefer verb + -ing (e.g., "processing-pdfs")
392
393### Troubleshoot
394
395Test hooks manually:
396```bash
397# UserPromptSubmit
398echo '{"prompt":"test"}' | npx tsx .claude/hooks/skill-activation-prompt.ts
399
400# PreToolUse
401cat <<'EOF' | npx tsx .claude/hooks/skill-verification-guard.ts
402{"tool_name":"Edit","tool_input":{"file_path":"test.ts"}}
403EOF
404```
405
406See [TROUBLESHOOTING.md](TROUBLESHOOTING.md) for complete debugging guide.
407
408---
409
410## Related Files
411
412**Configuration:**
413- .claude/skills/skill-rules.json - Master configuration
414- .claude/hooks/state/ - Session tracking
415- .claude/settings.json - Hook registration
416
417**Hooks:**
418- .claude/hooks/skill-activation-prompt.ts - UserPromptSubmit
419- .claude/hooks/error-handling-reminder.ts - Stop event (gentle reminders)
420
421**All Skills:**
422- .claude/skills/*/SKILL.md - Skill content files
423
424---
425
426**Skill Status**: COMPLETE - Restructured following Anthropic best practices ✅
427**Line Count**: < 500 (following 500-line rule) ✅
428**Progressive Disclosure**: Reference files for detailed information ✅
429
430**Next**: Create more skills, refine patterns based on usage
431