forgedev 1.1.0 → 1.2.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.
Files changed (64) hide show
  1. package/README.md +80 -7
  2. package/bin/devforge.js +11 -1
  3. package/docs/00-README.md +310 -0
  4. package/docs/01-universal-prompt-library.md +1049 -0
  5. package/docs/02-claude-code-mastery-playbook.md +283 -0
  6. package/docs/03-multi-agent-verification.md +565 -0
  7. package/docs/04-errata-and-verification-checklist.md +284 -0
  8. package/docs/05-universal-scaffolder-vision.md +452 -0
  9. package/docs/06-confidence-assessment-and-repo-prompt.md +407 -0
  10. package/docs/errata.md +58 -0
  11. package/docs/multi-agent-verification.md +66 -0
  12. package/docs/plans/.gitkeep +0 -0
  13. package/docs/playbook.md +95 -0
  14. package/docs/prompt-library.md +160 -0
  15. package/docs/uat/UAT_CHECKLIST.csv +9 -0
  16. package/docs/uat/UAT_TEMPLATE.md +163 -0
  17. package/package.json +10 -2
  18. package/src/claude-configurator.js +2 -0
  19. package/src/cli.js +16 -5
  20. package/src/doctor-prompts.js +9 -2
  21. package/src/doctor.js +19 -0
  22. package/src/index.js +7 -0
  23. package/src/update-check.js +49 -0
  24. package/src/update.js +33 -0
  25. package/src/utils.js +1 -1
  26. package/templates/auth/jwt-custom/backend/app/core/security.py.template +4 -1
  27. package/templates/backend/fastapi/backend/app/core/config.py.template +2 -2
  28. package/templates/base/docs/plans/.gitkeep +0 -0
  29. package/templates/base/docs/uat/UAT_CHECKLIST.csv.template +2 -0
  30. package/templates/base/docs/uat/UAT_TEMPLATE.md.template +22 -0
  31. package/templates/claude-code/agents/build-error-resolver.md +4 -4
  32. package/templates/claude-code/agents/code-quality-reviewer.md +1 -1
  33. package/templates/claude-code/agents/database-reviewer.md +2 -2
  34. package/templates/claude-code/agents/doc-updater.md +1 -1
  35. package/templates/claude-code/agents/harness-optimizer.md +26 -0
  36. package/templates/claude-code/agents/loop-operator.md +1 -1
  37. package/templates/claude-code/agents/product-strategist.md +124 -0
  38. package/templates/claude-code/agents/security-reviewer.md +1 -0
  39. package/templates/claude-code/agents/spec-validator.md +31 -1
  40. package/templates/claude-code/agents/uat-validator.md +6 -1
  41. package/templates/claude-code/claude-md/base.md +3 -2
  42. package/templates/claude-code/claude-md/nextjs.md +1 -1
  43. package/templates/claude-code/commands/build-fix.md +1 -1
  44. package/templates/claude-code/commands/code-review.md +6 -1
  45. package/templates/claude-code/commands/full-audit.md +61 -0
  46. package/templates/claude-code/commands/workflows.md +4 -0
  47. package/templates/claude-code/hooks/scripts/autofix-polyglot.mjs +28 -10
  48. package/templates/claude-code/hooks/scripts/autofix-python.mjs +11 -4
  49. package/templates/claude-code/hooks/scripts/autofix-typescript.mjs +11 -3
  50. package/templates/claude-code/hooks/scripts/guard-protected-files.mjs +2 -2
  51. package/templates/claude-code/skills/ai-prompts/SKILL.md +1 -0
  52. package/templates/claude-code/skills/fastapi/SKILL.md +1 -1
  53. package/templates/claude-code/skills/git-workflow/SKILL.md +3 -3
  54. package/templates/claude-code/skills/nextjs/SKILL.md +1 -1
  55. package/templates/claude-code/skills/playwright/SKILL.md +8 -7
  56. package/templates/claude-code/skills/security-api/SKILL.md +2 -2
  57. package/templates/claude-code/skills/security-web/SKILL.md +1 -0
  58. package/templates/database/sqlalchemy-postgres/.env.example +1 -0
  59. package/templates/infra/github-actions/.github/workflows/ci.yml.template +49 -0
  60. package/templates/testing/pytest/backend/tests/__init__.py +0 -0
  61. package/templates/testing/pytest/backend/tests/conftest.py.template +11 -0
  62. package/templates/testing/pytest/backend/tests/test_health.py.template +10 -0
  63. package/templates/testing/vitest/vitest.config.ts.template +18 -0
  64. package/CLAUDE.md +0 -38
