codex-genesis-harness 0.1.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 (56) hide show
  1. package/.codex/skills/project-genesis-harness/SKILL.md +727 -0
  2. package/.codex/skills/project-genesis-harness/agents/openai.yaml +9 -0
  3. package/.codex/skills/project-genesis-harness/references/planning-schema.md +35 -0
  4. package/.codex/skills/project-genesis-harness/references/quality-rubric.md +21 -0
  5. package/.codex/skills/project-genesis-harness/references/research-rubric.md +41 -0
  6. package/.codex/skills/project-genesis-harness/references/workflows.md +33 -0
  7. package/.codex/skills/project-genesis-harness/resources/agents-template.md +27 -0
  8. package/.codex/skills/project-genesis-harness/resources/api-docs-template.md +32 -0
  9. package/.codex/skills/project-genesis-harness/resources/architecture-template.md +30 -0
  10. package/.codex/skills/project-genesis-harness/resources/audit-template.md +26 -0
  11. package/.codex/skills/project-genesis-harness/resources/bug-template.md +34 -0
  12. package/.codex/skills/project-genesis-harness/resources/check-template.md +21 -0
  13. package/.codex/skills/project-genesis-harness/resources/conventions-template.md +42 -0
  14. package/.codex/skills/project-genesis-harness/resources/decision-template.md +33 -0
  15. package/.codex/skills/project-genesis-harness/resources/design-template.md +26 -0
  16. package/.codex/skills/project-genesis-harness/resources/escalation-template.md +21 -0
  17. package/.codex/skills/project-genesis-harness/resources/feature-template.md +49 -0
  18. package/.codex/skills/project-genesis-harness/resources/integrations-template.md +32 -0
  19. package/.codex/skills/project-genesis-harness/resources/journeys-template.md +13 -0
  20. package/.codex/skills/project-genesis-harness/resources/lessons-learned-template.md +12 -0
  21. package/.codex/skills/project-genesis-harness/resources/observability-template.md +34 -0
  22. package/.codex/skills/project-genesis-harness/resources/phase-template.md +34 -0
  23. package/.codex/skills/project-genesis-harness/resources/pitfalls-template.md +22 -0
  24. package/.codex/skills/project-genesis-harness/resources/planning-tree-template.md +39 -0
  25. package/.codex/skills/project-genesis-harness/resources/project-template.md +38 -0
  26. package/.codex/skills/project-genesis-harness/resources/quality-score-template.md +11 -0
  27. package/.codex/skills/project-genesis-harness/resources/requirements-template.md +26 -0
  28. package/.codex/skills/project-genesis-harness/resources/research-template.md +26 -0
  29. package/.codex/skills/project-genesis-harness/resources/review-template.md +22 -0
  30. package/.codex/skills/project-genesis-harness/resources/spec-changelog-template.md +6 -0
  31. package/.codex/skills/project-genesis-harness/resources/stack-template.md +33 -0
  32. package/.codex/skills/project-genesis-harness/resources/verification-template.md +26 -0
  33. package/.codex/skills/project-genesis-harness/scripts/check-architecture-boundaries.sh +23 -0
  34. package/.codex/skills/project-genesis-harness/scripts/check-docs-sync.sh +24 -0
  35. package/.codex/skills/project-genesis-harness/scripts/check-no-debug-logs.sh +21 -0
  36. package/.codex/skills/project-genesis-harness/scripts/check-required-planning-files.sh +46 -0
  37. package/.codex/skills/project-genesis-harness/scripts/check-spec-changelog.sh +24 -0
  38. package/.codex/skills/project-genesis-harness/scripts/check-task-tracking.sh +25 -0
  39. package/.codex/skills/project-genesis-harness/scripts/create-adr.sh +74 -0
  40. package/.codex/skills/project-genesis-harness/scripts/create-bug.sh +160 -0
  41. package/.codex/skills/project-genesis-harness/scripts/create-feature.sh +217 -0
  42. package/.codex/skills/project-genesis-harness/scripts/detect-stack.sh +26 -0
  43. package/.codex/skills/project-genesis-harness/scripts/init-planning.sh +719 -0
  44. package/.codex/skills/project-genesis-harness/scripts/list-changed-files.sh +12 -0
  45. package/.codex/skills/project-genesis-harness/scripts/run-verification.sh +47 -0
  46. package/.codex/skills/project-genesis-harness/scripts/update-state.sh +33 -0
  47. package/.codex-plugin/plugin.json +35 -0
  48. package/LICENSE +22 -0
  49. package/README.md +181 -0
  50. package/VERSION +2 -0
  51. package/bin/genesis-harness.js +164 -0
  52. package/package.json +37 -0
  53. package/scripts/install.sh +69 -0
  54. package/scripts/run-evals.sh +52 -0
  55. package/scripts/uninstall.sh +52 -0
  56. package/scripts/verify.sh +109 -0
