rebar-mcp 2.0.0
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.
- package/.claude/agents/template-writer.md +43 -0
- package/.claude/agents/test-runner.md +47 -0
- package/.claude/mcp.json +9 -0
- package/.claude/settings.json +29 -0
- package/.claude/skills/ /SKILL.md +21 -0
- package/.claude/skills/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/SKILL.md +21 -0
- package/.claude/skills/bmmibwetxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmibwjgvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmibwsesxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmibwxufxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmibx3r9xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmji0lrkxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmjiniphxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmjio86zxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmjiolfbxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmjit1lvxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bmmjita1qxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx/SKILL.md +21 -0
- package/.claude/skills/bnd-mmibweu3/SKILL.md +21 -0
- package/.claude/skills/bnd-mmibwjh4/SKILL.md +21 -0
- package/.claude/skills/bnd-mmibwsey/SKILL.md +21 -0
- package/.claude/skills/bnd-mmibwxup/SKILL.md +21 -0
- package/.claude/skills/bnd-mmibx3rg/SKILL.md +21 -0
- package/.claude/skills/bnd-mmji0lrp/SKILL.md +21 -0
- package/.claude/skills/bnd-mmjinipm/SKILL.md +21 -0
- package/.claude/skills/bnd-mmjio875/SKILL.md +21 -0
- package/.claude/skills/bnd-mmjiolfg/SKILL.md +21 -0
- package/.claude/skills/bnd-mmjit1m3/SKILL.md +21 -0
- package/.claude/skills/bnd-mmjita1x/SKILL.md +21 -0
- package/.claude/skills/coercion-test/SKILL.md +50 -0
- package/.claude/skills/large-skill/SKILL.md +21 -0
- package/.claude/skills/long-desc-skill/SKILL.md +21 -0
- package/.claude/skills/mcp-dev/SKILL.md +61 -0
- package/.claude/skills/nl-mmibweus/SKILL.md +25 -0
- package/.claude/skills/nl-mmibwjhf/SKILL.md +25 -0
- package/.claude/skills/nl-mmibwsf7/SKILL.md +25 -0
- package/.claude/skills/nl-mmibwxvq/SKILL.md +25 -0
- package/.claude/skills/nl-mmibx3rt/SKILL.md +25 -0
- package/.claude/skills/nl-mmji0lrz/SKILL.md +25 -0
- package/.claude/skills/nl-mmjinipx/SKILL.md +25 -0
- package/.claude/skills/nl-mmjio87f/SKILL.md +25 -0
- package/.claude/skills/nl-mmjiolfs/SKILL.md +25 -0
- package/.claude/skills/nl-mmjit1mc/SKILL.md +25 -0
- package/.claude/skills/nl-mmjita26/SKILL.md +25 -0
- package/.claude/skills/rapid-1/SKILL.md +21 -0
- package/.claude/skills/rapid-2/SKILL.md +21 -0
- package/.claude/skills/rapid-3/SKILL.md +21 -0
- package/.claude/skills/rapid-4/SKILL.md +21 -0
- package/.claude/skills/rapid-5/SKILL.md +21 -0
- package/.claude/skills/test/", /"malicious/": /"true/SKILL.md" +69 -0
- package/.claude/skills/test-emoji-/360/237/230/200-skill/SKILL.md +69 -0
- package/.claude/skills/test-skill/SKILL.md +69 -0
- package/.claude/skills/test; rm -rf /; skill/SKILL.md +69 -0
- package/.claude/skills/test<script>alert(1)</script>skill/SKILL.md +69 -0
- package/.claudeignore +5 -0
- package/.mcp.json +3 -0
- package/CHANGELOG.md +29 -0
- package/CLAUDE.md +76 -0
- package/LICENSE +21 -0
- package/README.md +149 -0
- package/ROADMAP.md +526 -0
- package/ccboot-PRD-v1.0.docx.md +732 -0
- package/ccboot-v1.2.0-enforcement-spec.md +1272 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +674 -0
- package/dist/cli.js.map +1 -0
- package/dist/constants.d.ts +25 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +118 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/common.d.ts +62 -0
- package/dist/schemas/common.d.ts.map +1 -0
- package/dist/schemas/common.js +15 -0
- package/dist/schemas/common.js.map +1 -0
- package/dist/schemas/scaffolding.d.ts +277 -0
- package/dist/schemas/scaffolding.d.ts.map +1 -0
- package/dist/schemas/scaffolding.js +133 -0
- package/dist/schemas/scaffolding.js.map +1 -0
- package/dist/services/claudemd-generator.d.ts +16 -0
- package/dist/services/claudemd-generator.d.ts.map +1 -0
- package/dist/services/claudemd-generator.js +426 -0
- package/dist/services/claudemd-generator.js.map +1 -0
- package/dist/services/codex-generator.d.ts +6 -0
- package/dist/services/codex-generator.d.ts.map +1 -0
- package/dist/services/codex-generator.js +35 -0
- package/dist/services/codex-generator.js.map +1 -0
- package/dist/services/cursor-generator.d.ts +15 -0
- package/dist/services/cursor-generator.d.ts.map +1 -0
- package/dist/services/cursor-generator.js +134 -0
- package/dist/services/cursor-generator.js.map +1 -0
- package/dist/services/file-ops.d.ts +48 -0
- package/dist/services/file-ops.d.ts.map +1 -0
- package/dist/services/file-ops.js +153 -0
- package/dist/services/file-ops.js.map +1 -0
- package/dist/services/output-formatter.d.ts +57 -0
- package/dist/services/output-formatter.d.ts.map +1 -0
- package/dist/services/output-formatter.js +88 -0
- package/dist/services/output-formatter.js.map +1 -0
- package/dist/services/platform-detect.d.ts +14 -0
- package/dist/services/platform-detect.d.ts.map +1 -0
- package/dist/services/platform-detect.js +63 -0
- package/dist/services/platform-detect.js.map +1 -0
- package/dist/services/project-analyzer.d.ts +71 -0
- package/dist/services/project-analyzer.d.ts.map +1 -0
- package/dist/services/project-analyzer.js +595 -0
- package/dist/services/project-analyzer.js.map +1 -0
- package/dist/services/rules-engine.d.ts +41 -0
- package/dist/services/rules-engine.d.ts.map +1 -0
- package/dist/services/rules-engine.js +304 -0
- package/dist/services/rules-engine.js.map +1 -0
- package/dist/services/strictness.d.ts +37 -0
- package/dist/services/strictness.d.ts.map +1 -0
- package/dist/services/strictness.js +182 -0
- package/dist/services/strictness.js.map +1 -0
- package/dist/services/template-engine.d.ts +16 -0
- package/dist/services/template-engine.d.ts.map +1 -0
- package/dist/services/template-engine.js +85 -0
- package/dist/services/template-engine.js.map +1 -0
- package/dist/services/validation.d.ts +41 -0
- package/dist/services/validation.d.ts.map +1 -0
- package/dist/services/validation.js +104 -0
- package/dist/services/validation.js.map +1 -0
- package/dist/services/windsurf-generator.d.ts +15 -0
- package/dist/services/windsurf-generator.d.ts.map +1 -0
- package/dist/services/windsurf-generator.js +127 -0
- package/dist/services/windsurf-generator.js.map +1 -0
- package/dist/tests/enforcement.test.d.ts +2 -0
- package/dist/tests/enforcement.test.d.ts.map +1 -0
- package/dist/tests/enforcement.test.js +541 -0
- package/dist/tests/enforcement.test.js.map +1 -0
- package/dist/tests/enterprise.test.d.ts +2 -0
- package/dist/tests/enterprise.test.d.ts.map +1 -0
- package/dist/tests/enterprise.test.js +353 -0
- package/dist/tests/enterprise.test.js.map +1 -0
- package/dist/tests/fuzzing.test.d.ts +2 -0
- package/dist/tests/fuzzing.test.d.ts.map +1 -0
- package/dist/tests/fuzzing.test.js +596 -0
- package/dist/tests/fuzzing.test.js.map +1 -0
- package/dist/tests/knowledge.test.d.ts +2 -0
- package/dist/tests/knowledge.test.d.ts.map +1 -0
- package/dist/tests/knowledge.test.js +292 -0
- package/dist/tests/knowledge.test.js.map +1 -0
- package/dist/tests/management.test.d.ts +2 -0
- package/dist/tests/management.test.d.ts.map +1 -0
- package/dist/tests/management.test.js +338 -0
- package/dist/tests/management.test.js.map +1 -0
- package/dist/tests/scaffolding.test.d.ts +2 -0
- package/dist/tests/scaffolding.test.d.ts.map +1 -0
- package/dist/tests/scaffolding.test.js +419 -0
- package/dist/tests/scaffolding.test.js.map +1 -0
- package/dist/tests/test-utils.d.ts +76 -0
- package/dist/tests/test-utils.d.ts.map +1 -0
- package/dist/tests/test-utils.js +171 -0
- package/dist/tests/test-utils.js.map +1 -0
- package/dist/tests/tool-harness.d.ts +18 -0
- package/dist/tests/tool-harness.d.ts.map +1 -0
- package/dist/tests/tool-harness.js +51 -0
- package/dist/tests/tool-harness.js.map +1 -0
- package/dist/tools/enterprise.d.ts +8 -0
- package/dist/tools/enterprise.d.ts.map +1 -0
- package/dist/tools/enterprise.js +571 -0
- package/dist/tools/enterprise.js.map +1 -0
- package/dist/tools/knowledge.d.ts +7 -0
- package/dist/tools/knowledge.d.ts.map +1 -0
- package/dist/tools/knowledge.js +120 -0
- package/dist/tools/knowledge.js.map +1 -0
- package/dist/tools/management.d.ts +10 -0
- package/dist/tools/management.d.ts.map +1 -0
- package/dist/tools/management.js +1541 -0
- package/dist/tools/management.js.map +1 -0
- package/dist/tools/scaffolding.d.ts +8 -0
- package/dist/tools/scaffolding.d.ts.map +1 -0
- package/dist/tools/scaffolding.js +736 -0
- package/dist/tools/scaffolding.js.map +1 -0
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/landing/app/layout.tsx +30 -0
- package/landing/app/page.tsx +944 -0
- package/landing/next-env.d.ts +6 -0
- package/landing/next.config.js +6 -0
- package/landing/package-lock.json +896 -0
- package/landing/package.json +20 -0
- package/landing/tsconfig.json +40 -0
- package/package.json +49 -0
- package/rebar-v2.0.0-platform-spec.md +1567 -0
- package/server.json +20 -0
- package/src/cli.ts +735 -0
- package/src/constants.ts +131 -0
- package/src/index.ts +54 -0
- package/src/schemas/common.ts +22 -0
- package/src/schemas/scaffolding.ts +161 -0
- package/src/services/claudemd-generator.ts +481 -0
- package/src/services/codex-generator.ts +44 -0
- package/src/services/cursor-generator.ts +153 -0
- package/src/services/file-ops.ts +172 -0
- package/src/services/platform-detect.ts +80 -0
- package/src/services/project-analyzer.ts +690 -0
- package/src/services/rules-engine.ts +353 -0
- package/src/services/strictness.ts +202 -0
- package/src/services/template-engine.ts +119 -0
- package/src/services/validation.ts +138 -0
- package/src/services/windsurf-generator.ts +145 -0
- package/src/tests/enforcement.test.ts +794 -0
- package/src/tests/enterprise.test.ts +483 -0
- package/src/tests/fuzzing.test.ts +690 -0
- package/src/tests/knowledge.test.ts +371 -0
- package/src/tests/management.test.ts +451 -0
- package/src/tests/scaffolding.test.ts +575 -0
- package/src/tests/test-utils.ts +206 -0
- package/src/tests/tool-harness.ts +70 -0
- package/src/tools/enterprise.ts +666 -0
- package/src/tools/knowledge.ts +162 -0
- package/src/tools/management.ts +1706 -0
- package/src/tools/scaffolding.ts +909 -0
- package/src/types.ts +93 -0
- package/supabase/.temp/cli-latest +1 -0
- package/supabase/.temp/gotrue-version +1 -0
- package/supabase/.temp/pooler-url +1 -0
- package/supabase/.temp/postgres-version +1 -0
- package/supabase/.temp/project-ref +1 -0
- package/supabase/.temp/rest-version +1 -0
- package/supabase/.temp/storage-migration +1 -0
- package/supabase/.temp/storage-version +1 -0
- package/templates/agents/explore.md +41 -0
- package/templates/agents/plan.md +73 -0
- package/templates/agents/security-auditor.md +77 -0
- package/templates/agents/test-runner.md +60 -0
- package/templates/claudemd/fastapi.md +49 -0
- package/templates/claudemd/monorepo.md +48 -0
- package/templates/claudemd/nextjs.md +52 -0
- package/templates/claudemd/react-spa.md +50 -0
- package/templates/claudemd/springboot.md +50 -0
- package/templates/hooks/danger-blocker.json +11 -0
- package/templates/hooks/format-on-write.json +17 -0
- package/templates/hooks/lint-on-write.json +16 -0
- package/templates/hooks/secret-detector.json +11 -0
- package/templates/skills/code-review.md +68 -0
- package/templates/skills/documentation.md +62 -0
- package/templates/skills/performance-audit.md +80 -0
- package/templates/skills/security-scan.md +66 -0
- package/templates/skills/test-writer.md +56 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,1272 @@
|
|
|
1
|
+
# ccboot-mcp-server v1.2.0 — The Enforcement Layer
|
|
2
|
+
|
|
3
|
+
## STATUS: IMPLEMENTATION SPEC — NOT A DISCUSSION DOCUMENT
|
|
4
|
+
|
|
5
|
+
Every section in this document is a directive. Do not paraphrase. Do not summarize.
|
|
6
|
+
Do not replace specific text with "appropriate content" or "relevant rules."
|
|
7
|
+
When this spec says "the template MUST contain the following text," copy it verbatim.
|
|
8
|
+
When this spec says "the hook command MUST be," use that exact command string.
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## What v1.2.0 Is
|
|
13
|
+
|
|
14
|
+
v1.0 built the MCP server infrastructure (15 tools, npm publish, MCP registry).
|
|
15
|
+
v1.1 added output modes, dry-run, CI mode, and testing.
|
|
16
|
+
v1.2 turns the product from a scaffolding tool into an enforcement system.
|
|
17
|
+
|
|
18
|
+
The difference: v1.0 generates files. v1.2 generates files that **prevent Claude from shipping broken code.**
|
|
19
|
+
|
|
20
|
+
After v1.2, when a developer runs `ccboot_init_project`, they get a project where:
|
|
21
|
+
- Claude cannot mark a task complete without tests passing
|
|
22
|
+
- Claude cannot commit code with empty catch blocks or `any` types
|
|
23
|
+
- Claude cannot skip error handling
|
|
24
|
+
- Claude gets blocked by hooks if it tries dangerous operations
|
|
25
|
+
- Claude gets audited by a code quality scanner that catches shortcuts
|
|
26
|
+
- Every generated template contains battle-tested, specific instructions — not placeholders
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## IMPLEMENTATION ORDER
|
|
31
|
+
|
|
32
|
+
Complete these in exact sequence. Do not skip ahead.
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Phase A: Rewrite all CLAUDE.md templates (Section 1)
|
|
36
|
+
Phase B: Rewrite all skill templates (Section 2)
|
|
37
|
+
Phase C: Rewrite all agent templates (Section 3)
|
|
38
|
+
Phase D: Rewrite all hook templates (Section 4)
|
|
39
|
+
Phase E: Build ccboot_audit_code_quality tool (Section 5)
|
|
40
|
+
Phase F: Enhance ccboot_init_project to wire everything together (Section 6)
|
|
41
|
+
Phase G: Update tests for all changes (Section 7)
|
|
42
|
+
Phase H: Update README and publish v1.2.0 (Section 8)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
After each phase, run `npm run build` and `npm run test`. Fix all errors before proceeding.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
# SECTION 1: CLAUDE.md TEMPLATES
|
|
50
|
+
|
|
51
|
+
## 1.1 Template Location
|
|
52
|
+
|
|
53
|
+
All CLAUDE.md templates live in `templates/claudemd/`. Each template is a standalone markdown file with `{{variable}}` substitution markers.
|
|
54
|
+
|
|
55
|
+
## 1.2 Template Variables
|
|
56
|
+
|
|
57
|
+
Every CLAUDE.md template MUST support these variables:
|
|
58
|
+
|
|
59
|
+
| Variable | Type | Description |
|
|
60
|
+
|---|---|---|
|
|
61
|
+
| `{{project_name}}` | string | Name of the project |
|
|
62
|
+
| `{{tech_stack}}` | string | Primary framework/language |
|
|
63
|
+
| `{{test_command}}` | string | Command to run tests (e.g., `npm test`) |
|
|
64
|
+
| `{{build_command}}` | string | Command to build (e.g., `npm run build`) |
|
|
65
|
+
| `{{lint_command}}` | string | Command to lint (e.g., `npm run lint`) |
|
|
66
|
+
| `{{format_command}}` | string | Command to format (e.g., `npx prettier --write`) |
|
|
67
|
+
| `{{primary_language}}` | string | e.g., TypeScript, Python, Java |
|
|
68
|
+
| `{{package_manager}}` | string | e.g., npm, yarn, pnpm, pip, maven |
|
|
69
|
+
| `{{team_size}}` | string | e.g., "solo", "small (2-5)", "medium (6-20)", "large (20+)" |
|
|
70
|
+
|
|
71
|
+
## 1.3 Mandatory Sections
|
|
72
|
+
|
|
73
|
+
EVERY CLAUDE.md template, regardless of tech stack, MUST contain ALL of the following sections in this exact order. These are non-negotiable. Do not omit any section. Do not reword the rules — use the exact text provided.
|
|
74
|
+
|
|
75
|
+
### Section: Project Overview
|
|
76
|
+
|
|
77
|
+
```markdown
|
|
78
|
+
# {{project_name}}
|
|
79
|
+
|
|
80
|
+
## Project Overview
|
|
81
|
+
{{project_description}}
|
|
82
|
+
|
|
83
|
+
### Tech Stack
|
|
84
|
+
{{tech_stack_details}}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
This section is customized per template. The content varies by tech stack.
|
|
88
|
+
|
|
89
|
+
### Section: Mandatory Practices
|
|
90
|
+
|
|
91
|
+
This section is IDENTICAL across all templates. Do not modify it per tech stack. Copy verbatim.
|
|
92
|
+
|
|
93
|
+
```markdown
|
|
94
|
+
## Mandatory Practices — NEVER VIOLATE THESE
|
|
95
|
+
|
|
96
|
+
### Completion Standards
|
|
97
|
+
- NEVER mark a task as complete without running `{{test_command}}` and confirming all tests pass
|
|
98
|
+
- NEVER say "I've completed the implementation" unless you have ACTUALLY run the tests and seen them pass in the terminal output
|
|
99
|
+
- NEVER skip writing tests for new functionality — every new function, endpoint, or component gets at least one test
|
|
100
|
+
- NEVER leave TODO, FIXME, HACK, or XXX comments in code you claim is finished
|
|
101
|
+
- If tests do not exist yet for the area you are modifying, WRITE THEM FIRST before making changes (test-driven development)
|
|
102
|
+
- After making changes, ALWAYS run `{{build_command}}` to verify the project compiles/builds without errors
|
|
103
|
+
|
|
104
|
+
### Error Handling
|
|
105
|
+
- NEVER write empty catch blocks — every catch block must either: (a) log the error with context, (b) re-throw with additional information, or (c) handle the error with specific recovery logic
|
|
106
|
+
- NEVER swallow errors silently — if you catch an exception, the catch block must DO something meaningful
|
|
107
|
+
- ALWAYS validate user input at system boundaries (API endpoints, form handlers, CLI arguments, file readers)
|
|
108
|
+
- ALWAYS handle the unhappy path — for every operation that can fail, write code that handles the failure case
|
|
109
|
+
- NEVER use generic error messages like "Something went wrong" — error messages must describe what failed, why, and what the user/developer can do about it
|
|
110
|
+
|
|
111
|
+
### Type Safety
|
|
112
|
+
- NEVER use `any` type — use `unknown`, proper generic types, or specific interfaces instead
|
|
113
|
+
- ALWAYS define explicit return types on functions (no implicit return type inference for exported functions)
|
|
114
|
+
- ALWAYS define interfaces or types for data structures that cross module boundaries (API responses, database records, configuration objects)
|
|
115
|
+
- NEVER use type assertions (`as SomeType`) unless you include a runtime check immediately before the assertion
|
|
116
|
+
|
|
117
|
+
### Code Completeness
|
|
118
|
+
- NEVER implement a partial solution — if a function needs error handling, input validation, logging, and the core logic, implement ALL of them, not just the core logic
|
|
119
|
+
- NEVER create a file and say "I'll add the implementation later" — if you create a file, it must be complete and functional
|
|
120
|
+
- NEVER stub out functions with `throw new Error("Not implemented")` in code you claim is finished
|
|
121
|
+
- ALWAYS implement edge cases — empty arrays, null values, missing fields, network timeouts, concurrent access
|
|
122
|
+
- ALWAYS clean up resources — close file handles, database connections, event listeners, and timers
|
|
123
|
+
|
|
124
|
+
### Security
|
|
125
|
+
- NEVER hardcode secrets, API keys, passwords, or tokens in source code
|
|
126
|
+
- NEVER log sensitive data (passwords, tokens, PII, credit card numbers)
|
|
127
|
+
- NEVER construct SQL queries with string concatenation — use parameterized queries or an ORM
|
|
128
|
+
- NEVER trust user input — sanitize and validate everything from external sources
|
|
129
|
+
- ALWAYS use HTTPS for external API calls
|
|
130
|
+
- NEVER disable TLS certificate verification
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Section: Architecture Rules
|
|
134
|
+
|
|
135
|
+
This section is customized per template. See individual template specs below.
|
|
136
|
+
|
|
137
|
+
### Section: File Structure
|
|
138
|
+
|
|
139
|
+
This section is customized per template. Describes the project layout.
|
|
140
|
+
|
|
141
|
+
### Section: Build and Test Commands
|
|
142
|
+
|
|
143
|
+
```markdown
|
|
144
|
+
## Build & Test Commands
|
|
145
|
+
- Build: `{{build_command}}`
|
|
146
|
+
- Test: `{{test_command}}`
|
|
147
|
+
- Lint: `{{lint_command}}`
|
|
148
|
+
- Format: `{{format_command}}`
|
|
149
|
+
|
|
150
|
+
### Testing Requirements
|
|
151
|
+
- Run `{{test_command}}` after EVERY code change, not just at the end
|
|
152
|
+
- If any test fails, fix it BEFORE moving on to the next task
|
|
153
|
+
- New features require tests BEFORE implementation (write the test, see it fail, then implement)
|
|
154
|
+
- Bug fixes require a regression test that reproduces the bug BEFORE fixing it
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Section: Code Review Checklist
|
|
158
|
+
|
|
159
|
+
This section is IDENTICAL across all templates. Copy verbatim.
|
|
160
|
+
|
|
161
|
+
```markdown
|
|
162
|
+
## Self-Review Checklist — Run Before Every Commit
|
|
163
|
+
|
|
164
|
+
Before committing any code, verify ALL of the following:
|
|
165
|
+
|
|
166
|
+
1. [ ] `{{build_command}}` passes with zero errors
|
|
167
|
+
2. [ ] `{{test_command}}` passes with all tests green
|
|
168
|
+
3. [ ] `{{lint_command}}` passes with zero warnings
|
|
169
|
+
4. [ ] No `any` types in changed files
|
|
170
|
+
5. [ ] No empty catch blocks in changed files
|
|
171
|
+
6. [ ] No TODO/FIXME/HACK comments in changed files
|
|
172
|
+
7. [ ] All new functions have explicit return types
|
|
173
|
+
8. [ ] All new functions have at least one test
|
|
174
|
+
9. [ ] All error paths are handled (not just the happy path)
|
|
175
|
+
10. [ ] No hardcoded secrets or credentials
|
|
176
|
+
11. [ ] No `console.log` left in production code (use proper logging)
|
|
177
|
+
12. [ ] Changed files are under 400 lines (split if longer)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## 1.4 Tech-Stack-Specific Templates
|
|
181
|
+
|
|
182
|
+
### Template: `templates/claudemd/nextjs.md`
|
|
183
|
+
|
|
184
|
+
In addition to ALL mandatory sections above, this template MUST include:
|
|
185
|
+
|
|
186
|
+
```markdown
|
|
187
|
+
## Architecture Rules — Next.js
|
|
188
|
+
|
|
189
|
+
### Routing
|
|
190
|
+
- Use the App Router (app/ directory), NOT the Pages Router, unless the project explicitly uses Pages Router
|
|
191
|
+
- Every route MUST have a loading.tsx and error.tsx boundary
|
|
192
|
+
- API routes go in app/api/ and MUST validate request bodies with Zod or a similar schema validator
|
|
193
|
+
- Dynamic routes MUST handle the case where the parameter does not match any record (return 404, not a crash)
|
|
194
|
+
|
|
195
|
+
### Data Fetching
|
|
196
|
+
- Use Server Components by default — only add "use client" when the component genuinely needs browser APIs or interactivity
|
|
197
|
+
- NEVER fetch data in client components if it can be done in a server component
|
|
198
|
+
- ALWAYS handle loading and error states — no component should render without a loading fallback and error boundary
|
|
199
|
+
- Cache API responses appropriately — use `revalidate` or `cache: 'no-store'` explicitly, never rely on defaults
|
|
200
|
+
|
|
201
|
+
### Styling
|
|
202
|
+
- Use Tailwind CSS utility classes for styling
|
|
203
|
+
- NEVER use inline `style={}` objects when Tailwind classes exist for the same purpose
|
|
204
|
+
- Component files should not exceed 200 lines — extract sub-components if they do
|
|
205
|
+
|
|
206
|
+
### Database
|
|
207
|
+
- Use Prisma for database access (if applicable)
|
|
208
|
+
- NEVER write raw SQL queries — use Prisma's query builder
|
|
209
|
+
- ALWAYS use transactions for operations that modify multiple tables
|
|
210
|
+
- ALWAYS handle unique constraint violations and foreign key errors explicitly
|
|
211
|
+
|
|
212
|
+
### State Management
|
|
213
|
+
- Use React Server Components + Server Actions for server state
|
|
214
|
+
- Use React hooks (useState, useReducer) for local UI state
|
|
215
|
+
- Only reach for external state libraries (Zustand, Jotai) if you genuinely need cross-component client state that React context cannot handle efficiently
|
|
216
|
+
|
|
217
|
+
### Environment Variables
|
|
218
|
+
- Access environment variables ONLY through a validated config module, never directly via process.env scattered throughout the code
|
|
219
|
+
- ALWAYS provide fallback values or throw clear errors for missing required environment variables
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### Template: `templates/claudemd/python-fastapi.md`
|
|
223
|
+
|
|
224
|
+
In addition to ALL mandatory sections above (with these substitutions: `{{test_command}}` = `pytest`, `{{build_command}}` = `python -m py_compile`, `{{lint_command}}` = `ruff check .`, `{{format_command}}` = `ruff format .`):
|
|
225
|
+
|
|
226
|
+
```markdown
|
|
227
|
+
## Architecture Rules — Python / FastAPI
|
|
228
|
+
|
|
229
|
+
### Type Hints
|
|
230
|
+
- EVERY function MUST have type hints for all parameters and return values
|
|
231
|
+
- Use `from __future__ import annotations` at the top of every file
|
|
232
|
+
- Use Pydantic BaseModel for ALL request/response schemas — never use raw dicts for API data
|
|
233
|
+
- NEVER use `Any` from typing — use `object`, specific unions, or generic type variables instead
|
|
234
|
+
|
|
235
|
+
### API Design
|
|
236
|
+
- Every endpoint MUST have a Pydantic request model (for POST/PUT/PATCH) and response model
|
|
237
|
+
- Every endpoint MUST have explicit status codes: 200, 201, 400, 401, 403, 404, 422, 500
|
|
238
|
+
- NEVER return raw dicts from endpoints — always return Pydantic models
|
|
239
|
+
- Use dependency injection for database sessions, auth, and config — never import globals directly
|
|
240
|
+
- ALWAYS include OpenAPI summary and description on every endpoint
|
|
241
|
+
|
|
242
|
+
### Error Handling
|
|
243
|
+
- Use FastAPI's HTTPException with specific status codes and detail messages
|
|
244
|
+
- Create custom exception handlers for domain-specific errors
|
|
245
|
+
- NEVER let unhandled exceptions reach the client — always have a global exception handler
|
|
246
|
+
- Log all exceptions with traceback using structured logging (not print())
|
|
247
|
+
|
|
248
|
+
### Database
|
|
249
|
+
- Use SQLAlchemy 2.0 style with async sessions
|
|
250
|
+
- ALWAYS use Alembic for migrations — never modify the database schema manually
|
|
251
|
+
- ALWAYS use transactions — wrap multi-step database operations in `async with session.begin()`
|
|
252
|
+
- NEVER write raw SQL strings — use SQLAlchemy's expression language or ORM
|
|
253
|
+
|
|
254
|
+
### Testing
|
|
255
|
+
- Use pytest with pytest-asyncio for async tests
|
|
256
|
+
- Use httpx.AsyncClient for API endpoint tests (not the synchronous test client)
|
|
257
|
+
- Every endpoint needs at least: one happy-path test, one validation-error test, one auth-failure test
|
|
258
|
+
- Use factories (factory_boy) or fixtures for test data — never hardcode test data inline
|
|
259
|
+
|
|
260
|
+
### Project Structure
|
|
261
|
+
- app/main.py — FastAPI app initialization
|
|
262
|
+
- app/api/ — Route handlers grouped by domain
|
|
263
|
+
- app/models/ — SQLAlchemy models
|
|
264
|
+
- app/schemas/ — Pydantic request/response models
|
|
265
|
+
- app/services/ — Business logic (not in route handlers)
|
|
266
|
+
- app/core/ — Config, security, dependencies
|
|
267
|
+
- tests/ — Mirrors app/ structure
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Template: `templates/claudemd/spring-boot.md`
|
|
271
|
+
|
|
272
|
+
In addition to ALL mandatory sections above (with: `{{test_command}}` = `./mvnw test`, `{{build_command}}` = `./mvnw compile`, `{{lint_command}}` = `./mvnw checkstyle:check`, `{{format_command}}` = `./mvnw spotless:apply`):
|
|
273
|
+
|
|
274
|
+
```markdown
|
|
275
|
+
## Architecture Rules — Spring Boot / Java
|
|
276
|
+
|
|
277
|
+
### Layered Architecture
|
|
278
|
+
- Controller → Service → Repository — NEVER skip layers
|
|
279
|
+
- Controllers handle HTTP concerns ONLY (request parsing, response formatting, status codes)
|
|
280
|
+
- Services contain ALL business logic — controllers MUST NOT contain business logic
|
|
281
|
+
- Repositories handle data access ONLY — no business logic in repository classes
|
|
282
|
+
- NEVER inject a Repository directly into a Controller — always go through a Service
|
|
283
|
+
|
|
284
|
+
### Exception Handling
|
|
285
|
+
- Create a global @ControllerAdvice exception handler
|
|
286
|
+
- Define custom exception classes for each error category (NotFoundException, ValidationException, ConflictException)
|
|
287
|
+
- NEVER catch Exception broadly — catch specific exception types
|
|
288
|
+
- NEVER return stack traces to API clients — log them server-side and return safe error responses
|
|
289
|
+
- Every REST endpoint MUST document possible error responses in Swagger annotations
|
|
290
|
+
|
|
291
|
+
### Validation
|
|
292
|
+
- Use Jakarta Bean Validation annotations (@NotNull, @Size, @Email, @Pattern) on all DTOs
|
|
293
|
+
- ALWAYS use @Valid on controller method parameters
|
|
294
|
+
- Create custom validators for complex business rules
|
|
295
|
+
- NEVER validate by writing if-else chains in controllers — use the validation framework
|
|
296
|
+
|
|
297
|
+
### Database
|
|
298
|
+
- Use Spring Data JPA repositories
|
|
299
|
+
- ALWAYS define entity relationships with proper cascade types and fetch strategies
|
|
300
|
+
- Use @Transactional on service methods that perform multiple database operations
|
|
301
|
+
- NEVER use EntityManager directly unless JPA repository methods are genuinely insufficient
|
|
302
|
+
- Write database migrations with Flyway or Liquibase — never use hibernate.ddl-auto in production
|
|
303
|
+
|
|
304
|
+
### Testing
|
|
305
|
+
- Unit tests: Test services with mocked repositories using @MockBean or Mockito
|
|
306
|
+
- Integration tests: Test controllers with @SpringBootTest and MockMvc
|
|
307
|
+
- Repository tests: Use @DataJpaTest with an in-memory database
|
|
308
|
+
- Every service method needs: one happy-path test, one exception test, one edge-case test
|
|
309
|
+
- ALWAYS use AssertJ for assertions (not JUnit's basic assertEquals)
|
|
310
|
+
|
|
311
|
+
### Security
|
|
312
|
+
- Use Spring Security for authentication and authorization
|
|
313
|
+
- NEVER store passwords in plain text — use BCryptPasswordEncoder
|
|
314
|
+
- ALWAYS validate JWT tokens on every protected endpoint
|
|
315
|
+
- Use method-level security (@PreAuthorize) for authorization checks
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Template: `templates/claudemd/react-spa.md`
|
|
319
|
+
|
|
320
|
+
In addition to ALL mandatory sections above (with: `{{test_command}}` = `npm test` or `npx vitest`, `{{build_command}}` = `npm run build`, `{{lint_command}}` = `npx eslint .`, `{{format_command}}` = `npx prettier --write .`):
|
|
321
|
+
|
|
322
|
+
```markdown
|
|
323
|
+
## Architecture Rules — React SPA
|
|
324
|
+
|
|
325
|
+
### Component Design
|
|
326
|
+
- Components MUST be under 200 lines — extract sub-components if they grow beyond this
|
|
327
|
+
- Separate container components (data fetching, state) from presentation components (rendering)
|
|
328
|
+
- NEVER put API calls directly in components — use custom hooks or a data layer (React Query, SWR)
|
|
329
|
+
- Every component that accepts props MUST have a TypeScript interface defining those props
|
|
330
|
+
- NEVER use `React.FC` — use plain function declarations with typed props
|
|
331
|
+
|
|
332
|
+
### State Management
|
|
333
|
+
- Use React hooks (useState, useReducer) for component-local state
|
|
334
|
+
- Use React Query or SWR for server state (API data) — NEVER store server data in Redux/Zustand
|
|
335
|
+
- Only use a state management library (Zustand, Jotai) for genuinely global client state
|
|
336
|
+
- NEVER put form state in global state — use react-hook-form or controlled local state
|
|
337
|
+
- NEVER create a "god context" that holds all application state — split contexts by domain
|
|
338
|
+
|
|
339
|
+
### Error Handling
|
|
340
|
+
- EVERY async operation needs try/catch with user-visible error feedback
|
|
341
|
+
- Use Error Boundaries for component tree crash protection
|
|
342
|
+
- NEVER show raw error objects to users — format them into human-readable messages
|
|
343
|
+
- ALWAYS show loading states during async operations — no blank screens or frozen UIs
|
|
344
|
+
|
|
345
|
+
### Routing
|
|
346
|
+
- Use React Router v6+ with typed route parameters
|
|
347
|
+
- Every route MUST have a fallback/404 handler
|
|
348
|
+
- Protected routes MUST redirect to login, not show a blank page
|
|
349
|
+
- ALWAYS handle the "back button" — navigating back should not break state
|
|
350
|
+
|
|
351
|
+
### API Integration
|
|
352
|
+
- Create a centralized API client (e.g., an axios instance with interceptors)
|
|
353
|
+
- NEVER hardcode API URLs — use environment variables
|
|
354
|
+
- ALWAYS handle: loading state, success, error, and empty-data states for every API call
|
|
355
|
+
- ALWAYS handle token refresh and 401 responses in the API client interceptor
|
|
356
|
+
|
|
357
|
+
### Testing
|
|
358
|
+
- Use React Testing Library (not Enzyme)
|
|
359
|
+
- Test behavior, not implementation — query by role, label, or text, NEVER by CSS class or test ID
|
|
360
|
+
- Every component with conditional rendering needs tests for each condition
|
|
361
|
+
- Every custom hook needs tests using renderHook()
|
|
362
|
+
- Mock API calls with MSW (Mock Service Worker), not by mocking fetch/axios directly
|
|
363
|
+
|
|
364
|
+
### Accessibility
|
|
365
|
+
- EVERY interactive element must be keyboard accessible
|
|
366
|
+
- EVERY image must have an alt attribute
|
|
367
|
+
- Use semantic HTML (button, nav, main, aside) — not div for everything
|
|
368
|
+
- Form inputs MUST have associated labels
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Template: `templates/claudemd/monorepo.md`
|
|
372
|
+
|
|
373
|
+
In addition to ALL mandatory sections, add:
|
|
374
|
+
|
|
375
|
+
```markdown
|
|
376
|
+
## Monorepo Architecture
|
|
377
|
+
|
|
378
|
+
### Package Boundaries
|
|
379
|
+
- Each package MUST have its own CLAUDE.md with package-specific rules
|
|
380
|
+
- Packages MUST NOT import from other packages using relative paths — use the package name
|
|
381
|
+
- Shared types go in a dedicated `packages/shared` or `packages/types` package
|
|
382
|
+
- Every package MUST have its own test suite that can run independently
|
|
383
|
+
|
|
384
|
+
### Dependency Management
|
|
385
|
+
- Use workspace protocol for internal dependencies (e.g., `"workspace:*"`)
|
|
386
|
+
- NEVER duplicate dependencies across packages — hoist shared deps to the root
|
|
387
|
+
- Run `{{package_manager}} install` from the workspace root, never from individual packages
|
|
388
|
+
|
|
389
|
+
### CI/CD
|
|
390
|
+
- Changes to a package MUST only trigger CI for that package and its dependents
|
|
391
|
+
- The root build command MUST build packages in dependency order
|
|
392
|
+
- NEVER deploy a package without running its tests AND the tests of packages that depend on it
|
|
393
|
+
|
|
394
|
+
### Subdirectory CLAUDE.md files
|
|
395
|
+
- Each package directory (e.g., packages/api, packages/web, packages/shared) should have its own CLAUDE.md
|
|
396
|
+
- Subdirectory CLAUDE.md files inherit all Mandatory Practices from the root but add package-specific rules
|
|
397
|
+
- When working in a subdirectory, Claude loads BOTH the root and subdirectory CLAUDE.md
|
|
398
|
+
```
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
# SECTION 2: SKILL TEMPLATES
|
|
403
|
+
|
|
404
|
+
Each skill template lives in `templates/skills/`. Each file is a complete SKILL.md with YAML frontmatter and detailed instructions. These are NOT stubs. Every instruction must be specific and actionable.
|
|
405
|
+
|
|
406
|
+
## 2.1 Code Review Skill
|
|
407
|
+
|
|
408
|
+
File: `templates/skills/code-review.md`
|
|
409
|
+
|
|
410
|
+
```markdown
|
|
411
|
+
---
|
|
412
|
+
name: code-review
|
|
413
|
+
description: Performs comprehensive code review on changed files, checking for bugs, security issues, missing tests, and code quality problems. Auto-invokes when reviewing PRs or when asked to review code.
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Code Review Process
|
|
417
|
+
|
|
418
|
+
When performing a code review, follow this EXACT process in order:
|
|
419
|
+
|
|
420
|
+
### Step 1: Identify Changed Files
|
|
421
|
+
Run `git diff --name-only HEAD~1` (or the appropriate diff command for the context) to identify all changed files. List them before proceeding.
|
|
422
|
+
|
|
423
|
+
### Step 2: For EACH Changed File, Check ALL of the Following
|
|
424
|
+
|
|
425
|
+
**Correctness**
|
|
426
|
+
- Does the logic actually do what it claims to do? Trace through the code mentally with sample inputs.
|
|
427
|
+
- Are there off-by-one errors in loops or array indexing?
|
|
428
|
+
- Are there race conditions in concurrent code?
|
|
429
|
+
- Are null/undefined values handled at every point they could occur?
|
|
430
|
+
- Do conditional branches cover all cases? Is there a missing else/default?
|
|
431
|
+
|
|
432
|
+
**Error Handling**
|
|
433
|
+
- Does every function that can fail have error handling?
|
|
434
|
+
- Are catch blocks doing something meaningful (logging, recovery, re-throwing with context)?
|
|
435
|
+
- Are there any empty catch blocks? FLAG THESE AS CRITICAL.
|
|
436
|
+
- Do error messages include enough context to debug the issue?
|
|
437
|
+
- Are errors propagated correctly up the call chain?
|
|
438
|
+
|
|
439
|
+
**Security**
|
|
440
|
+
- Is user input validated before use?
|
|
441
|
+
- Are there any SQL injection vectors (string concatenation in queries)?
|
|
442
|
+
- Are there any XSS vectors (unescaped user content in HTML)?
|
|
443
|
+
- Are secrets or credentials hardcoded? FLAG AS CRITICAL.
|
|
444
|
+
- Are there any path traversal vulnerabilities in file operations?
|
|
445
|
+
- Is authentication/authorization checked before sensitive operations?
|
|
446
|
+
|
|
447
|
+
**Testing**
|
|
448
|
+
- Does every new function have at least one test?
|
|
449
|
+
- Are edge cases tested (empty input, null, boundary values)?
|
|
450
|
+
- Are error paths tested (what happens when things fail)?
|
|
451
|
+
- If a bug was fixed, is there a regression test?
|
|
452
|
+
- FLAG any new code without corresponding tests as a REQUIRED CHANGE.
|
|
453
|
+
|
|
454
|
+
**Code Quality**
|
|
455
|
+
- Are there any `any` types? FLAG THESE.
|
|
456
|
+
- Are functions under 50 lines? Flag functions over 50 lines for extraction.
|
|
457
|
+
- Are files under 400 lines? Flag files over 400 lines for splitting.
|
|
458
|
+
- Are variable names descriptive? Flag single-letter variables outside of loop counters.
|
|
459
|
+
- Is there duplicated code that should be extracted?
|
|
460
|
+
- Are there TODO/FIXME/HACK comments? Flag these as incomplete work.
|
|
461
|
+
|
|
462
|
+
### Step 3: Produce Review Summary
|
|
463
|
+
|
|
464
|
+
Format your review as:
|
|
465
|
+
|
|
466
|
+
```
|
|
467
|
+
## Code Review Summary
|
|
468
|
+
|
|
469
|
+
### Critical Issues (Must Fix)
|
|
470
|
+
- [file:line] Description of the issue and why it's critical
|
|
471
|
+
|
|
472
|
+
### Required Changes
|
|
473
|
+
- [file:line] Description of what needs to change
|
|
474
|
+
|
|
475
|
+
### Suggestions (Nice to Have)
|
|
476
|
+
- [file:line] Description of the improvement
|
|
477
|
+
|
|
478
|
+
### What Looks Good
|
|
479
|
+
- Specific things that are well-implemented
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
NEVER produce a review that says "Looks good, no issues found" unless you have genuinely checked every item above for every changed file. If you only spot-checked, say so.
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
## 2.2 Test Writer Skill
|
|
486
|
+
|
|
487
|
+
File: `templates/skills/test-writer.md`
|
|
488
|
+
|
|
489
|
+
```markdown
|
|
490
|
+
---
|
|
491
|
+
name: test-writer
|
|
492
|
+
description: Generates comprehensive tests for code changes. Auto-invokes when creating new functions, modules, or fixing bugs. Writes tests BEFORE implementation when doing TDD.
|
|
493
|
+
---
|
|
494
|
+
|
|
495
|
+
## Test Writing Process
|
|
496
|
+
|
|
497
|
+
### Step 1: Analyze What Needs Testing
|
|
498
|
+
- Read the function/module signature, parameters, and return type
|
|
499
|
+
- Identify the happy path (normal successful execution)
|
|
500
|
+
- Identify error paths (what can go wrong?)
|
|
501
|
+
- Identify edge cases (empty input, null, boundary values, max values)
|
|
502
|
+
- Identify integration points (database calls, API calls, file system)
|
|
503
|
+
|
|
504
|
+
### Step 2: Write Tests in This Order
|
|
505
|
+
|
|
506
|
+
1. **Happy path test** — The most basic successful case
|
|
507
|
+
2. **Input validation tests** — Invalid inputs, missing required fields, wrong types
|
|
508
|
+
3. **Edge case tests** — Empty arrays, zero values, very long strings, special characters
|
|
509
|
+
4. **Error handling tests** — Network failures, database errors, file not found
|
|
510
|
+
5. **Integration tests** — Full request/response cycle (if applicable)
|
|
511
|
+
|
|
512
|
+
### Step 3: Test Structure
|
|
513
|
+
|
|
514
|
+
Every test MUST follow this structure:
|
|
515
|
+
|
|
516
|
+
```
|
|
517
|
+
// Descriptive name that explains what is being tested and expected outcome
|
|
518
|
+
test("createUser returns the created user with a generated ID when given valid input", async () => {
|
|
519
|
+
// ARRANGE: Set up test data and dependencies
|
|
520
|
+
const input = { name: "Test User", email: "test@example.com" };
|
|
521
|
+
|
|
522
|
+
// ACT: Execute the function under test
|
|
523
|
+
const result = await createUser(input);
|
|
524
|
+
|
|
525
|
+
// ASSERT: Verify the outcome
|
|
526
|
+
expect(result.id).toBeDefined();
|
|
527
|
+
expect(result.name).toBe("Test User");
|
|
528
|
+
expect(result.email).toBe("test@example.com");
|
|
529
|
+
});
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
### Mandatory Test Categories
|
|
533
|
+
|
|
534
|
+
For EVERY function, write tests covering:
|
|
535
|
+
|
|
536
|
+
| Category | Example | Required? |
|
|
537
|
+
|---|---|---|
|
|
538
|
+
| Valid input, expected output | Normal successful operation | ALWAYS |
|
|
539
|
+
| Missing required field | Omit a required parameter | ALWAYS |
|
|
540
|
+
| Invalid type | Pass string where number expected | ALWAYS |
|
|
541
|
+
| Empty input | Empty string, empty array, null | ALWAYS |
|
|
542
|
+
| Boundary values | 0, -1, MAX_INT, very long string | WHEN APPLICABLE |
|
|
543
|
+
| Duplicate/conflict | Creating something that already exists | WHEN APPLICABLE |
|
|
544
|
+
| Not found | Requesting something that does not exist | WHEN APPLICABLE |
|
|
545
|
+
| Unauthorized | Accessing without proper permissions | WHEN AUTH EXISTS |
|
|
546
|
+
| Concurrent access | Two operations on same resource | WHEN APPLICABLE |
|
|
547
|
+
| Error recovery | Service dependency fails | WHEN EXTERNAL DEPS EXIST |
|
|
548
|
+
|
|
549
|
+
### Rules
|
|
550
|
+
- Test file names MUST match source file: `user.service.ts` → `user.service.test.ts`
|
|
551
|
+
- NEVER test implementation details — test behavior and outcomes
|
|
552
|
+
- NEVER use `test("should work")` — test names must describe the specific scenario and expected outcome
|
|
553
|
+
- EVERY test must be independent — no test should depend on another test running first
|
|
554
|
+
- ALWAYS clean up test data (use beforeEach/afterEach or setup/teardown)
|
|
555
|
+
- Mock external dependencies (databases, APIs, file system) — do not make real network calls in unit tests
|
|
556
|
+
- NEVER write a test that always passes — verify your test fails before the implementation exists
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
## 2.3 Security Scan Skill
|
|
560
|
+
|
|
561
|
+
File: `templates/skills/security-scan.md`
|
|
562
|
+
|
|
563
|
+
```markdown
|
|
564
|
+
---
|
|
565
|
+
name: security-scan
|
|
566
|
+
description: Scans code for security vulnerabilities including injection, XSS, hardcoded secrets, insecure dependencies, and missing auth checks. Auto-invokes when modifying auth, API, or data handling code.
|
|
567
|
+
---
|
|
568
|
+
|
|
569
|
+
## Security Scan Process
|
|
570
|
+
|
|
571
|
+
### Step 1: Scan for Hardcoded Secrets
|
|
572
|
+
Search the entire codebase for patterns matching:
|
|
573
|
+
- API keys: strings matching `[A-Za-z0-9_-]{20,}` near variables named `key`, `token`, `secret`, `password`, `apiKey`, `api_key`, `auth`
|
|
574
|
+
- AWS keys: strings starting with `AKIA`
|
|
575
|
+
- Private keys: `-----BEGIN (RSA |EC |DSA )?PRIVATE KEY-----`
|
|
576
|
+
- Connection strings with embedded passwords
|
|
577
|
+
- .env files committed to git (check .gitignore)
|
|
578
|
+
|
|
579
|
+
Use `grep -rn` with these patterns. Report EVERY match as CRITICAL.
|
|
580
|
+
|
|
581
|
+
### Step 2: Scan for Injection Vulnerabilities
|
|
582
|
+
For every file that constructs queries or commands:
|
|
583
|
+
- SQL injection: String concatenation or template literals in SQL queries
|
|
584
|
+
- Command injection: User input passed to exec(), spawn(), system(), or shell commands
|
|
585
|
+
- Path traversal: User input used in file paths without sanitization
|
|
586
|
+
- LDAP injection: User input in LDAP queries
|
|
587
|
+
- NoSQL injection: User input in MongoDB queries without sanitization
|
|
588
|
+
|
|
589
|
+
### Step 3: Scan for XSS Vulnerabilities
|
|
590
|
+
For every file that renders user content:
|
|
591
|
+
- Unescaped user input in HTML templates
|
|
592
|
+
- innerHTML or dangerouslySetInnerHTML with user data
|
|
593
|
+
- User data in href, src, or event handler attributes
|
|
594
|
+
- Missing Content-Security-Policy headers
|
|
595
|
+
|
|
596
|
+
### Step 4: Scan for Auth/AuthZ Issues
|
|
597
|
+
- Endpoints without authentication middleware
|
|
598
|
+
- Missing authorization checks (user can access other users' data)
|
|
599
|
+
- JWT tokens without expiration
|
|
600
|
+
- Passwords stored without hashing
|
|
601
|
+
- Session tokens in URLs (should be in cookies or headers)
|
|
602
|
+
- Missing CORS configuration or overly permissive CORS (`*`)
|
|
603
|
+
|
|
604
|
+
### Step 5: Scan for Dependency Vulnerabilities
|
|
605
|
+
Run the appropriate audit command:
|
|
606
|
+
- Node.js: `npm audit` or `yarn audit`
|
|
607
|
+
- Python: `pip-audit` or `safety check`
|
|
608
|
+
- Java: `./mvnw dependency-check:check`
|
|
609
|
+
|
|
610
|
+
Report any high or critical severity vulnerabilities.
|
|
611
|
+
|
|
612
|
+
### Output Format
|
|
613
|
+
```
|
|
614
|
+
## Security Scan Results
|
|
615
|
+
|
|
616
|
+
### CRITICAL (Fix Immediately)
|
|
617
|
+
- [file:line] [CATEGORY] Description and remediation
|
|
618
|
+
|
|
619
|
+
### HIGH (Fix Before Merge)
|
|
620
|
+
- [file:line] [CATEGORY] Description and remediation
|
|
621
|
+
|
|
622
|
+
### MEDIUM (Fix Soon)
|
|
623
|
+
- [file:line] [CATEGORY] Description and remediation
|
|
624
|
+
|
|
625
|
+
### LOW (Informational)
|
|
626
|
+
- [file:line] [CATEGORY] Description
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
NEVER produce a clean scan without actually running the checks. If a check cannot be performed (e.g., no audit tool installed), say so explicitly.
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
## 2.4 Documentation Skill
|
|
633
|
+
|
|
634
|
+
File: `templates/skills/documentation.md`
|
|
635
|
+
|
|
636
|
+
```markdown
|
|
637
|
+
---
|
|
638
|
+
name: documentation
|
|
639
|
+
description: Generates and updates documentation when code changes. Creates README updates, API docs, and inline documentation. Auto-invokes when creating new modules, endpoints, or public APIs.
|
|
640
|
+
---
|
|
641
|
+
|
|
642
|
+
## Documentation Standards
|
|
643
|
+
|
|
644
|
+
### When to Generate Documentation
|
|
645
|
+
- New module or package created → Generate module README
|
|
646
|
+
- New API endpoint created → Update API documentation
|
|
647
|
+
- New public function/class created → Add JSDoc/docstring
|
|
648
|
+
- Configuration changed → Update setup documentation
|
|
649
|
+
- Breaking change made → Update CHANGELOG and migration guide
|
|
650
|
+
|
|
651
|
+
### Function/Method Documentation
|
|
652
|
+
Every exported function MUST have a documentation comment containing:
|
|
653
|
+
1. One-line summary of what the function does
|
|
654
|
+
2. @param for every parameter with type and description
|
|
655
|
+
3. @returns describing what is returned and when
|
|
656
|
+
4. @throws listing every exception that can be thrown and why
|
|
657
|
+
5. @example with at least one usage example
|
|
658
|
+
|
|
659
|
+
### API Endpoint Documentation
|
|
660
|
+
Every API endpoint MUST be documented with:
|
|
661
|
+
1. HTTP method and path
|
|
662
|
+
2. Description of what it does
|
|
663
|
+
3. Request body schema (with all fields, types, and whether required)
|
|
664
|
+
4. Response schemas for ALL status codes (200, 400, 401, 404, 500)
|
|
665
|
+
5. Example request and response
|
|
666
|
+
6. Authentication requirements
|
|
667
|
+
|
|
668
|
+
### README Standards
|
|
669
|
+
Every package/module README MUST contain:
|
|
670
|
+
1. What the module does (one paragraph)
|
|
671
|
+
2. How to install/setup
|
|
672
|
+
3. Basic usage example that actually works
|
|
673
|
+
4. Configuration options
|
|
674
|
+
5. API reference or link to API docs
|
|
675
|
+
|
|
676
|
+
NEVER generate documentation that says "Add description here" or contains placeholder text. If you don't know what something does, read the code and describe it accurately.
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
## 2.5 Performance Audit Skill
|
|
680
|
+
|
|
681
|
+
File: `templates/skills/performance-audit.md`
|
|
682
|
+
|
|
683
|
+
```markdown
|
|
684
|
+
---
|
|
685
|
+
name: performance-audit
|
|
686
|
+
description: Identifies performance issues in code including N+1 queries, memory leaks, unnecessary re-renders, and inefficient algorithms. Auto-invokes when modifying database queries, loops, or data processing code.
|
|
687
|
+
---
|
|
688
|
+
|
|
689
|
+
## Performance Audit Checklist
|
|
690
|
+
|
|
691
|
+
### Database Performance
|
|
692
|
+
- [ ] N+1 query detection: Are queries inside loops? Should they be batched?
|
|
693
|
+
- [ ] Missing indexes: Are WHERE clause columns indexed?
|
|
694
|
+
- [ ] SELECT *: Are you fetching columns you don't need?
|
|
695
|
+
- [ ] Unbounded queries: Is there a LIMIT? What if the table has 10 million rows?
|
|
696
|
+
- [ ] Missing pagination: Are list endpoints paginated?
|
|
697
|
+
- [ ] Transaction scope: Are transactions held open during slow operations?
|
|
698
|
+
|
|
699
|
+
### Memory Performance
|
|
700
|
+
- [ ] Unbounded collections: Are arrays/lists growing without limit?
|
|
701
|
+
- [ ] Missing cleanup: Are event listeners, intervals, and subscriptions cleaned up?
|
|
702
|
+
- [ ] Large object retention: Are references to large objects held after they're needed?
|
|
703
|
+
- [ ] Stream vs. buffer: Are large files loaded entirely into memory, or streamed?
|
|
704
|
+
|
|
705
|
+
### Algorithm Performance
|
|
706
|
+
- [ ] Nested loops: Is there an O(n²) operation that could be O(n) with a map/set?
|
|
707
|
+
- [ ] Repeated computation: Is the same value calculated multiple times?
|
|
708
|
+
- [ ] Unnecessary sorting: Is data sorted when only the min/max is needed?
|
|
709
|
+
- [ ] String concatenation in loops: Should use array join or string builder?
|
|
710
|
+
|
|
711
|
+
### Frontend Performance (if applicable)
|
|
712
|
+
- [ ] Unnecessary re-renders: Are components re-rendering when their props haven't changed?
|
|
713
|
+
- [ ] Missing memoization: Should expensive computations use useMemo?
|
|
714
|
+
- [ ] Bundle size: Are large libraries imported for small features?
|
|
715
|
+
- [ ] Image optimization: Are images appropriately sized and lazy-loaded?
|
|
716
|
+
- [ ] Missing virtualization: Are long lists rendered without windowing?
|
|
717
|
+
|
|
718
|
+
Report issues with estimated impact (critical/high/medium/low) and specific remediation steps.
|
|
719
|
+
```
|
|
720
|
+
|
|
721
|
+
---
|
|
722
|
+
|
|
723
|
+
# SECTION 3: AGENT TEMPLATES
|
|
724
|
+
|
|
725
|
+
Each agent template lives in `templates/agents/`. Each file is a complete markdown file ready to be placed in `.claude/agents/`.
|
|
726
|
+
|
|
727
|
+
## 3.1 Explore Agent
|
|
728
|
+
|
|
729
|
+
File: `templates/agents/explore.md`
|
|
730
|
+
|
|
731
|
+
```markdown
|
|
732
|
+
---
|
|
733
|
+
name: explore
|
|
734
|
+
description: Read-only codebase investigation. Understands architecture, finds files, traces data flow. Never modifies files.
|
|
735
|
+
allowed-tools: Read, Glob, Grep, Bash(find *), Bash(wc *), Bash(cat *)
|
|
736
|
+
---
|
|
737
|
+
|
|
738
|
+
You are an exploration agent. Your job is to understand codebases without modifying them.
|
|
739
|
+
|
|
740
|
+
## Rules
|
|
741
|
+
- NEVER use Write, Edit, or any tool that modifies files
|
|
742
|
+
- NEVER run commands that could change state (no npm install, no git commit, no database writes)
|
|
743
|
+
- ALWAYS explain your findings with specific file paths and line numbers
|
|
744
|
+
- ALWAYS trace the full call chain when investigating how something works
|
|
745
|
+
|
|
746
|
+
## When Asked to Explore
|
|
747
|
+
1. Start by reading the project structure (`find . -type f -not -path '*/node_modules/*' -not -path '*/.git/*'`)
|
|
748
|
+
2. Read the entry point files first (index.ts, main.py, App.java)
|
|
749
|
+
3. Follow imports to understand the dependency graph
|
|
750
|
+
4. Use Grep to find all usages of specific functions or types
|
|
751
|
+
5. Summarize findings with a clear architecture description and specific file references
|
|
752
|
+
```
|
|
753
|
+
|
|
754
|
+
## 3.2 Plan Agent
|
|
755
|
+
|
|
756
|
+
File: `templates/agents/plan.md`
|
|
757
|
+
|
|
758
|
+
```markdown
|
|
759
|
+
---
|
|
760
|
+
name: plan
|
|
761
|
+
description: Architecture planning and task decomposition. Produces detailed implementation plans without writing code.
|
|
762
|
+
allowed-tools: Read, Glob, Grep, Bash(find *), Bash(wc *), Bash(cat *)
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
You are a planning agent. Your job is to produce detailed implementation plans.
|
|
766
|
+
|
|
767
|
+
## Rules
|
|
768
|
+
- NEVER write or modify code — only produce plans
|
|
769
|
+
- ALWAYS read existing code before planning changes
|
|
770
|
+
- ALWAYS break plans into tasks that are each completable in under 30 minutes
|
|
771
|
+
- EVERY task must include: what files to create/modify, what to add/change, and how to verify it works
|
|
772
|
+
- ALWAYS identify risks and dependencies between tasks
|
|
773
|
+
|
|
774
|
+
## Plan Format
|
|
775
|
+
```
|
|
776
|
+
## Implementation Plan: [Feature Name]
|
|
777
|
+
|
|
778
|
+
### Prerequisites
|
|
779
|
+
- What must exist before starting
|
|
780
|
+
|
|
781
|
+
### Tasks (in order)
|
|
782
|
+
1. **[Task Name]** (estimated: X minutes)
|
|
783
|
+
- Files to modify: [list]
|
|
784
|
+
- Changes: [specific description]
|
|
785
|
+
- Verification: [how to test this task is done correctly]
|
|
786
|
+
- Dependencies: [which tasks must be done first]
|
|
787
|
+
|
|
788
|
+
### Risks
|
|
789
|
+
- [Risk]: [Mitigation]
|
|
790
|
+
|
|
791
|
+
### Definition of Done
|
|
792
|
+
- [ ] All tasks completed
|
|
793
|
+
- [ ] All tests pass
|
|
794
|
+
- [ ] No new lint warnings
|
|
795
|
+
- [ ] Documentation updated
|
|
796
|
+
```
|
|
797
|
+
```
|
|
798
|
+
|
|
799
|
+
## 3.3 Test Runner Agent
|
|
800
|
+
|
|
801
|
+
File: `templates/agents/test-runner.md`
|
|
802
|
+
|
|
803
|
+
```markdown
|
|
804
|
+
---
|
|
805
|
+
name: test-runner
|
|
806
|
+
description: Executes test suites, analyzes failures, identifies flaky tests, and reports coverage gaps.
|
|
807
|
+
allowed-tools: Read, Glob, Grep, Bash
|
|
808
|
+
---
|
|
809
|
+
|
|
810
|
+
You are a test runner agent. Your job is to execute tests and provide detailed analysis.
|
|
811
|
+
|
|
812
|
+
## Process
|
|
813
|
+
1. Run the full test suite: `{{test_command}}`
|
|
814
|
+
2. If tests fail:
|
|
815
|
+
- Read each failing test to understand what it expects
|
|
816
|
+
- Read the implementation code the test covers
|
|
817
|
+
- Identify whether the test or the implementation is wrong
|
|
818
|
+
- Provide specific fix recommendations
|
|
819
|
+
3. If tests pass:
|
|
820
|
+
- Check coverage report if available
|
|
821
|
+
- Identify files/functions with low or zero coverage
|
|
822
|
+
- List the specific test cases that should be added
|
|
823
|
+
4. Check for flaky tests:
|
|
824
|
+
- Run the suite 3 times
|
|
825
|
+
- Report any tests that pass sometimes and fail sometimes
|
|
826
|
+
- Flaky tests are BUGS — they indicate race conditions or test isolation issues
|
|
827
|
+
|
|
828
|
+
## Output Format
|
|
829
|
+
```
|
|
830
|
+
## Test Report
|
|
831
|
+
|
|
832
|
+
### Results: X passed, Y failed, Z skipped
|
|
833
|
+
|
|
834
|
+
### Failures
|
|
835
|
+
- test_name: Why it failed, recommended fix
|
|
836
|
+
|
|
837
|
+
### Coverage Gaps
|
|
838
|
+
- file.ts: Functions missing tests: [list]
|
|
839
|
+
|
|
840
|
+
### Flaky Tests
|
|
841
|
+
- test_name: Passed X/3 runs, likely cause
|
|
842
|
+
|
|
843
|
+
### Recommendations
|
|
844
|
+
- Specific tests to add, ordered by risk
|
|
845
|
+
```
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
## 3.4 Security Auditor Agent
|
|
849
|
+
|
|
850
|
+
File: `templates/agents/security-auditor.md`
|
|
851
|
+
|
|
852
|
+
```markdown
|
|
853
|
+
---
|
|
854
|
+
name: security-auditor
|
|
855
|
+
description: Comprehensive security audit of the codebase. Scans for vulnerabilities, checks dependencies, and reviews auth implementation.
|
|
856
|
+
allowed-tools: Read, Glob, Grep, Bash
|
|
857
|
+
---
|
|
858
|
+
|
|
859
|
+
You are a security auditor agent. Your job is to find security vulnerabilities.
|
|
860
|
+
|
|
861
|
+
## Audit Process
|
|
862
|
+
1. Run dependency audit (`npm audit` / `pip-audit` / equivalent)
|
|
863
|
+
2. Scan for hardcoded secrets (grep for key patterns in all source files)
|
|
864
|
+
3. Review authentication implementation (find auth middleware, check JWT handling)
|
|
865
|
+
4. Review authorization (find access control checks, verify they cover all protected resources)
|
|
866
|
+
5. Scan for injection vulnerabilities (SQL, command, path traversal, XSS)
|
|
867
|
+
6. Check security headers (CORS, CSP, HSTS, X-Frame-Options)
|
|
868
|
+
7. Review error handling (ensure no stack traces or internal details leak to clients)
|
|
869
|
+
8. Check logging (ensure no sensitive data is logged)
|
|
870
|
+
|
|
871
|
+
## Rules
|
|
872
|
+
- NEVER mark a vulnerability as "low risk" to avoid inconvenience — report what you find honestly
|
|
873
|
+
- ALWAYS include the specific file and line number
|
|
874
|
+
- ALWAYS include a concrete remediation step, not just "fix this"
|
|
875
|
+
- If you find a critical vulnerability, say so clearly at the top of your report
|
|
876
|
+
```
|
|
877
|
+
|
|
878
|
+
---
|
|
879
|
+
|
|
880
|
+
# SECTION 4: HOOK TEMPLATES
|
|
881
|
+
|
|
882
|
+
Hook templates live in `templates/hooks/`. Each file is a JSON object that gets merged into `.claude/settings.json` under the `hooks` key.
|
|
883
|
+
|
|
884
|
+
## 4.1 Format-on-Write Hook
|
|
885
|
+
|
|
886
|
+
File: `templates/hooks/format-on-write.json`
|
|
887
|
+
|
|
888
|
+
```json
|
|
889
|
+
{
|
|
890
|
+
"PostToolUse": [
|
|
891
|
+
{
|
|
892
|
+
"matcher": "Write(*.ts)|Write(*.tsx)|Write(*.js)|Write(*.jsx)",
|
|
893
|
+
"hooks": [
|
|
894
|
+
{
|
|
895
|
+
"type": "command",
|
|
896
|
+
"command": "npx prettier --write \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
|
|
897
|
+
}
|
|
898
|
+
]
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
"matcher": "Write(*.py)",
|
|
902
|
+
"hooks": [
|
|
903
|
+
{
|
|
904
|
+
"type": "command",
|
|
905
|
+
"command": "ruff format \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
|
|
906
|
+
}
|
|
907
|
+
]
|
|
908
|
+
},
|
|
909
|
+
{
|
|
910
|
+
"matcher": "Write(*.go)",
|
|
911
|
+
"hooks": [
|
|
912
|
+
{
|
|
913
|
+
"type": "command",
|
|
914
|
+
"command": "gofmt -w \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
|
|
915
|
+
}
|
|
916
|
+
]
|
|
917
|
+
},
|
|
918
|
+
{
|
|
919
|
+
"matcher": "Write(*.rs)",
|
|
920
|
+
"hooks": [
|
|
921
|
+
{
|
|
922
|
+
"type": "command",
|
|
923
|
+
"command": "rustfmt \"$CLAUDE_FILE_PATH\" 2>/dev/null || true"
|
|
924
|
+
}
|
|
925
|
+
]
|
|
926
|
+
}
|
|
927
|
+
]
|
|
928
|
+
}
|
|
929
|
+
```
|
|
930
|
+
|
|
931
|
+
## 4.2 Lint-on-Write Hook
|
|
932
|
+
|
|
933
|
+
File: `templates/hooks/lint-on-write.json`
|
|
934
|
+
|
|
935
|
+
```json
|
|
936
|
+
{
|
|
937
|
+
"PostToolUse": [
|
|
938
|
+
{
|
|
939
|
+
"matcher": "Write(*.ts)|Write(*.tsx)|Write(*.js)|Write(*.jsx)",
|
|
940
|
+
"hooks": [
|
|
941
|
+
{
|
|
942
|
+
"type": "command",
|
|
943
|
+
"command": "npx eslint --no-error-on-unmatched-pattern \"$CLAUDE_FILE_PATH\" 2>&1 | head -20"
|
|
944
|
+
}
|
|
945
|
+
]
|
|
946
|
+
},
|
|
947
|
+
{
|
|
948
|
+
"matcher": "Write(*.py)",
|
|
949
|
+
"hooks": [
|
|
950
|
+
{
|
|
951
|
+
"type": "command",
|
|
952
|
+
"command": "ruff check \"$CLAUDE_FILE_PATH\" 2>&1 | head -20"
|
|
953
|
+
}
|
|
954
|
+
]
|
|
955
|
+
}
|
|
956
|
+
]
|
|
957
|
+
}
|
|
958
|
+
```
|
|
959
|
+
|
|
960
|
+
## 4.3 Test Enforcement Hook
|
|
961
|
+
|
|
962
|
+
File: `templates/hooks/test-enforcement.json`
|
|
963
|
+
|
|
964
|
+
THIS IS THE MOST IMPORTANT HOOK. This is what prevents Claude from shipping untested code.
|
|
965
|
+
|
|
966
|
+
```json
|
|
967
|
+
{
|
|
968
|
+
"PostToolUse": [
|
|
969
|
+
{
|
|
970
|
+
"matcher": "Write(*.ts)|Write(*.tsx)|Write(*.js)|Write(*.jsx)|Edit(*.ts)|Edit(*.tsx)|Edit(*.js)|Edit(*.jsx)",
|
|
971
|
+
"hooks": [
|
|
972
|
+
{
|
|
973
|
+
"type": "command",
|
|
974
|
+
"command": "npm test 2>&1 | tail -5; EXIT_CODE=${PIPESTATUS[0]}; if [ $EXIT_CODE -ne 0 ]; then echo '\\n❌ TESTS FAILED — Fix failing tests before continuing. Do not move to the next task.'; fi; exit 0"
|
|
975
|
+
}
|
|
976
|
+
]
|
|
977
|
+
}
|
|
978
|
+
]
|
|
979
|
+
}
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
Note: The hook itself does not block (exit 0) because blocking on every file write is too aggressive. Instead, it surfaces the test failure prominently in Claude's context so it sees the failure and acts on it. For strict enforcement, change `exit 0` to `exit 2` which will cause Claude to stop and address the issue.
|
|
983
|
+
|
|
984
|
+
## 4.4 Dangerous Command Blocker Hook
|
|
985
|
+
|
|
986
|
+
File: `templates/hooks/danger-blocker.json`
|
|
987
|
+
|
|
988
|
+
```json
|
|
989
|
+
{
|
|
990
|
+
"PreToolUse": [
|
|
991
|
+
{
|
|
992
|
+
"matcher": "Bash",
|
|
993
|
+
"hooks": [
|
|
994
|
+
{
|
|
995
|
+
"type": "command",
|
|
996
|
+
"command": "BLOCKED_PATTERNS='rm -rf|rm -fr|git push --force|git push -f|DROP TABLE|DROP DATABASE|TRUNCATE TABLE|:(){:|:&};:|dd if=|mkfs|format c:|del /f /s /q|chmod -R 777|curl.*|.*|sh$|wget.*|.*|sh$'; if echo \"$CLAUDE_BASH_COMMAND\" | grep -qiE \"$BLOCKED_PATTERNS\"; then echo 'BLOCKED: This command is potentially destructive and has been blocked by ccboot safety hooks. If you genuinely need to run this command, ask the developer for explicit approval.' >&2; exit 2; fi; exit 0"
|
|
997
|
+
}
|
|
998
|
+
]
|
|
999
|
+
}
|
|
1000
|
+
]
|
|
1001
|
+
}
|
|
1002
|
+
```
|
|
1003
|
+
|
|
1004
|
+
Exit code 2 is critical — it tells Claude Code to STOP and not execute the command.
|
|
1005
|
+
|
|
1006
|
+
## 4.5 Secret Leak Detector Hook
|
|
1007
|
+
|
|
1008
|
+
File: `templates/hooks/secret-detector.json`
|
|
1009
|
+
|
|
1010
|
+
```json
|
|
1011
|
+
{
|
|
1012
|
+
"PreToolUse": [
|
|
1013
|
+
{
|
|
1014
|
+
"matcher": "Bash(git commit*)|Bash(git add*)",
|
|
1015
|
+
"hooks": [
|
|
1016
|
+
{
|
|
1017
|
+
"type": "command",
|
|
1018
|
+
"command": "STAGED=$(git diff --cached --name-only 2>/dev/null); if [ -z \"$STAGED\" ]; then exit 0; fi; SECRETS=$(git diff --cached | grep -inE '(api[_-]?key|secret|password|token|private[_-]?key|aws_access|AKIA[A-Z0-9]{16})\\s*[:=]\\s*[\"\\x27]?[A-Za-z0-9+/=_-]{8,}' | head -5); if [ -n \"$SECRETS\" ]; then echo \"BLOCKED: Potential secrets detected in staged files:\" >&2; echo \"$SECRETS\" >&2; echo 'Remove secrets and use environment variables instead.' >&2; exit 2; fi; exit 0"
|
|
1019
|
+
}
|
|
1020
|
+
]
|
|
1021
|
+
}
|
|
1022
|
+
]
|
|
1023
|
+
}
|
|
1024
|
+
```
|
|
1025
|
+
|
|
1026
|
+
---
|
|
1027
|
+
|
|
1028
|
+
# SECTION 5: NEW TOOL — ccboot_audit_code_quality
|
|
1029
|
+
|
|
1030
|
+
## 5.1 Tool Registration
|
|
1031
|
+
|
|
1032
|
+
Add this tool to `src/tools/management.ts` (or create a new `src/tools/enforcement.ts`).
|
|
1033
|
+
|
|
1034
|
+
Tool name: `ccboot_audit_code_quality`
|
|
1035
|
+
|
|
1036
|
+
## 5.2 Input Schema
|
|
1037
|
+
|
|
1038
|
+
```typescript
|
|
1039
|
+
const AuditCodeQualitySchema = z.object({
|
|
1040
|
+
project_path: z.string().describe("Path to the project root directory"),
|
|
1041
|
+
language: z.enum(["typescript", "javascript", "python", "java", "auto"])
|
|
1042
|
+
.default("auto")
|
|
1043
|
+
.describe("Primary language to scan. 'auto' detects from project files."),
|
|
1044
|
+
output_format: z.enum(["markdown", "json"])
|
|
1045
|
+
.default("markdown")
|
|
1046
|
+
.describe("Output format"),
|
|
1047
|
+
fix_suggestions: z.boolean()
|
|
1048
|
+
.default(true)
|
|
1049
|
+
.describe("Include specific fix suggestions for each issue"),
|
|
1050
|
+
}).strict();
|
|
1051
|
+
```
|
|
1052
|
+
|
|
1053
|
+
## 5.3 What It Scans
|
|
1054
|
+
|
|
1055
|
+
The tool MUST scan for ALL of the following. Each check must be implemented. Do not skip any.
|
|
1056
|
+
|
|
1057
|
+
### Check 1: TODO/FIXME/HACK/XXX Detection
|
|
1058
|
+
- Scan all source files for comments containing TODO, FIXME, HACK, or XXX
|
|
1059
|
+
- Report each occurrence with file, line number, and the comment text
|
|
1060
|
+
- Severity: MEDIUM (indicates incomplete work)
|
|
1061
|
+
|
|
1062
|
+
### Check 2: Empty Catch Blocks
|
|
1063
|
+
- Scan for `catch` blocks that contain no statements (or only a comment)
|
|
1064
|
+
- For TypeScript/JavaScript: regex pattern `catch\s*\([^)]*\)\s*\{\s*\}` and `catch\s*\([^)]*\)\s*\{\s*//[^\n]*\s*\}`
|
|
1065
|
+
- For Python: `except.*:\s*pass` and `except.*:\s*#`
|
|
1066
|
+
- Report each occurrence with file and line number
|
|
1067
|
+
- Severity: HIGH (errors are being silently swallowed)
|
|
1068
|
+
|
|
1069
|
+
### Check 3: `any` Type Usage (TypeScript/JavaScript only)
|
|
1070
|
+
- Scan for `: any`, `as any`, `<any>`, `any[]`, `Promise<any>`, `Record<string, any>`
|
|
1071
|
+
- Exclude files in node_modules/, dist/, and .d.ts declaration files
|
|
1072
|
+
- Report each occurrence with file and line number
|
|
1073
|
+
- Severity: HIGH (defeats the purpose of TypeScript)
|
|
1074
|
+
|
|
1075
|
+
### Check 4: Console.log in Production Code
|
|
1076
|
+
- Scan for `console.log(` in source files (not test files)
|
|
1077
|
+
- Exclude files matching `*.test.*`, `*.spec.*`, and files in `__tests__/`
|
|
1078
|
+
- Report each occurrence
|
|
1079
|
+
- Severity: MEDIUM (should use proper logging)
|
|
1080
|
+
|
|
1081
|
+
### Check 5: Large Files
|
|
1082
|
+
- Scan all source files and report any over 400 lines
|
|
1083
|
+
- Report the file path and line count
|
|
1084
|
+
- Severity: MEDIUM (indicates the file should be split)
|
|
1085
|
+
|
|
1086
|
+
### Check 6: Long Functions
|
|
1087
|
+
- Scan for functions over 50 lines
|
|
1088
|
+
- For TypeScript/JavaScript: Track function/method declarations and count lines to closing brace
|
|
1089
|
+
- Report function name, file, line number, and line count
|
|
1090
|
+
- Severity: MEDIUM (indicates the function should be extracted)
|
|
1091
|
+
|
|
1092
|
+
### Check 7: Hardcoded Strings That Look Like Secrets
|
|
1093
|
+
- Scan for patterns that look like API keys, tokens, or passwords in source code (not .env files)
|
|
1094
|
+
- Patterns: strings longer than 20 chars assigned to variables named key, token, secret, password, api_key, apiKey
|
|
1095
|
+
- Report each occurrence
|
|
1096
|
+
- Severity: CRITICAL (potential secret leak)
|
|
1097
|
+
|
|
1098
|
+
### Check 8: Missing Error Handling in Async Code
|
|
1099
|
+
- For TypeScript/JavaScript: Find `await` expressions not inside a try/catch block
|
|
1100
|
+
- For Python: Find `await` expressions not inside a try/except block
|
|
1101
|
+
- This is a heuristic — report as WARNING, not ERROR
|
|
1102
|
+
- Severity: LOW (not all awaits need try/catch, but unhandled rejections are common bugs)
|
|
1103
|
+
|
|
1104
|
+
## 5.4 Output Format
|
|
1105
|
+
|
|
1106
|
+
Markdown output:
|
|
1107
|
+
```
|
|
1108
|
+
## Code Quality Audit Report
|
|
1109
|
+
|
|
1110
|
+
**Project:** {{project_path}}
|
|
1111
|
+
**Scanned:** {{file_count}} files
|
|
1112
|
+
**Issues Found:** {{total_issues}}
|
|
1113
|
+
|
|
1114
|
+
### Summary
|
|
1115
|
+
| Severity | Count |
|
|
1116
|
+
|----------|-------|
|
|
1117
|
+
| CRITICAL | X |
|
|
1118
|
+
| HIGH | X |
|
|
1119
|
+
| MEDIUM | X |
|
|
1120
|
+
| LOW | X |
|
|
1121
|
+
|
|
1122
|
+
### CRITICAL Issues
|
|
1123
|
+
- **[file.ts:42]** Hardcoded secret: Variable `apiKey` contains a 32-character string that appears to be an API key. Move this to an environment variable.
|
|
1124
|
+
|
|
1125
|
+
### HIGH Issues
|
|
1126
|
+
- **[file.ts:87]** Empty catch block: Error is caught but not handled. Add logging or error recovery.
|
|
1127
|
+
- **[file.ts:15]** `any` type: Parameter `data` is typed as `any`. Use a specific interface or `unknown`.
|
|
1128
|
+
|
|
1129
|
+
### MEDIUM Issues
|
|
1130
|
+
...
|
|
1131
|
+
|
|
1132
|
+
### Quality Score: X/100
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
JSON output must include: `{ success: true, data: { score, summary, issues: [...], scanned_files }, message, next_steps }`
|
|
1136
|
+
|
|
1137
|
+
## 5.5 Quality Score Calculation
|
|
1138
|
+
|
|
1139
|
+
```
|
|
1140
|
+
score = 100
|
|
1141
|
+
score -= (critical_count * 15)
|
|
1142
|
+
score -= (high_count * 5)
|
|
1143
|
+
score -= (medium_count * 2)
|
|
1144
|
+
score -= (low_count * 1)
|
|
1145
|
+
score = Math.max(0, Math.min(100, score))
|
|
1146
|
+
```
|
|
1147
|
+
|
|
1148
|
+
---
|
|
1149
|
+
|
|
1150
|
+
# SECTION 6: ENHANCED ccboot_init_project
|
|
1151
|
+
|
|
1152
|
+
## 6.1 What Changes
|
|
1153
|
+
|
|
1154
|
+
The existing `ccboot_init_project` tool must be updated to:
|
|
1155
|
+
|
|
1156
|
+
1. Use the new opinionated CLAUDE.md templates instead of generic placeholders
|
|
1157
|
+
2. Install ALL hook templates (format-on-write, lint-on-write, test-enforcement, danger-blocker, secret-detector) into `.claude/settings.json`
|
|
1158
|
+
3. Install ALL skill templates into `.claude/skills/`
|
|
1159
|
+
4. Install ALL agent templates into `.claude/agents/`
|
|
1160
|
+
5. Run `ccboot_audit_code_quality` as a post-init step and include the results in the output
|
|
1161
|
+
|
|
1162
|
+
## 6.2 Default Behavior Changes
|
|
1163
|
+
|
|
1164
|
+
When `ccboot_init_project` is called without explicit options:
|
|
1165
|
+
|
|
1166
|
+
- Detect tech stack from existing project files (package.json → Node.js, pyproject.toml → Python, pom.xml → Java, Cargo.toml → Rust)
|
|
1167
|
+
- Select the appropriate CLAUDE.md template based on detected stack
|
|
1168
|
+
- Install ALL hooks (all 5 hook templates)
|
|
1169
|
+
- Install ALL skills (all 5 skill templates)
|
|
1170
|
+
- Install ALL agents (all 4 agent templates)
|
|
1171
|
+
- Generate .claudeignore
|
|
1172
|
+
- Generate .claude/settings.json with appropriate permissions
|
|
1173
|
+
- Run the code quality audit and include results
|
|
1174
|
+
|
|
1175
|
+
The output message should list everything that was created and highlight any immediate code quality issues found.
|
|
1176
|
+
|
|
1177
|
+
---
|
|
1178
|
+
|
|
1179
|
+
# SECTION 7: TESTING REQUIREMENTS
|
|
1180
|
+
|
|
1181
|
+
## 7.1 Template Content Tests
|
|
1182
|
+
|
|
1183
|
+
For every template, write a test that:
|
|
1184
|
+
1. Renders the template with sample variables
|
|
1185
|
+
2. Verifies the output contains the "Mandatory Practices" section verbatim
|
|
1186
|
+
3. Verifies the output contains the "Self-Review Checklist" section verbatim
|
|
1187
|
+
4. Verifies no `{{variable}}` markers remain in the output (all were substituted)
|
|
1188
|
+
5. Verifies YAML frontmatter parses correctly (for skill templates)
|
|
1189
|
+
|
|
1190
|
+
## 7.2 Code Quality Audit Tests
|
|
1191
|
+
|
|
1192
|
+
Write tests for `ccboot_audit_code_quality` that:
|
|
1193
|
+
1. Create a temp directory with intentionally bad code (empty catch, any types, TODO comments)
|
|
1194
|
+
2. Run the audit tool
|
|
1195
|
+
3. Verify each check catches the intentional issues
|
|
1196
|
+
4. Verify the quality score calculation is correct
|
|
1197
|
+
5. Test both markdown and JSON output formats
|
|
1198
|
+
|
|
1199
|
+
## 7.3 Hook Template Tests
|
|
1200
|
+
|
|
1201
|
+
Write tests for each hook template that:
|
|
1202
|
+
1. Verify the JSON is valid
|
|
1203
|
+
2. Verify the event names are valid Claude Code lifecycle events
|
|
1204
|
+
3. Verify the matcher patterns are syntactically correct
|
|
1205
|
+
4. For the danger blocker: verify that test patterns are blocked (echo "rm -rf /" should match)
|
|
1206
|
+
5. For the secret detector: verify that test patterns are detected
|
|
1207
|
+
|
|
1208
|
+
---
|
|
1209
|
+
|
|
1210
|
+
# SECTION 8: PUBLISH v1.2.0
|
|
1211
|
+
|
|
1212
|
+
## 8.1 Version Bump
|
|
1213
|
+
Update package.json version to `1.2.0`.
|
|
1214
|
+
|
|
1215
|
+
## 8.2 CHANGELOG
|
|
1216
|
+
Add a CHANGELOG.md entry:
|
|
1217
|
+
|
|
1218
|
+
```markdown
|
|
1219
|
+
## [1.2.0] - 2026-XX-XX
|
|
1220
|
+
|
|
1221
|
+
### Added
|
|
1222
|
+
- Opinionated CLAUDE.md templates for Next.js, FastAPI, Spring Boot, React SPA, and monorepo projects
|
|
1223
|
+
- Enforcement hook templates: test-enforcement, format-on-write, lint-on-write, secret-detector
|
|
1224
|
+
- `ccboot_audit_code_quality` tool: scans for empty catch blocks, any types, TODO comments, hardcoded secrets, large files, long functions
|
|
1225
|
+
- Complete skill templates with detailed instructions: code-review, test-writer, security-scan, documentation, performance-audit
|
|
1226
|
+
- Complete agent templates: explore, plan, test-runner, security-auditor
|
|
1227
|
+
- Quality score calculation (0-100) in audit results
|
|
1228
|
+
|
|
1229
|
+
### Changed
|
|
1230
|
+
- `ccboot_init_project` now installs all enforcement hooks by default
|
|
1231
|
+
- `ccboot_init_project` runs code quality audit as post-init step
|
|
1232
|
+
- All CLAUDE.md templates now include mandatory practices and self-review checklist
|
|
1233
|
+
- All templates contain specific, actionable instructions instead of placeholders
|
|
1234
|
+
|
|
1235
|
+
### Fixed
|
|
1236
|
+
- Templates no longer contain TODO or placeholder text
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
## 8.3 README Update
|
|
1240
|
+
Update README.md to highlight the enforcement features prominently. Lead with: "ccboot doesn't just set up Claude Code — it prevents Claude from shipping broken code."
|
|
1241
|
+
|
|
1242
|
+
## 8.4 Publish
|
|
1243
|
+
```bash
|
|
1244
|
+
npm run build
|
|
1245
|
+
npm run test
|
|
1246
|
+
npm version 1.2.0
|
|
1247
|
+
npm publish
|
|
1248
|
+
```
|
|
1249
|
+
|
|
1250
|
+
---
|
|
1251
|
+
|
|
1252
|
+
## FINAL CHECKLIST
|
|
1253
|
+
|
|
1254
|
+
Before marking v1.2.0 as complete, verify ALL of the following:
|
|
1255
|
+
|
|
1256
|
+
- [ ] Every CLAUDE.md template contains the FULL "Mandatory Practices" section (copy-pasted from Section 1.3, not summarized)
|
|
1257
|
+
- [ ] Every CLAUDE.md template contains the FULL "Self-Review Checklist" section
|
|
1258
|
+
- [ ] Every skill template contains specific, step-by-step instructions (not "add appropriate content")
|
|
1259
|
+
- [ ] Every hook template contains a working shell command (not a placeholder)
|
|
1260
|
+
- [ ] The test-enforcement hook actually runs the test command and surfaces failures
|
|
1261
|
+
- [ ] The danger-blocker hook actually blocks rm -rf (exit code 2)
|
|
1262
|
+
- [ ] The secret-detector hook actually detects API key patterns (exit code 2)
|
|
1263
|
+
- [ ] ccboot_audit_code_quality scans for all 8 check categories
|
|
1264
|
+
- [ ] ccboot_init_project installs all hooks, skills, and agents by default
|
|
1265
|
+
- [ ] npm run build passes with zero errors
|
|
1266
|
+
- [ ] npm run test passes with all tests green
|
|
1267
|
+
- [ ] No TODO, FIXME, or placeholder text exists in any template
|
|
1268
|
+
- [ ] Version is 1.2.0 in package.json
|
|
1269
|
+
- [ ] CHANGELOG.md is updated
|
|
1270
|
+
- [ ] README.md highlights enforcement features
|
|
1271
|
+
|
|
1272
|
+
If ANY item above is not checked, v1.2.0 is NOT complete. Do not publish.
|