claude-git-hooks 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,656 @@
1
+ # Preset Customization Guide
2
+
3
+ **Purpose**: Learn how to create custom presets or modify existing ones for your tech stack.
4
+
5
+ **Audience**: Developers customizing claude-hooks for specific technologies.
6
+
7
+ ---
8
+
9
+ ## ⚠️ Known Issue: Claude API Burst Limits
10
+
11
+ **Symptom**: Rate limit errors during git commits, even though manual `claude` CLI commands work fine.
12
+
13
+ **Why**: Git hooks fire multiple Claude API requests simultaneously (parallel execution), triggering burst limits:
14
+ - **Hourly limit**: ~100 requests/hour (manual CLI respects this)
15
+ - **Burst limit**: ~5 requests per 10 seconds (git hooks can exceed this)
16
+
17
+ **Example**:
18
+ ```bash
19
+ # Manual CLI (works fine - sequential with natural delays)
20
+ claude --prompt "test1" # Request 1
21
+ # ... 30 seconds later ...
22
+ claude --prompt "test2" # Request 2
23
+
24
+ # Git hooks (hits burst limit - simultaneous)
25
+ git commit -m "auto"
26
+ → Pre-commit: 2 parallel processes ⚡⚡ (instant)
27
+ → Prepare-commit-msg: 1 process ⚡ (3 seconds later)
28
+ → Total: 3 requests in 3 seconds = RATE_LIMIT
29
+ ```
30
+
31
+ **Solution**: Disable parallel execution in `.claude/config.json`:
32
+ ```json
33
+ {
34
+ "subagents": {
35
+ "enabled": false
36
+ }
37
+ }
38
+ ```
39
+
40
+ **Effect**: Requests become sequential → No burst limit issues (slower but reliable).
41
+
42
+ ---
43
+
44
+ ## Table of Contents
45
+
46
+ 1. [Understanding the Preset System](#understanding-the-preset-system)
47
+ 2. [How Analysis Prompts Are Built](#how-analysis-prompts-are-built)
48
+ 3. [Creating a New Preset](#creating-a-new-preset)
49
+ 4. [Modifying Existing Presets](#modifying-existing-presets)
50
+ 5. [Placeholder System](#placeholder-system)
51
+ 6. [Preset Kickstart Prompt](#preset-kickstart-prompt)
52
+
53
+ ---
54
+
55
+ ## Understanding the Preset System
56
+
57
+ ### What is a Preset?
58
+
59
+ A preset is a **self-contained package** that customizes claude-hooks for a specific technology stack. It includes:
60
+
61
+ - **Metadata** - Tech stack, file extensions, focus areas
62
+ - **Configuration** - Analysis settings, timeouts, parallel processing
63
+ - **Templates** - Custom prompts and guidelines for Claude
64
+
65
+ ### Directory Structure
66
+
67
+ ```
68
+ .claude/presets/{preset-name}/
69
+ ├── preset.json # Metadata (tech stack, file filters, focus areas)
70
+ ├── config.json # Configuration overrides (optional)
71
+ ├── ANALYSIS_PROMPT.md # Custom analysis prompt template
72
+ ├── PRE_COMMIT_GUIDELINES.md # Evaluation criteria for Claude
73
+ └── (other templates) # Can reference ../shared/ templates
74
+ ```
75
+
76
+ ### Preset Components
77
+
78
+ | File | Required | Purpose | Example |
79
+ | -------------------------- | -------- | -------------------------------------- | ---------------------------------------- |
80
+ | `preset.json` | **Yes** | Metadata, file extensions, focus areas | Tech stack list, `.java` files |
81
+ | `config.json` | No | Override analysis settings | Timeout, model selection |
82
+ | `ANALYSIS_PROMPT.md` | **Yes** | Main prompt template for Claude | "You are analyzing a backend project..." |
83
+ | `PRE_COMMIT_GUIDELINES.md` | **Yes** | Evaluation criteria | "Check for SQL injection..." |
84
+
85
+ **Shared templates**: Use `../shared/TEMPLATE_NAME.md` to reuse common templates (commit messages, PR analysis, etc.)
86
+
87
+ ---
88
+
89
+ ## How Analysis Prompts Are Built
90
+
91
+ ### Visual Flow
92
+
93
+ ```
94
+ ┌─────────────────────────────────────────────────────────────┐
95
+ │ 1. USER SELECTS PRESET │
96
+ │ claude-hooks --set-preset backend │
97
+ └────────────────────────┬────────────────────────────────────┘
98
+
99
+ ┌────────────────────────▼────────────────────────────────────┐
100
+ │ 2. PRESET LOADED FROM DISK │
101
+ │ .claude/presets/backend/ │
102
+ │ ├── preset.json → metadata │
103
+ │ ├── config.json → configuration │
104
+ │ └── ANALYSIS_PROMPT.md → template │
105
+ └────────────────────────┬────────────────────────────────────┘
106
+
107
+ ┌────────────────────────▼────────────────────────────────────┐
108
+ │ 3. CONFIGURATION MERGED │
109
+ │ defaults < user config < preset config │
110
+ │ - File extensions: ['.java', '.xml', '.yml'] │
111
+ │ - Max file size: 100KB │
112
+ │ - Parallel analysis: enabled │
113
+ └────────────────────────┬────────────────────────────────────┘
114
+
115
+ ┌────────────────────────▼────────────────────────────────────┐
116
+ │ 4. STAGED FILES FILTERED │
117
+ │ git diff --cached --name-only │
118
+ │ - Filter by preset.fileExtensions │
119
+ │ - Filter by config.analysis.maxFileSize │
120
+ │ - Limit to config.analysis.maxFiles │
121
+ │ Result: [UserController.java, UserService.java] │
122
+ └────────────────────────┬────────────────────────────────────┘
123
+
124
+ ┌────────────────────────▼────────────────────────────────────┐
125
+ │ 5. TEMPLATES LOADED & PLACEHOLDERS REPLACED │
126
+ │ Load: ANALYSIS_PROMPT.md │
127
+ │ Replace: │
128
+ │ {{PRESET_NAME}} → "backend" │
129
+ │ {{TECH_STACK}} → "Spring Boot, JPA, SQL Server" │
130
+ │ {{FILE_EXTENSIONS}} → ".java, .xml, .yml" │
131
+ │ {{FOCUS_AREAS}} → "REST APIs, JPA, Security..." │
132
+ └────────────────────────┬────────────────────────────────────┘
133
+
134
+ ┌────────────────────────▼────────────────────────────────────┐
135
+ │ 6. PROMPT CONSTRUCTED │
136
+ │ [ANALYSIS_PROMPT.md] │
137
+ │ + [PRE_COMMIT_GUIDELINES.md] │
138
+ │ + [SUBAGENT_INSTRUCTION.md] (if parallel enabled) │
139
+ │ + [File diffs section] │
140
+ │ Result: Complete prompt ready for Claude │
141
+ └────────────────────────┬────────────────────────────────────┘
142
+
143
+ ┌────────────────────────▼────────────────────────────────────┐
144
+ │ 7. SENT TO CLAUDE │
145
+ │ claude --prompt "..." --model sonnet │
146
+ │ - Single analysis (1-2 files) │
147
+ │ - OR parallel analysis (3+ files, batched) │
148
+ └────────────────────────┬────────────────────────────────────┘
149
+
150
+ ┌────────────────────────▼────────────────────────────────────┐
151
+ │ 8. RESPONSE PROCESSED │
152
+ │ - JSON format (SonarQube-style) │
153
+ │ - Quality gate: PASSED/FAILED │
154
+ │ - Issues by severity: blocker, critical, major, minor │
155
+ │ - Commit proceeds or blocked │
156
+ └─────────────────────────────────────────────────────────────┘
157
+ ```
158
+
159
+ ### Prompt Assembly Example
160
+
161
+ **Input files:**
162
+
163
+ - `ANALYSIS_PROMPT.md` (50 lines) - Tech-stack-specific context
164
+ - `PRE_COMMIT_GUIDELINES.md` (100 lines) - Evaluation criteria
165
+ - File diffs (variable) - Actual code changes
166
+
167
+ **Output prompt:**
168
+
169
+ ```markdown
170
+ You are analyzing a backend project...
171
+ Tech Stack: Spring Boot, JPA, SQL Server
172
+ Focus Areas: REST APIs, Security, Transaction management
173
+
174
+ === EVALUATION GUIDELINES ===
175
+
176
+ 1. Security First: Check for OWASP Top 10...
177
+ 2. Spring Boot Best Practices...
178
+
179
+ === CHANGES TO REVIEW ===
180
+ --- File: src/main/java/UserController.java ---
181
+ @@ -10,5 +10,8 @@
182
+ +public UserDTO getUser(@PathVariable Long id) {
183
+
184
+ - return userService.findById(id);
185
+ +}
186
+ ```
187
+
188
+ ---
189
+
190
+ ## Creating a New Preset
191
+
192
+ ### Step 1: Choose Preset Directory Name
193
+
194
+ Convention: `{tech-stack}` (lowercase, hyphenated)
195
+
196
+ Examples:
197
+
198
+ - `python-django`
199
+ - `go-microservices`
200
+ - `mobile-react-native`
201
+
202
+ ```bash
203
+ cd templates/presets
204
+ mkdir python-django
205
+ cd python-django
206
+ ```
207
+
208
+ ### Step 2: Create `preset.json`
209
+
210
+ **Purpose**: Metadata that defines what your preset analyzes and focuses on.
211
+
212
+ **Why each field matters**:
213
+
214
+ - `fileExtensions` → Filters which files are analyzed (performance + relevance)
215
+ - `focusAreas` → Directs Claude's attention to tech-stack-specific concerns
216
+ - `techStack` → Provides context to Claude about the project
217
+
218
+ **Template**:
219
+
220
+ ```json
221
+ {
222
+ "name": "python-django",
223
+ "displayName": "Python Django",
224
+ "description": "Python web applications with Django, PostgreSQL, Celery",
225
+ "version": "1.0.0",
226
+
227
+ "techStack": [
228
+ "Python 3.9+",
229
+ "Django 4.x",
230
+ "Django REST Framework",
231
+ "PostgreSQL",
232
+ "Celery",
233
+ "Redis",
234
+ "pytest"
235
+ ],
236
+
237
+ "fileExtensions": [".py", ".txt", ".yml", ".yaml"],
238
+
239
+ "focusAreas": [
240
+ "Django ORM query optimization (N+1 queries)",
241
+ "Security vulnerabilities (OWASP Top 10)",
242
+ "SQL injection prevention in raw queries",
243
+ "Proper use of Django middleware",
244
+ "Celery task design and error handling",
245
+ "API serializer validation",
246
+ "Test coverage and pytest best practices"
247
+ ],
248
+
249
+ "templates": {
250
+ "analysis": "ANALYSIS_PROMPT.md",
251
+ "guidelines": "PRE_COMMIT_GUIDELINES.md",
252
+ "commitMessage": "../shared/COMMIT_MESSAGE.md",
253
+ "analyzeDiff": "../shared/ANALYZE_DIFF.md",
254
+ "resolution": "../shared/RESOLUTION_PROMPT.md"
255
+ }
256
+ }
257
+ ```
258
+
259
+ **Field reference**:
260
+
261
+ - `name` - Internal identifier (must match directory name)
262
+ - `displayName` - Human-readable name shown in UI
263
+ - `description` - Brief tech stack summary
264
+ - `version` - Semantic version for tracking changes
265
+ - `techStack` - Array of technologies (injected as `{{TECH_STACK}}`)
266
+ - `fileExtensions` - Files to analyze (filters `git diff` output)
267
+ - `focusAreas` - Array of concerns (injected as `{{FOCUS_AREAS}}`)
268
+ - `templates` - Relative paths to template files
269
+
270
+ ### Step 3: Create `config.json` (Optional)
271
+
272
+ **Purpose**: Override default analysis settings for this tech stack.
273
+
274
+ **Why**: Different tech stacks have different needs:
275
+
276
+ - Django projects → Larger models, need more `maxFileSize`
277
+ - Microservices → Many small files, increase `maxFiles`
278
+ - Complex analysis → Increase `timeout`
279
+
280
+ **Template**:
281
+
282
+ ```json
283
+ {
284
+ "analysis": {
285
+ "maxFileSize": 150000,
286
+ "maxFiles": 12,
287
+ "timeout": 180000
288
+ },
289
+ "subagents": {
290
+ "enabled": true,
291
+ "model": "sonnet",
292
+ "batchSize": 3
293
+ }
294
+ }
295
+ ```
296
+
297
+ **When to override**:
298
+
299
+ - `maxFileSize` - Increase if files are typically large (models with many fields)
300
+ - `maxFiles` - Adjust based on typical commit size
301
+ - `timeout` - Increase for complex analysis (fullstack presets)
302
+ - `model` - Use `sonnet`/`opus` for critical stacks, `haiku` for speed
303
+
304
+ **Default values** (from `lib/config.js`):
305
+
306
+ ```javascript
307
+ {
308
+ analysis: {
309
+ maxFileSize: 100000, // 100KB
310
+ maxFiles: 10,
311
+ timeout: 120000 // 2 minutes
312
+ },
313
+ subagents: {
314
+ enabled: true,
315
+ model: 'haiku',
316
+ batchSize: 3
317
+ }
318
+ }
319
+ ```
320
+
321
+ ### Step 4: Create `ANALYSIS_PROMPT.md`
322
+
323
+ **Purpose**: Tech-stack-specific instructions that prepend the analysis.
324
+
325
+ **Why**: Gives Claude context about the project before showing code.
326
+
327
+ **Template**:
328
+
329
+ ```markdown
330
+ You are analyzing a **{{PRESET_NAME}}** project with the following technology stack:
331
+
332
+ **Tech Stack:** {{TECH_STACK}}
333
+
334
+ **Analyzing files matching:** {{FILE_EXTENSIONS}}
335
+
336
+ ## Your Task
337
+
338
+ Perform a comprehensive code quality analysis focusing on these areas:
339
+
340
+ {{FOCUS_AREAS}}
341
+
342
+ ## Analysis Guidelines
343
+
344
+ 1. **Security First**: Check for OWASP Top 10 vulnerabilities, especially:
345
+ - SQL injection in raw queries
346
+ - XSS in template rendering
347
+ - CSRF token validation
348
+ - Insecure authentication
349
+
350
+ 2. **Django Best Practices**:
351
+ - Proper use of Django ORM (avoid N+1 queries)
352
+ - Correct exception handling
353
+ - Appropriate use of serializers vs models
354
+ - Proper middleware usage
355
+
356
+ 3. **Performance**:
357
+ - Database query optimization
358
+ - select_related() and prefetch_related()
359
+ - Caching strategies
360
+ - Celery task efficiency
361
+
362
+ 4. **Code Quality**:
363
+ - PEP 8 compliance
364
+ - DRY violations
365
+ - Proper error handling
366
+ - Test coverage
367
+ ```
368
+
369
+ **Customization tips**:
370
+
371
+ - **Section 1**: Always start with security (highest priority)
372
+ - **Section 2**: Framework-specific patterns and anti-patterns
373
+ - **Section 3**: Performance concerns for this stack
374
+ - **Section 4**: General code quality (reusable across stacks)
375
+
376
+ ### Step 5: Create `PRE_COMMIT_GUIDELINES.md`
377
+
378
+ **Purpose**: Detailed evaluation criteria for Claude.
379
+
380
+ **Why**: Provides concrete examples of what to look for and how to report issues.
381
+
382
+ **Template**:
383
+
384
+ ````markdown
385
+ # SonarQube-Style Evaluation Criteria
386
+
387
+ ## Severity Levels
388
+
389
+ - **BLOCKER**: Security vulnerabilities, data loss risks
390
+ - **CRITICAL**: Major bugs, performance killers
391
+ - **MAJOR**: Code smells, maintainability issues
392
+ - **MINOR**: Style violations, minor improvements
393
+ - **INFO**: Suggestions and best practices
394
+
395
+ ## Django-Specific Rules
396
+
397
+ ### BLOCKER Issues
398
+
399
+ 1. **SQL Injection in Raw Queries**
400
+ - Pattern: `.raw()` or `.extra()` with string formatting
401
+ - Example: `User.objects.raw(f"SELECT * FROM users WHERE id = {user_id}")`
402
+ - Why blocker: Direct security vulnerability
403
+
404
+ 2. **Missing CSRF Protection**
405
+ - Pattern: `@csrf_exempt` without justification
406
+ - Why blocker: Opens XSS attack vectors
407
+
408
+ ### CRITICAL Issues
409
+
410
+ 1. **N+1 Query Problem**
411
+ - Pattern: Accessing related objects in a loop without `select_related()`
412
+ - Example:
413
+ ```python
414
+ users = User.objects.all()
415
+ for user in users:
416
+ print(user.profile.bio) # N+1 query
417
+ ```
418
+ - Why critical: Performance degradation at scale
419
+
420
+ 2. **Unhandled Exceptions in Views**
421
+ - Pattern: No try/except in view functions
422
+ - Why critical: Exposes stack traces to users
423
+
424
+ ### MAJOR Issues
425
+
426
+ 1. **Missing Migrations**
427
+ - Pattern: Model changes without corresponding migration files
428
+ - Why major: Deployment will fail
429
+
430
+ 2. **Hardcoded Secrets**
431
+ - Pattern: API keys, passwords in code
432
+ - Example: `API_KEY = "sk_live_..."`
433
+ - Why major: Security risk if committed
434
+
435
+ ## Output Format
436
+
437
+ Always return JSON in this exact structure:
438
+
439
+ ```json
440
+ {
441
+ "QUALITY_GATE": "PASSED or FAILED",
442
+ "metrics": {
443
+ "reliability": "A-E",
444
+ "security": "A-E",
445
+ "maintainability": "A-E"
446
+ },
447
+ "issuesSummary": {
448
+ "blocker": 0,
449
+ "critical": 0,
450
+ "major": 2,
451
+ "minor": 1,
452
+ "info": 3
453
+ },
454
+ "blockingIssues": []
455
+ }
456
+ ```
457
+ ````
458
+
459
+ ````
460
+
461
+ **Customization tips**:
462
+ - Start with your framework's most common security issues
463
+ - Include real code examples (helps Claude recognize patterns)
464
+ - Explain "why" for each severity level (helps calibration)
465
+ - Reference official documentation when possible
466
+
467
+ ### Step 6: Test Your Preset
468
+
469
+ ```bash
470
+ # 1. Install preset (from repo root)
471
+ cd ../../.. # Back to repo root
472
+ claude-hooks install --force
473
+
474
+ # 2. Select your new preset
475
+ claude-hooks --set-preset python-django
476
+
477
+ # 3. Test on a sample commit
478
+ git add .
479
+ git commit -m "test: verify preset works"
480
+
481
+ # 4. Review analysis output
482
+ # Look for:
483
+ # - Correct file filtering
484
+ # - Tech-stack-specific focus areas mentioned
485
+ # - Appropriate severity levels
486
+ ````
487
+
488
+ ---
489
+
490
+ ## Modifying Existing Presets
491
+
492
+ ### User-Level Customization
493
+
494
+ **Location**: `.claude/` (in your repository, not in `templates/presets/`)
495
+
496
+ **Why**: Project-specific overrides without modifying the preset itself.
497
+
498
+ **Steps**:
499
+
500
+ ```bash
501
+ # 1. Copy preset to your repo's .claude directory
502
+ cp templates/presets/backend/ANALYSIS_PROMPT.md .claude/
503
+
504
+ # 2. Edit .claude/ANALYSIS_PROMPT.md
505
+ vim .claude/ANALYSIS_PROMPT.md
506
+
507
+ # 3. Commit continues to work
508
+ git commit -m "test"
509
+ # Now uses YOUR custom prompt instead of preset's
510
+ ```
511
+
512
+ **Precedence**:
513
+
514
+ ```
515
+ .claude/ANALYSIS_PROMPT.md (highest priority)
516
+
517
+ templates/presets/backend/ANALYSIS_PROMPT.md
518
+
519
+ templates/shared/ANALYSIS_PROMPT.md (fallback)
520
+ ```
521
+
522
+ ---
523
+
524
+ ## Placeholder System
525
+
526
+ ### Available Placeholders
527
+
528
+ | Placeholder | Source | Example Value | When Replaced |
529
+ | --------------------- | ------------------------------------- | ------------------------------------- | -------------------------- |
530
+ | `{{PRESET_NAME}}` | `preset.json` → `name` | `"backend"` | Template load |
531
+ | `{{TECH_STACK}}` | `preset.json` → `techStack` | `"Spring Boot, JPA, SQL Server"` | Template load |
532
+ | `{{FILE_EXTENSIONS}}` | `preset.json` → `fileExtensions` | `".java, .xml, .yml"` | Template load |
533
+ | `{{FOCUS_AREAS}}` | `preset.json` → `focusAreas` | `"REST APIs, Security..."` (bulleted) | Template load |
534
+ | `{{REPO_NAME}}` | Git metadata | `"my-project"` | Prompt build |
535
+ | `{{BRANCH_NAME}}` | Git metadata | `"feature/new-endpoint"` | Prompt build |
536
+ | `{{BATCH_SIZE}}` | `config.json` → `subagents.batchSize` | `"3"` | Prompt build (if parallel) |
537
+ | `{{MODEL}}` | `config.json` → `subagents.model` | `"haiku"` | Prompt build (if parallel) |
538
+
539
+ ---
540
+
541
+ ## Preset Kickstart Prompt
542
+
543
+ Use this prompt with Claude (in the same directory) to generate a new preset:
544
+
545
+ ---
546
+
547
+ ### 🤖 PRESET GENERATION PROMPT
548
+
549
+ ```markdown
550
+ I need to create a new claude-hooks preset for the following technology stack:
551
+
552
+ **Tech Stack**: [e.g., Python Django, Go microservices, React Native]
553
+
554
+ **Primary Technologies**:
555
+
556
+ - [List 5-10 main technologies]
557
+ - [e.g., Django 4.x, PostgreSQL, Celery, Redis, pytest]
558
+
559
+ **File Extensions to Analyze**:
560
+
561
+ - [e.g., .py, .yml, .yaml, requirements.txt]
562
+
563
+ **Key Concerns for This Stack**:
564
+
565
+ - [e.g., Django ORM N+1 queries]
566
+ - [e.g., SQL injection in raw queries]
567
+ - [e.g., Celery task error handling]
568
+
569
+ **Common Vulnerabilities**:
570
+
571
+ - [e.g., XSS in Django templates]
572
+ - [e.g., CSRF protection]
573
+
574
+ **Performance Gotchas**:
575
+
576
+ - [e.g., Missing select_related(), database query count]
577
+
578
+ ---
579
+
580
+ Please generate the following files:
581
+
582
+ 1. **preset.json** - Include name, displayName, description, version, techStack, fileExtensions, focusAreas, and templates
583
+
584
+ 2. **config.json** - Suggest appropriate maxFileSize, maxFiles, timeout, and model based on typical file sizes and analysis complexity for this stack
585
+
586
+ 3. **ANALYSIS_PROMPT.md** - Create a tech-stack-specific analysis prompt that:
587
+ - Uses placeholders: {{PRESET_NAME}}, {{TECH_STACK}}, {{FILE_EXTENSIONS}}, {{FOCUS_AREAS}}
588
+ - Includes 4 sections: Security First, Framework Best Practices, Performance, Code Quality
589
+ - Provides concrete examples of what to look for
590
+
591
+ 4. **PRE_COMMIT_GUIDELINES.md** - Create detailed evaluation criteria with:
592
+ - Severity levels (BLOCKER, CRITICAL, MAJOR, MINOR, INFO)
593
+ - Tech-stack-specific rules with code examples
594
+ - "Why" explanations for each severity level
595
+ - JSON output format specification
596
+
597
+ **Context**:
598
+
599
+ - This preset will be installed at: `templates/presets/{preset-name}/`
600
+ - It should follow the same structure as existing presets in `templates/presets/backend/`
601
+ - Users will select it with: `claude-hooks --set-preset {preset-name}`
602
+ - The preset must output JSON in SonarQube format
603
+
604
+ **Format**: Return each file's content as a separate code block with clear file headers.
605
+ ```
606
+
607
+ ---
608
+
609
+ ### Usage Example
610
+
611
+ ```bash
612
+ # 1. Navigate to presets directory
613
+ cd templates/presets
614
+
615
+ # 2. Create new preset directory
616
+ mkdir python-django
617
+
618
+ # 3. Open Claude (in same directory context)
619
+ # 4. Paste the kickstart prompt above (filled with your tech stack)
620
+ # 5. Copy generated files into python-django/
621
+ # 6. Test and iterate
622
+
623
+ # 7. Install and test
624
+ cd ../../..
625
+ claude-hooks install --force
626
+ claude-hooks --set-preset python-django
627
+ ```
628
+
629
+ ---
630
+
631
+ ## Best Practices
632
+
633
+ ### ✅ Do
634
+
635
+ - **Include examples** - Real code snippets help Claude recognize patterns
636
+ - **Explain "why"** - Severity justifications improve analysis consistency
637
+ - **Reuse shared templates** - Use `../shared/` for common templates (commit messages, etc.)
638
+
639
+ ### ❌ Don't
640
+
641
+ - **Over-specify** - Too many rules overwhelm Claude and cause false positives
642
+ - **Skip security** - Always make security the #1 priority in guidelines
643
+ - **Forget fallbacks** - Provide generic rules for edge cases
644
+
645
+ ---
646
+
647
+ ## Additional Resources
648
+
649
+ - **Example presets**: `templates/presets/backend/`, `templates/presets/frontend/`
650
+ - **Utility functions**: `lib/utils/preset-loader.js` - See how templates are loaded
651
+ - **Configuration reference**: `lib/config.js` - Default values and merge logic
652
+ - **Prompt building**: `lib/utils/prompt-builder.js` - How prompts are assembled
653
+
654
+ ---
655
+
656
+ **Questions?** good luck