@@ -0,0 +1,727 @@
1
+ ---
2
+ name: project-genesis-harness
3
+ description: Initialize and operate a project planning harness for Codex. Use this skill when the user types /init, asks to create a new project, add a feature, fix a bug, plan work, generate tests first, update docs, track phases, review changes, audit a repository, or manage architecture decisions.
4
+ ---
5
+
6
+ # Project Genesis Harness
7
+
8
+ This skill turns Codex into a project operating harness.
9
+
10
+ Codex must not behave like a simple code generator. Codex must behave like a disciplined engineering agent that understands the project before coding, confirms missing product intent, researches the repository and best practices, plans before implementation, defines tests or verification first, keeps docs synchronized with code, tracks tasks explicitly, records bug lessons, maintains architecture diagrams, reviews changed files after implementation, removes unnecessary changes, and escalates when human judgment is required.
11
+
12
+ ## Core Principle
13
+
14
+ Do not code first.
15
+
16
+ Correct order:
17
+
18
+ ```txt
19
+ Confirm intent
20
+ -> Inspect repository
21
+ -> Initialize planning
22
+ -> Research
23
+ -> Decide
24
+ -> Diagram
25
+ -> Plan
26
+ -> Test contract
27
+ -> Implement
28
+ -> Verify
29
+ -> Review
30
+ -> Sync docs
31
+ -> Track completion
32
+ -> Report
33
+ ```
34
+
35
+ Never skip confirmation when intent is unclear, research, planning, test or verification, docs synchronization, task tracking, or review.
36
+
37
+ ## Supported Commands
38
+
39
+ Support these user intents:
40
+
41
+ ```txt
42
+ /init
43
+ /new-feature <description>
44
+ /fix-bug <description>
45
+ /plan <description>
46
+ /audit
47
+ /review
48
+ /status
49
+ ```
50
+
51
+ If the user does not type an exact command but clearly asks for one of these workflows, infer the correct workflow.
52
+
53
+ ## Resource And Script Map
54
+
55
+ Bundled resources live under `resources/`. Use them as starting content when creating `.planning/` files:
56
+
57
+ - `planning-tree-template.md`: required `.planning/` tree.
58
+ - `agents-template.md`: concise root `AGENTS.md`.
59
+ - `project-template.md` through `check-template.md`: starter content for project, phase, feature, bug, ADR, research, review, verification, audit, and check files.
60
+
61
+ Bundled references live under `references/`. Load them only when needed:
62
+
63
+ - `references/workflows.md`: command routing, readiness gate, and completion gate.
64
+ - `references/planning-schema.md`: detailed `.planning/` file meanings and required subtrees.
65
+ - `references/research-rubric.md`: local/external evidence format for research.
66
+ - `references/quality-rubric.md`: scoring rubric for `QUALITY_SCORE.md`.
67
+
68
+ Bundled scripts live under `scripts/`. Prefer copying or adapting these into `.planning/scripts/` or project scripts during `/init`:
69
+
70
+ - `init-planning.sh`: creates `AGENTS.md` and the `.planning/` tree.
71
+ - `create-feature.sh`: scaffolds `.planning/features/NNN-feature-slug/`.
72
+ - `create-bug.sh`: scaffolds `.planning/bugs/NNN-bug-slug/`.
73
+ - `create-adr.sh`: scaffolds `.planning/decisions/ADR-NNN-slug.md`.
74
+ - `update-state.sh`: updates common fields in `.planning/STATE.md`.
75
+ - `detect-stack.sh`: inspects repository stack clues.
76
+ - `list-changed-files.sh`: lists git changes when git is available.
77
+ - `run-verification.sh`: runs detected lint/typecheck/test/build checks.
78
+ - `check-docs-sync.sh`, `check-task-tracking.sh`, `check-no-debug-logs.sh`, `check-spec-changelog.sh`, `check-required-planning-files.sh`, `check-architecture-boundaries.sh`: mechanical harness checks.
79
+
80
+ ## `/init` Workflow
81
+
82
+ When the user types `/init`, initialize the project planning harness. Before creating files, inspect the current repository.
83
+
84
+ Look for:
85
+
86
+ - `README.md`
87
+ - `AGENTS.md`
88
+ - `package.json`
89
+ - `composer.json`
90
+ - `pyproject.toml`
91
+ - `requirements.txt`
92
+ - `Cargo.toml`
93
+ - `go.mod`
94
+ - `*.csproj` or `*.sln`
95
+ - `Dockerfile`
96
+ - `docker-compose.yml`
97
+ - `src/` or `app/`
98
+ - existing docs
99
+ - existing tests
100
+ - existing API routes
101
+ - existing database schema
102
+ - existing architecture clues
103
+
104
+ ### Confirmation Rule
105
+
106
+ If there is enough information to infer the product idea, summarize the detected project brief and ask for confirmation:
107
+
108
+ ```md
109
+ ## Detected Project Brief
110
+
111
+ Product:
112
+ Target users:
113
+ Core features:
114
+ Tech stack:
115
+ Integrations:
116
+ First milestone:
117
+ Out of scope:
118
+ Assumptions:
119
+
120
+ Please confirm before I initialize `.planning/`.
121
+ ```
122
+
123
+ If the app idea is missing or ambiguous, stop and ask:
124
+
125
+ 1. What application are we building?
126
+ 2. Who are the target users?
127
+ 3. What are the core features?
128
+ 4. What tech stack do you prefer?
129
+ 5. What integrations are required?
130
+ 6. What is explicitly out of scope?
131
+ 7. What is the first milestone?
132
+ 8. Are there any design, architecture, security, or deployment constraints?
133
+
134
+ Do not create implementation code until the project idea is confirmed.
135
+
136
+ After confirmation, create root `AGENTS.md`, the `.planning/` structure, initial planning files, base Mermaid diagrams, the first roadmap phase, initial checks, and the initial quality score. Use `scripts/init-planning.sh` when it fits the repository.
137
+
138
+ `scripts/init-planning.sh` must only be run after confirmation, using `--confirmed` or `PROJECT_BRIEF_CONFIRMED=1`. Do not bypass this guard unless the user explicitly asks to create a blank harness with unknown product details.
139
+
140
+ ## Root `AGENTS.md`
141
+
142
+ Create a short root-level `AGENTS.md`. It is a table of contents for Codex, not a giant instruction dump. It must point Codex to the real project knowledge in `.planning/`.
143
+
144
+ Minimum contents:
145
+
146
+ ```md
147
+ # AGENTS.md
148
+
149
+ This repository uses the Project Genesis Harness.
150
+
151
+ Before doing feature work, bug fixes, refactors, or architecture changes, read:
152
+
153
+ 1. `.planning/SUMMARY.md`
154
+ 2. `.planning/STATE.md`
155
+ 3. `.planning/PROJECT.md`
156
+ 4. `.planning/REQUIREMENTS.md`
157
+ 5. `.planning/STACK.md`
158
+ 6. `.planning/ARCHITECTURE.md`
159
+ 7. `.planning/CONVENTIONS.md`
160
+ 8. `.planning/PITFALLS.md`
161
+ 9. `.planning/LESSONS_LEARNED.md`
162
+
163
+ For new features, create a folder under `.planning/features/`.
164
+ For bug fixes, create a folder under `.planning/bugs/`.
165
+ For major decisions, create an ADR under `.planning/decisions/`.
166
+
167
+ Do not claim completion unless verification passed, docs were synchronized, task tracking was updated, and changed files were reviewed.
168
+ ```
169
+
170
+ Keep `AGENTS.md` concise.
171
+
172
+ ## Required `.planning/` Architecture
173
+
174
+ Create the full tree described in `resources/planning-tree-template.md`, including:
175
+
176
+ - core docs: `PROJECT.md`, `REQUIREMENTS.md`, `ROADMAP.md`, `STATE.md`, `STACK.md`, `ARCHITECTURE.md`, `DESIGN.md`, `API_DOCS.md`, `INTEGRATIONS.md`, `CONVENTIONS.md`, `PITFALLS.md`, `LESSONS_LEARNED.md`, `SPEC_CHANGELOG.md`, `FEATURE_INDEX.md`, `CHANGE_IMPACT_MATRIX.md`, `QUALITY_SCORE.md`, `ESCALATION.md`, `OBSERVABILITY.md`, `SMOKE_TESTS.md`, `JOURNEYS.md`, `SUMMARY.md`, `config.json`
177
+ - diagrams: `system-context.mmd`, `container-architecture.mmd`, `database-erd.mmd`, `deployment-flow.mmd`, `roadmap-flow.mmd`
178
+ - research, decisions, phases, features, bugs, audits, checks, quick, codebase, and templates folders.
179
+
180
+ ## Meaning Of Core Files
181
+
182
+ - `PROJECT.md`: project identity, target users, value, scope, out of scope, constraints, assumptions, current milestone, success criteria.
183
+ - `REQUIREMENTS.md`: functional and non-functional requirements, user stories, acceptance criteria, edge cases, known unknowns.
184
+ - `ROADMAP.md`: milestones, phases, dependencies, status, acceptance criteria.
185
+ - `STATE.md`: current phase, active feature or bug, last completed task, next task, blockers, latest verification.
186
+ - `STACK.md`: language, framework, runtime, database, package manager, test framework, lint/typecheck tools, deployment target, versions, local commands.
187
+ - `ARCHITECTURE.md`: architecture, module boundaries, data flow, dependency direction, service boundaries, principles, forbidden patterns.
188
+ - `DESIGN.md`: UX principles, screens/pages, component conventions, state management, accessibility, constraints.
189
+ - `API_DOCS.md`: endpoints, examples, errors, auth, versioning.
190
+ - `INTEGRATIONS.md`: services, SDKs, env vars, secrets, failure handling, fallbacks, rate limits.
191
+ - `CONVENTIONS.md`: naming, folders, style, errors, logging, tests, API rules, security rules, patterns to follow and avoid.
192
+ - `PITFALLS.md`: common mistakes, risky areas, fragile dependencies, historical warnings.
193
+ - `LESSONS_LEARNED.md`: fixed bugs, root causes, failed assumptions, correct patterns, prevention rules, changed files, verification evidence.
194
+ - `SPEC_CHANGELOG.md`: every spec-affecting change with date/time, reason, impacted docs, impacted tests, migration notes.
195
+ - `FEATURE_INDEX.md`: table of features with status, phase, path, notes.
196
+ - `CHANGE_IMPACT_MATRIX.md`: mapping from change types to docs that must update.
197
+ - `QUALITY_SCORE.md`: quality areas and scores; update during `/audit`, `/review`, major features, and major bug fixes.
198
+ - `ESCALATION.md`: when Codex must stop and ask the user.
199
+ - `OBSERVABILITY.md`: logs, metrics, traces, errors, health checks, debug commands, local inspection.
200
+ - `JOURNEYS.md`: important user journeys with expected UI/API/DB/log state and verification.
201
+ - `SMOKE_TESTS.md`: minimal checks proving the app is alive.
202
+
203
+ ## Task Tracking Rule
204
+
205
+ Every phase, feature, bug, audit, and task must use checkbox tracking:
206
+
207
+ ```txt
208
+ [ ] not started
209
+ [~] in progress
210
+ [x] completed
211
+ [!] blocked
212
+ ```
213
+
214
+ When a task is started:
215
+
216
+ 1. update checkbox from `[ ]` to `[~]`
217
+ 2. update `.planning/STATE.md`
218
+
219
+ When a task is completed:
220
+
221
+ 1. update checkbox from `[~]` or `[ ]` to `[x]`
222
+ 2. update `.planning/STATE.md`
223
+ 3. update related phase `TASKS.md`
224
+ 4. update related feature or bug `TASKS.md` if applicable
225
+ 5. update `.planning/SUMMARY.md`
226
+
227
+ Never claim a task is complete unless tracking files were updated.
228
+
229
+ ## Definition Of Ready
230
+
231
+ Feature, bug, phase, audit, and architecture work is ready to implement only when:
232
+
233
+ - [x] product intent or bug report is clear enough to avoid guessing
234
+ - [x] required planning docs were read
235
+ - [x] relevant local codebase patterns were researched
236
+ - [x] best-practice research is recorded or internet unavailability is stated
237
+ - [x] impact on API, data, UI, auth, integrations, config, docs, and tests is known
238
+ - [x] test contract or verification contract exists
239
+ - [x] diagram or ADR impact is handled when architecture changes
240
+ - [x] escalation concerns were resolved or explicitly recorded
241
+
242
+ If any item is false, do not implement. Update tracking to `[!]` or ask the user.
243
+
244
+ ## Definition Of Done
245
+
246
+ Work is done only when:
247
+
248
+ - [x] implementation is complete and scoped to the plan
249
+ - [x] automated tests or documented verification passed
250
+ - [x] docs were synchronized, or no-docs-needed was justified
251
+ - [x] task tracking moved from `[ ]` or `[~]` to `[x]`
252
+ - [x] `STATE.md`, `SUMMARY.md`, and feature/bug/phase tracking are current
253
+ - [x] changed files were reviewed
254
+ - [x] debug logs, dead code, unrelated edits, and unnecessary files were removed
255
+ - [x] risks and follow-up tasks are recorded
256
+
257
+ Never use completion language until the Definition of Done is satisfied.
258
+
259
+ ## Research Rule
260
+
261
+ Before planning or implementing any non-trivial task:
262
+
263
+ 1. Research the existing codebase.
264
+ 2. Identify similar patterns already present.
265
+ 3. Research best practices using official docs, Google, GitHub, or reputable sources when internet access is available.
266
+ 4. Record findings in `.planning/research/`.
267
+ 5. Mention evidence in the plan.
268
+
269
+ The plan must state what will change, where, why, the pattern or best practice supporting the change, risks, and verification commands. If internet access is unavailable, state this clearly and rely on local codebase research. Never invent external research results.
270
+
271
+ Use this evidence format in `.planning/research/`:
272
+
273
+ ```md
274
+ ## Research: <topic>
275
+
276
+ Date:
277
+ Question:
278
+
279
+ ## Local Evidence
280
+
281
+ | File / Command | Finding | Impact |
282
+ |---|---|---|
283
+ | `path/to/file` | TBD | TBD |
284
+
285
+ ## External Evidence
286
+
287
+ | Source | Date Checked | Finding | Impact |
288
+ |---|---|---|---|
289
+ | URL or official doc name | YYYY-MM-DD | TBD | TBD |
290
+
291
+ ## Decision Impact
292
+
293
+ - [ ] TBD
294
+
295
+ ## Confidence / Gaps
296
+
297
+ - [ ] TBD
298
+ ```
299
+
300
+ External findings must include a source name or URL and date checked. If browsing is unavailable, write `External Evidence: unavailable in this environment` and do not fabricate sources.
301
+
302
+ ## Mermaid Diagram Rule
303
+
304
+ Use Mermaid diagrams as architecture source of truth. Before implementation, create or update diagrams when the task affects architecture, data flow, API flow, database schema, deployment, integration, phase dependency, feature workflow, background jobs, or auth.
305
+
306
+ Required base diagrams:
307
+
308
+ ```txt
309
+ .planning/diagrams/system-context.mmd
310
+ .planning/diagrams/container-architecture.mmd
311
+ .planning/diagrams/database-erd.mmd
312
+ .planning/diagrams/deployment-flow.mmd
313
+ .planning/diagrams/roadmap-flow.mmd
314
+ ```
315
+
316
+ A feature must also have `.planning/features/NNN-feature-name/DIAGRAM.mmd`. Do not implement architecture-changing work before updating the relevant diagram.
317
+
318
+ ## `/new-feature` Workflow
319
+
320
+ When adding a new feature, first read:
321
+
322
+ ```txt
323
+ .planning/SUMMARY.md
324
+ .planning/STATE.md
325
+ .planning/PITFALLS.md
326
+ .planning/LESSONS_LEARNED.md
327
+ .planning/CONVENTIONS.md
328
+ .planning/ARCHITECTURE.md
329
+ .planning/STACK.md
330
+ ```
331
+
332
+ Then research local patterns and best practices. Create:
333
+
334
+ ```txt
335
+ .planning/features/NNN-feature-slug/
336
+ ├── SPEC.md
337
+ ├── IMPACT.md
338
+ ├── PLAN.md
339
+ ├── TEST_CONTRACT.md
340
+ ├── TASKS.md
341
+ ├── VERIFICATION.md
342
+ ├── REVIEW.md
343
+ └── DIAGRAM.mmd
344
+ ```
345
+
346
+ `SPEC.md` must include summary, user story, expected behavior, edge cases, out of scope, and acceptance criteria.
347
+
348
+ `IMPACT.md` must answer whether the feature affects API, database, UI, auth/security, integrations, environment variables, architecture, docs, tests, migrations, or existing user journeys.
349
+
350
+ `PLAN.md` must include files to create/change, why each changes, implementation steps, test strategy, docs to update, diagrams to update, risks, rollback plan, and verification commands. Each planned file change must use:
351
+
352
+ ```md
353
+ ### File: `path/to/file`
354
+
355
+ Change:
356
+ Why:
357
+ Risk:
358
+ Test:
359
+ Docs impact:
360
+ ```
361
+
362
+ `TEST_CONTRACT.md` must include normal input/output, edge cases, invalid inputs, expected errors, acceptance tests, and manual verification if automated tests are unavailable.
363
+
364
+ `TASKS.md` must include checkbox tasks for required doc reads, pitfalls, lessons, codebase research, best-practice research, diagram, spec, impact, plan, test contract, failing tests or verification, implementation, verification, docs, review, cleanup, state, feature index, spec changelog, and completion tracking.
365
+
366
+ Prefer `scripts/create-feature.sh` for the initial folder and file scaffold, then fill the generated files with task-specific content.
367
+
368
+ ## `/fix-bug` Workflow
369
+
370
+ Before fixing a bug, always read:
371
+
372
+ ```txt
373
+ .planning/PITFALLS.md
374
+ .planning/LESSONS_LEARNED.md
375
+ .planning/CONVENTIONS.md
376
+ .planning/ARCHITECTURE.md
377
+ .planning/STACK.md
378
+ ```
379
+
380
+ Then reproduce and diagnose before changing code. Create:
381
+
382
+ ```txt
383
+ .planning/bugs/NNN-bug-slug/
384
+ ├── REPORT.md
385
+ ├── ROOT_CAUSE.md
386
+ ├── PLAN.md
387
+ ├── TEST_CONTRACT.md
388
+ ├── TASKS.md
389
+ ├── VERIFICATION.md
390
+ └── REVIEW.md
391
+ ```
392
+
393
+ Bug `TASKS.md` must include checkboxes for reading pitfalls and lessons, reproducing the bug, identifying root cause, writing regression test or verification, fixing, verification, updating lessons learned, updating docs if behavior changed, reviewing changed files, updating state, and updating spec changelog if needed.
394
+
395
+ Prefer `scripts/create-bug.sh` for the initial folder and file scaffold, then fill the generated files with task-specific evidence.
396
+
397
+ After fixing the bug, append to `.planning/LESSONS_LEARNED.md`:
398
+
399
+ ```md
400
+ ## Bug: <name>
401
+
402
+ Date:
403
+ Root cause:
404
+ Failed assumption:
405
+ Correct pattern:
406
+ Prevention rule:
407
+ Files changed:
408
+ Verification:
409
+ ```
410
+
411
+ Never fix the same type of bug without checking `LESSONS_LEARNED.md`.
412
+
413
+ ## `/plan` Workflow
414
+
415
+ When the user asks for a plan:
416
+
417
+ 1. Read required planning docs.
418
+ 2. Research the codebase.
419
+ 3. Research best practices if internet is available.
420
+ 4. Create or update relevant diagrams.
421
+ 5. Write a plan with:
422
+
423
+ ```md
424
+ ## Goal
425
+
426
+ ## Current State
427
+
428
+ ## Research Findings
429
+
430
+ ## Files to Change
431
+
432
+ ### File: `path/to/file`
433
+ Change:
434
+ Why:
435
+ Risk:
436
+ Test:
437
+ Docs impact:
438
+
439
+ ## Test Contract
440
+
441
+ ## Verification Commands
442
+
443
+ ## Docs to Update
444
+
445
+ ## Risks
446
+
447
+ ## Rollback Plan
448
+ ```
449
+
450
+ Do not implement unless the user asks to implement or the workflow clearly requires implementation.
451
+
452
+ ## `/audit` Workflow
453
+
454
+ When the user asks for `/audit`, perform a harness audit. Review architecture drift, docs freshness, dead code, duplicated logic, dependency risk, security risk, missing tests, missing diagrams, stale decisions, stale feature tasks, and stale phase tasks.
455
+
456
+ Update:
457
+
458
+ ```txt
459
+ .planning/audits/architecture-drift.md
460
+ .planning/audits/dependency-audit.md
461
+ .planning/audits/dead-code-audit.md
462
+ .planning/audits/security-audit.md
463
+ .planning/audits/docs-freshness-audit.md
464
+ .planning/QUALITY_SCORE.md
465
+ .planning/STATE.md
466
+ .planning/SUMMARY.md
467
+ ```
468
+
469
+ Create follow-up tasks if needed. Do not make risky code changes during `/audit` unless explicitly requested.
470
+
471
+ ## `/review` Workflow
472
+
473
+ When the user asks for `/review`, review changed files. Check unnecessary files, unused code, duplicated logic, debug logs, poor naming, missing tests, missing docs update, architecture drift, convention violations, security risks, performance risks, and best-practice improvements.
474
+
475
+ Record the review in the related feature `REVIEW.md`, related phase `REVIEW.md`, and `.planning/SUMMARY.md`. If problems are found, create tracked follow-up tasks.
476
+
477
+ ## `/status` Workflow
478
+
479
+ When the user asks for `/status`, summarize current project state, current phase, active feature or bug, completed tasks, blocked tasks, latest verification result, next recommended task, and docs that may be stale.
480
+
481
+ Use `.planning/STATE.md`, `.planning/ROADMAP.md`, `.planning/FEATURE_INDEX.md`, and `.planning/SUMMARY.md`. Do not guess.
482
+
483
+ ## Test-First Rule
484
+
485
+ Before implementation:
486
+
487
+ 1. create or update tests
488
+ 2. define input/output expectations
489
+ 3. define edge cases
490
+ 4. run tests and confirm they fail for the expected reason
491
+
492
+ If no test framework exists, create a minimal verification script, document manual verification steps, and add a test framework recommendation to `STACK.md` or `ROADMAP.md`. Never claim completion without verification.
493
+
494
+ ## Implementation Rule
495
+
496
+ During implementation, make the smallest working change. Follow `CONVENTIONS.md`, `ARCHITECTURE.md`, and `STACK.md`. Reuse existing utilities. Avoid unrelated refactors, hidden dependencies, public behavior changes without docs, integrations without `INTEGRATIONS.md`, deleting files without justification, and destructive migrations without user confirmation.
497
+
498
+ ## Docs Sync Rule
499
+
500
+ Whenever implementation changes behavior, API, data model, UI, integration, architecture, convention, config, environment variable, security behavior, or requirement, update all related docs.
501
+
502
+ Possible docs include:
503
+
504
+ - `.planning/REQUIREMENTS.md`
505
+ - `.planning/API_DOCS.md`
506
+ - `.planning/ARCHITECTURE.md`
507
+ - `.planning/DESIGN.md`
508
+ - `.planning/INTEGRATIONS.md`
509
+ - `.planning/STACK.md`
510
+ - `.planning/CONVENTIONS.md`
511
+ - `.planning/ROADMAP.md`
512
+ - `.planning/STATE.md`
513
+ - `.planning/SPEC_CHANGELOG.md`
514
+ - `.planning/QUALITY_SCORE.md`
515
+ - `.planning/OBSERVABILITY.md`
516
+ - `.planning/SMOKE_TESTS.md`
517
+ - `.planning/JOURNEYS.md`
518
+ - `.planning/diagrams/*.mmd`
519
+ - `.planning/decisions/*.md`
520
+ - `.planning/features/*/*.md`
521
+ - `.planning/phases/*/*.md`
522
+ - `.planning/bugs/*/*.md`
523
+
524
+ If no docs need updating, explicitly explain why in the final report.
525
+
526
+ ## Decision Record Rule
527
+
528
+ Use ADR files for important decisions. Create files like `.planning/decisions/ADR-003-use-postgres.md`.
529
+
530
+ Each ADR must include status, context, decision, alternatives considered, consequences, risks, mitigation, and verification evidence.
531
+
532
+ Use ADRs for tech stack decisions, database choice, auth strategy, architecture boundaries, external integrations, major library choices, deployment strategy, security strategy, and API versioning strategy.
533
+
534
+ Prefer `scripts/create-adr.sh` for ADR numbering and starter content.
535
+
536
+ ## Quality Rubric
537
+
538
+ Use this rubric when updating `QUALITY_SCORE.md`:
539
+
540
+ | Score | Meaning |
541
+ |---:|---|
542
+ | 0 | Unknown, absent, or not evaluated |
543
+ | 2 | Known major gaps with no mitigation |
544
+ | 4 | Basic structure exists but is inconsistent or mostly manual |
545
+ | 6 | Working baseline with known gaps and follow-up tasks |
546
+ | 8 | Strong, verified, documented, and mostly automated |
547
+ | 10 | Mature, automated, documented, reviewed, and low-risk |
548
+
549
+ Area guidance:
550
+
551
+ - Architecture: module boundaries, dependency direction, diagrams, ADRs, forbidden patterns.
552
+ - Tests: regression coverage, smoke tests, edge cases, failing-first evidence, CI/local repeatability.
553
+ - Docs Sync: docs updated with behavior changes, changelog entries, impact matrix compliance.
554
+ - Security: auth, secrets, data protection, dependency risk, destructive-operation safeguards.
555
+ - Maintainability: naming, duplication, dead code, conventions, file/module size, refactor risk.
556
+ - Observability: logs, metrics, traces, errors, health checks, debug commands, inspection workflow.
557
+
558
+ ## Mechanical Checks Rule
559
+
560
+ When possible, use or create scripts that check harness consistency. Scripts should include:
561
+
562
+ ```txt
563
+ scripts/check-docs-sync.sh
564
+ scripts/check-task-tracking.sh
565
+ scripts/check-no-debug-logs.sh
566
+ scripts/check-spec-changelog.sh
567
+ scripts/check-required-planning-files.sh
568
+ scripts/check-architecture-boundaries.sh
569
+ scripts/run-verification.sh
570
+ ```
571
+
572
+ These scripts do not need to be perfect, but they should provide practical guardrails. Document all checks in `.planning/checks/CHECKS.md`.
573
+
574
+ ## Escalation Rule
575
+
576
+ Stop and ask the user before continuing when product intent is unclear, requirements conflict, a public API breaking change is required, destructive migration is required, deleting user data is possible, credentials or secrets are missing, paid external services are required, a security tradeoff is unclear, legal/compliance concern exists, or the change conflicts with existing architecture decisions.
577
+
578
+ Record escalations in `.planning/ESCALATION.md`.
579
+
580
+ ## Review Rule
581
+
582
+ After tests pass, review all changed files. Check unnecessary files, unused code, duplicated logic, debug logs, poor naming, missing tests, missing docs update, architecture drift, convention violations, security risks, performance risks, and best-practice improvements.
583
+
584
+ Record the review in the related feature `REVIEW.md`, bug `REVIEW.md`, phase `REVIEW.md`, and `.planning/SUMMARY.md`.
585
+
586
+ ## Completion Report Rule
587
+
588
+ Final response must include:
589
+
590
+ ```md
591
+ ## Completed
592
+
593
+ - What was done
594
+
595
+ ## Planning Updated
596
+
597
+ - Files updated under `.planning/`
598
+
599
+ ## Code Changed
600
+
601
+ - Files changed
602
+
603
+ ## Tests / Verification
604
+
605
+ - Tests added/updated
606
+ - Commands run
607
+ - Result
608
+
609
+ ## Docs Sync
610
+
611
+ - Docs updated
612
+ - If none, explain why
613
+
614
+ ## Tracking
615
+
616
+ - Tasks changed from `[ ]` or `[~]` to `[x]`
617
+
618
+ ## Review
619
+
620
+ - Changed files reviewed
621
+ - Cleanup performed
622
+
623
+ ## Risks / Follow-up
624
+
625
+ - Remaining risks
626
+ - Suggested next step
627
+ ```
628
+
629
+ Do not say completion is done unless tests or verification passed, tracking was updated, docs were synced or explicitly declared unnecessary, changed files were reviewed, and unnecessary files/debug code were removed.
630
+
631
+ ## Default `config.json`
632
+
633
+ When initializing, create:
634
+
635
+ ```json
636
+ {
637
+ "workflow": {
638
+ "init_requires_confirmation": true,
639
+ "research_before_plan": true,
640
+ "best_practice_research": true,
641
+ "diagram_before_implementation": true,
642
+ "test_first": true,
643
+ "task_tracking": true,
644
+ "docs_sync_required": true,
645
+ "lessons_read_required": true,
646
+ "code_review": true,
647
+ "cleanup_pass": true,
648
+ "mechanical_checks": true,
649
+ "audit_supported": true,
650
+ "escalation_required": true
651
+ },
652
+ "tracking": {
653
+ "todo": "[ ]",
654
+ "in_progress": "[~]",
655
+ "done": "[x]",
656
+ "blocked": "[!]"
657
+ },
658
+ "required_reads_before_work": [
659
+ ".planning/SUMMARY.md",
660
+ ".planning/STATE.md",
661
+ ".planning/PITFALLS.md",
662
+ ".planning/LESSONS_LEARNED.md",
663
+ ".planning/CONVENTIONS.md",
664
+ ".planning/ARCHITECTURE.md",
665
+ ".planning/STACK.md"
666
+ ],
667
+ "docs_sync_targets": [
668
+ ".planning/REQUIREMENTS.md",
669
+ ".planning/API_DOCS.md",
670
+ ".planning/ARCHITECTURE.md",
671
+ ".planning/DESIGN.md",
672
+ ".planning/INTEGRATIONS.md",
673
+ ".planning/CONVENTIONS.md",
674
+ ".planning/ROADMAP.md",
675
+ ".planning/STATE.md",
676
+ ".planning/SPEC_CHANGELOG.md",
677
+ ".planning/QUALITY_SCORE.md",
678
+ ".planning/OBSERVABILITY.md",
679
+ ".planning/JOURNEYS.md",
680
+ ".planning/SMOKE_TESTS.md"
681
+ ],
682
+ "mermaid_required_for": [
683
+ "architecture",
684
+ "database",
685
+ "api_flow",
686
+ "integration",
687
+ "deployment",
688
+ "feature_flow",
689
+ "auth_flow",
690
+ "background_job_flow"
691
+ ],
692
+ "escalate_when": [
693
+ "ambiguous_product_intent",
694
+ "conflicting_requirements",
695
+ "breaking_api_change",
696
+ "destructive_migration",
697
+ "possible_user_data_loss",
698
+ "missing_credentials",
699
+ "paid_external_service_required",
700
+ "unclear_security_tradeoff",
701
+ "legal_or_compliance_risk"
702
+ ]
703
+ }
704
+ ```
705
+
706
+ ## Final Hard Rules
707
+
708
+ 1. `/init` must not blindly create implementation code.
709
+ 2. If the app idea is missing or ambiguous, ask for confirmation first.
710
+ 3. Create root `AGENTS.md` as a concise table of contents.
711
+ 4. Every task must be tracked with `[ ]`, `[~]`, `[x]`, or `[!]`.
712
+ 5. Do not say a task is done unless tracking files are updated.
713
+ 6. Every behavior/spec/API/DB/UI/integration/config/security change must update related docs.
714
+ 7. Before bug fix or feature work, always read `PITFALLS.md`, `LESSONS_LEARNED.md`, `CONVENTIONS.md`, `ARCHITECTURE.md`, and `STACK.md`.
715
+ 8. Every bug fix must append a lesson to `LESSONS_LEARNED.md`.
716
+ 9. Every non-trivial feature must have `SPEC.md`, `IMPACT.md`, `PLAN.md`, `TEST_CONTRACT.md`, `TASKS.md`, `VERIFICATION.md`, `REVIEW.md`, and `DIAGRAM.mmd`.
717
+ 10. Plans must clearly say what changes, where it changes, why it changes, risks, docs impact, and verification commands.
718
+ 11. Research best practices before planning when internet is available.
719
+ 12. Never invent external research results.
720
+ 13. Mermaid diagrams must be updated before architecture-impacting implementation.
721
+ 14. Tests or verification must be created before implementation.
722
+ 15. Review changed files after verification passes.
723
+ 16. Remove unnecessary files, debug logs, dead code, and unrelated changes.
724
+ 17. Use ADRs for major technical decisions.
725
+ 18. Use `/audit` to detect architecture drift, stale docs, dead code, missing tests, and quality gaps.
726
+ 19. Escalate to the user when human judgment is required.
727
+ 20. Final response must include changed files, tests, docs sync, tracking updates, review result, and remaining risks.