@@ -0,0 +1,283 @@
1
+ # Claude Code Mastery Playbook
2
+ ## How to Structure Your Project for Production-Grade AI-Assisted Development
3
+
4
+ ---
5
+
6
+ ## The Core Problem
7
+
8
+ Your CLAUDE.md is too long and tries to do too much. Research shows Claude Code
9
+ reliably follows about 150 instructions — its own system prompt uses ~50, leaving
10
+ you ~100-150 for your project rules. If your CLAUDE.md exceeds that, instructions
11
+ get dropped uniformly.
12
+
13
+ The fix: move enforcement to hooks (deterministic), domain knowledge to skills
14
+ (on-demand), and keep CLAUDE.md lean (~150 lines of universally-applicable rules).
15
+
16
+ ---
17
+
18
+ ## Part 1: Lean CLAUDE.md (~150 Lines)
19
+
20
+ ### Structure: WHAT → WHY → HOW → RULES
21
+
22
+ ```markdown
23
+ # [Your Project Name]
24
+
25
+ ## WHAT (Project Map)
26
+ - [Tech stack: e.g., React 19 + TypeScript + FastAPI + PostgreSQL]
27
+ - /src — frontend source
28
+ - /backend — API and business logic
29
+ - /e2e — end-to-end tests
30
+ - [List key directories and what they contain]
31
+
32
+ ## WHY (Purpose)
33
+ - [One sentence: what the product does and who it's for]
34
+ - [Key architectural decisions worth knowing]
35
+
36
+ ## HOW (Verification Commands)
37
+ - Lint: [your lint command]
38
+ - Type check: [your type check command]
39
+ - Unit tests: [your test command]
40
+ - E2E tests: [your e2e command]
41
+ - Build: [your build command]
42
+
43
+ ## RULES (Only What the Agent Gets Wrong)
44
+ - [IMPORTANT: Rule that prevents a recurring mistake]
45
+ - [IMPORTANT: Another rule that prevents a recurring mistake]
46
+ - [Pattern to follow consistently]
47
+ - [Pattern to follow consistently]
48
+
49
+ ## Known Pitfalls (Recurring Bugs)
50
+ - [Bug pattern 1: what happens and how to avoid it]
51
+ - [Bug pattern 2: what happens and how to avoid it]
52
+
53
+ ## Build Order
54
+ [your project's dependency order, e.g.:]
55
+ models → backend logic → API endpoints → frontend API client → components → pages
56
+
57
+ ## Completion Protocol
58
+ Before reporting ANY task as done:
59
+ 1. Re-read the original instruction word-by-word
60
+ 2. Run all verification commands
61
+ 3. Trace every new wire: source → transport → consumer → render
62
+ 4. Show proof: file paths, what connects to what
63
+ ```
64
+
65
+ ### What NOT to Put in CLAUDE.md
66
+
67
+ - Data model schemas → move to a Skill
68
+ - Full API endpoint inventories → move to a Skill
69
+ - Detailed security checklists → move to a Skill
70
+ - Framework-specific patterns → move to directory-scoped CLAUDE.md
71
+ - Anything only relevant to one module → move to a Skill
72
+ - Anything that MUST happen every time → move to a Hook
73
+
74
+ ---
75
+
76
+ ## Part 2: Skills (On-Demand Knowledge)
77
+
78
+ Skills load only when Claude works on relevant files. Unlike CLAUDE.md
79
+ (loaded every session), skills don't waste context on irrelevant information.
80
+
81
+ ### Creating a Skill
82
+
83
+ ```
84
+ .claude/skills/
85
+ [skill-name]/
86
+ SKILL.md
87
+ ```
88
+
89
+ ### Example Skill Structure
90
+
91
+ ```markdown
92
+ ---
93
+ name: [skill-name]
94
+ description: [When Claude should load this skill — be specific]
95
+ ---
96
+
97
+ # [Skill Title]
98
+
99
+ ## [Section 1: Patterns]
100
+ [Patterns, conventions, and examples specific to this domain]
101
+
102
+ ## [Section 2: Anti-Patterns]
103
+ [What NOT to do]
104
+
105
+ ## [Section 3: Examples]
106
+ [Reference files or code examples]
107
+ ```
108
+
109
+ ### Common Skills to Create
110
+
111
+ | Skill | Description | Contains |
112
+ |-------|-------------|----------|
113
+ | `testing` | Testing patterns for your framework | Locator strategy, fixtures, anti-flakiness rules |
114
+ | `frontend` | Frontend component patterns | File structure, state management, API integration |
115
+ | `backend` | Backend service patterns | Endpoint templates, ORM patterns, validation |
116
+ | `security` | Full security checklist | Auth, input validation, output safety, secrets |
117
+ | `data-models` | Schema definitions | Entity definitions, relationships, migration patterns |
118
+ | `ai-integration` | AI/LLM prompt patterns | Prompt quality standards, output parsing, fallbacks |
119
+ | `[domain]` | Domain-specific knowledge | Business rules, terminology, workflow logic |
120
+
121
+ ---
122
+
123
+ ## Part 3: Directory-Scoped CLAUDE.md Files
124
+
125
+ Claude loads the nearest CLAUDE.md when working in a directory.
126
+
127
+ ```
128
+ CLAUDE.md # Root: universal rules (~150 lines)
129
+ backend/CLAUDE.md # Backend: language + framework rules
130
+ src/CLAUDE.md # Frontend: UI + component rules
131
+ e2e/CLAUDE.md # Tests: testing rules and patterns
132
+ ```
133
+
134
+ ---
135
+
136
+ ## Part 4: Hooks (Deterministic Enforcement)
137
+
138
+ See `multi-agent-verification.md` for the complete hook setup.
139
+
140
+ **Three essential hooks:**
141
+ 1. **PostToolUse** — auto-lint after every file edit
142
+ 2. **Stop** — run validation before marking done (exit 2 to block)
143
+ 3. **PreToolUse** — protect files that should never be modified
144
+
145
+ ---
146
+
147
+ ## Part 5: Validating Existing Work
148
+
149
+ ### Audit Commands (`.claude/commands/`)
150
+
151
+ | Command | File | Purpose |
152
+ |---------|------|---------|
153
+ | `/project:audit-spec` | `audit-spec.md` | Check implementation vs specification |
154
+ | `/project:audit-wiring` | `audit-wiring.md` | Find dead endpoints, methods, components |
155
+ | `/project:pre-pr` | `pre-pr.md` | Full validation before creating PR |
156
+ | `/project:audit-prompts` | `audit-prompts.md` | Score AI prompts (if applicable) |
157
+ | `/project:run-uat` | `run-uat.md` | Execute UAT scenarios, report coverage |
158
+ | `/project:audit-resilience` | `audit-resilience.md` | Check failover, health, graceful shutdown |
159
+ | `/project:pre-deploy` | `pre-deploy.md` | Staging/pre-production smoke test |
160
+
161
+ ---
162
+
163
+ ## Part 6: UAT (User Acceptance Testing)
164
+
165
+ ### Every Feature Needs a UAT Scenario
166
+
167
+ Before a feature is "done," it needs at minimum:
168
+
169
+ - **P0 scenarios:** critical user flows that MUST work (blocking)
170
+ - **P1 scenarios:** important flows that SHOULD work (non-blocking)
171
+ - **Each scenario:** steps, expected result, pass/fail status, tester, date
172
+
173
+ ### UAT Template (create at `docs/uat/UAT_TEMPLATE.md`)
174
+
175
+ ```markdown
176
+ # UAT Scenario Pack: [Project Name]
177
+
178
+ ## Pre-Conditions
179
+ - [ ] App is running (dev or staging)
180
+ - [ ] Test accounts exist
181
+ - [ ] Test data is seeded
182
+
183
+ ## UAT-001: [Feature] — Happy Path
184
+ **Priority:** P0
185
+ **Steps:**
186
+ 1. [action]
187
+ 2. [action]
188
+ **Expected:** [result]
189
+ **Status:** PASS / FAIL / BLOCKED / NOT RUN
190
+ **Tester:** ___ **Date:** ___
191
+ ```
192
+
193
+ ### UAT Tracking (create at `docs/uat/UAT_CHECKLIST.csv`)
194
+
195
+ ```csv
196
+ UAT_ID,Feature,Priority,Status,Tester,Date,Defect_ID,Notes
197
+ UAT-001,[Feature],P0,NOT RUN,,,,
198
+ ```
199
+
200
+ ### Gate Rule
201
+
202
+ No feature is "complete" unless:
203
+ - All P0 UAT scenarios are PASS, or
204
+ - A product-owner waiver is documented for each failed/blocked P0
205
+
206
+ ---
207
+
208
+ ## Part 7: Failover & Production Resilience
209
+
210
+ ### Every Backend Must Include
211
+
212
+ **Health check endpoint** (`/health` or `/healthz`):
213
+ - Returns 200 when the service is healthy
214
+ - Checks database connectivity
215
+ - Checks critical external service reachability
216
+
217
+ **Graceful shutdown:**
218
+ - Handle SIGTERM/SIGINT
219
+ - Stop accepting new requests
220
+ - Drain active connections
221
+ - Close database pools
222
+ - Exit cleanly
223
+
224
+ **Retry with backoff** for external calls:
225
+ - Database connections: retry 3x with exponential backoff
226
+ - External API calls: timeout (5-30s) + retry (2-3x) + fallback
227
+ - AI/LLM calls: timeout (60s) + retry (1x) + rule-based fallback
228
+
229
+ **Structured error responses** (never leak internals):
230
+ - Production: `{ "error": "Something went wrong", "code": "INTERNAL" }`
231
+ - Development: full stack trace (toggled by env var)
232
+
233
+ ### If Your App Uses AI/LLM
234
+
235
+ Additionally include:
236
+ - AI response validation (parse into typed schema, reject raw strings)
237
+ - Fallback when AI is unavailable (rule-based or informative error)
238
+ - Rate limit handling (queue or degrade gracefully)
239
+ - PII redaction before any data leaves your infrastructure
240
+
241
+ ---
242
+
243
+ ## Part 8: Frontend/Backend Separation
244
+
245
+ Always implement backend first, frontend second, with `/clear` between.
246
+
247
+ ```
248
+ BACKEND TASK: [description]. Do NOT touch frontend files.
249
+ ```
250
+ ```
251
+ FRONTEND TASK: [description]. Wire to existing API methods. Do NOT touch backend files.
252
+ ```
253
+
254
+ ---
255
+
256
+ ## Part 9: Complete Workflow
257
+
258
+ ```
259
+ SPEC → PLAN → REVIEW → BRANCH → BACKEND → FRONTEND → TESTS → UAT CHECK → VERIFY → PR → PRE-DEPLOY → SHIP
260
+ ```
261
+
262
+ Each step uses the corresponding prompt from `universal-prompt-library.md`.
263
+
264
+ ---
265
+
266
+ ## Quick Reference
267
+
268
+ | What | Where | Loaded |
269
+ |------|-------|--------|
270
+ | Universal rules (~150 lines) | `CLAUDE.md` (root) | Every session |
271
+ | Backend rules | `backend/CLAUDE.md` | In backend/ |
272
+ | Frontend rules | `src/CLAUDE.md` | In src/ |
273
+ | Test rules | `e2e/CLAUDE.md` | In e2e/ |
274
+ | Domain knowledge | `.claude/skills/` | On demand |
275
+ | Lint enforcement | PostToolUse hook | Every edit |
276
+ | Validation gate | Stop hook | Every completion |
277
+ | File protection | PreToolUse hook | Every write |
278
+ | Spec audits | `.claude/commands/` | On demand |
279
+ | Agent reviews | `.claude/agents/` | On demand |
280
+ | UAT scenarios | `docs/uat/UAT_TEMPLATE.md` | Per feature |
281
+ | UAT tracking | `docs/uat/UAT_CHECKLIST.csv` | Per release |
282
+ | Resilience audit | `/project:audit-resilience` | Before deploy |
283
+ | Pre-deploy smoke | `/project:pre-deploy` | Before deploy |