codex-genesis-harness 0.1.5 → 0.1.6

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 (151) hide show
  1. package/.codebase/ARCHITECTURE_REVIEW_COMPLETE.md +216 -216
  2. package/.codebase/CURRENT_STATE.md +7 -2
  3. package/.codebase/FILE_NAMING_CLARIFICATION.md +161 -161
  4. package/.codebase/HARNESS_COMPLETENESS_AUDIT.md +613 -613
  5. package/.codebase/IMPLEMENTATION_COMPLETE.md +429 -429
  6. package/.codebase/IMPLEMENTATION_HANDOFF.md +351 -351
  7. package/.codebase/IMPROVEMENTS_SUMMARY.md +419 -419
  8. package/.codebase/PHASE3_SKILLS_NAMING_COMPLETE.md +292 -292
  9. package/.codebase/PHASE_DEPENDENCY_MAP.md +486 -486
  10. package/.codebase/QUICK_START_SPEC_IMPACT.md +456 -456
  11. package/.codebase/README.md +139 -139
  12. package/.codebase/RECOVERY_POINTS.md +438 -438
  13. package/.codex/skills/genesis-api-sync/SKILL.md +354 -354
  14. package/.codex/skills/genesis-api-sync/checklists/api-sync-checklist.md +101 -101
  15. package/.codex/skills/genesis-api-sync/templates/api-change-template.md +257 -257
  16. package/.codex/skills/genesis-debug-guide/SKILL.md +479 -479
  17. package/.codex/skills/genesis-debug-guide/checklists/flaky-test-investigation.md +339 -339
  18. package/.codex/skills/genesis-debug-guide/checklists/production-bug-debug.md +210 -210
  19. package/.codex/skills/genesis-debug-guide/checklists/test-failure-debug.md +158 -158
  20. package/.codex/skills/genesis-debug-guide/observability/debug-commands.md +365 -365
  21. package/.codex/skills/genesis-debug-guide/playbooks/unit-test-failures.md +289 -289
  22. package/.codex/skills/genesis-debug-guide/templates/debug-investigation-log.md +288 -288
  23. package/.codex/skills/genesis-docs-automation/SKILL.md +1003 -1003
  24. package/.codex/skills/genesis-docs-automation/checklists/docs-validation.md +359 -359
  25. package/.codex/skills/genesis-docs-automation/checklists/spec-alignment.md +312 -312
  26. package/.codex/skills/genesis-docs-automation/observability/docs-tracking.md +382 -382
  27. package/.codex/skills/genesis-docs-automation/playbooks/auto-update-flow.md +851 -851
  28. package/.codex/skills/genesis-docs-automation/playbooks/changelog-generation.md +491 -491
  29. package/.codex/skills/genesis-docs-automation/templates/changelog-entry-template.md +187 -187
  30. package/.codex/skills/genesis-docs-automation/templates/handoff-template.md +297 -297
  31. package/.codex/skills/genesis-harness/SKILL.md +1427 -1427
  32. package/.codex/skills/genesis-harness/agents/openai.yaml +7 -7
  33. package/.codex/skills/genesis-harness/checklists/bug-fix-qa.md +169 -169
  34. package/.codex/skills/genesis-harness/checklists/new-feature-qa.md +157 -157
  35. package/.codex/skills/genesis-harness/checklists/refactor-qa.md +216 -216
  36. package/.codex/skills/genesis-harness/checklists/requirements-validation.md +211 -211
  37. package/.codex/skills/genesis-harness/references/planning-schema.md +35 -35
  38. package/.codex/skills/genesis-harness/references/quality-rubric.md +21 -21
  39. package/.codex/skills/genesis-harness/references/research-rubric.md +41 -41
  40. package/.codex/skills/genesis-harness/references/workflows.md +33 -33
  41. package/.codex/skills/genesis-harness/resources/agents-template.md +27 -27
  42. package/.codex/skills/genesis-harness/resources/api-docs-template.md +32 -32
  43. package/.codex/skills/genesis-harness/resources/architecture-template.md +30 -30
  44. package/.codex/skills/genesis-harness/resources/audit-template.md +26 -26
  45. package/.codex/skills/genesis-harness/resources/bug-template.md +34 -34
  46. package/.codex/skills/genesis-harness/resources/change-impact-matrix-template.md +204 -204
  47. package/.codex/skills/genesis-harness/resources/check-template.md +21 -21
  48. package/.codex/skills/genesis-harness/resources/conventions-template.md +42 -42
  49. package/.codex/skills/genesis-harness/resources/decision-template.md +33 -33
  50. package/.codex/skills/genesis-harness/resources/design-template.md +26 -26
  51. package/.codex/skills/genesis-harness/resources/escalation-template.md +21 -21
  52. package/.codex/skills/genesis-harness/resources/feature-template.md +49 -49
  53. package/.codex/skills/genesis-harness/resources/foundation-phase-template.md +131 -131
  54. package/.codex/skills/genesis-harness/resources/integrations-template.md +32 -32
  55. package/.codex/skills/genesis-harness/resources/journeys-template.md +13 -13
  56. package/.codex/skills/genesis-harness/resources/lessons-learned-template.md +12 -12
  57. package/.codex/skills/genesis-harness/resources/observability-template.md +34 -34
  58. package/.codex/skills/genesis-harness/resources/phase-00-foundation-template.md +76 -76
  59. package/.codex/skills/genesis-harness/resources/phase-template.md +34 -34
  60. package/.codex/skills/genesis-harness/resources/pitfalls-template.md +22 -22
  61. package/.codex/skills/genesis-harness/resources/planning-tree-template.md +39 -39
  62. package/.codex/skills/genesis-harness/resources/post-implementation-guide.md +347 -347
  63. package/.codex/skills/genesis-harness/resources/project-template.md +38 -38
  64. package/.codex/skills/genesis-harness/resources/quality-score-template.md +11 -11
  65. package/.codex/skills/genesis-harness/resources/requirements-template.md +26 -26
  66. package/.codex/skills/genesis-harness/resources/research-template.md +26 -26
  67. package/.codex/skills/genesis-harness/resources/review-template.md +22 -22
  68. package/.codex/skills/genesis-harness/resources/spec-changelog-template.md +6 -6
  69. package/.codex/skills/genesis-harness/resources/stack-template.md +33 -33
  70. package/.codex/skills/genesis-harness/resources/verification-template.md +26 -26
  71. package/.codex/skills/genesis-harness/scripts/check-architecture-boundaries.sh +0 -0
  72. package/.codex/skills/genesis-harness/scripts/check-docs-sync.sh +0 -0
  73. package/.codex/skills/genesis-harness/scripts/check-no-debug-logs.sh +0 -0
  74. package/.codex/skills/genesis-harness/scripts/check-required-planning-files.sh +0 -0
  75. package/.codex/skills/genesis-harness/scripts/check-spec-changelog.sh +0 -0
  76. package/.codex/skills/genesis-harness/scripts/check-task-tracking.sh +0 -0
  77. package/.codex/skills/genesis-harness/scripts/compact-context.sh +0 -0
  78. package/.codex/skills/genesis-harness/scripts/create-adr.sh +0 -0
  79. package/.codex/skills/genesis-harness/scripts/create-bug.sh +0 -0
  80. package/.codex/skills/genesis-harness/scripts/create-feature.sh +0 -0
  81. package/.codex/skills/genesis-harness/scripts/detect-stack.sh +0 -0
  82. package/.codex/skills/genesis-harness/scripts/init-planning.sh +0 -0
  83. package/.codex/skills/genesis-harness/scripts/list-changed-files.sh +0 -0
  84. package/.codex/skills/genesis-harness/scripts/offload-log.sh +0 -0
  85. package/.codex/skills/genesis-harness/scripts/run-verification.sh +0 -0
  86. package/.codex/skills/genesis-harness/scripts/run-verify-loop.sh +0 -0
  87. package/.codex/skills/genesis-harness/scripts/update-state.sh +0 -0
  88. package/.codex/skills/genesis-mvp-planning/SKILL.md +114 -0
  89. package/.codex/skills/genesis-mvp-planning/agents/openai.yaml +6 -0
  90. package/.codex/skills/genesis-mvp-planning/checklists/mvp-readiness.md +18 -0
  91. package/.codex/skills/genesis-mvp-planning/examples/5-phase-roadmap-example.md +43 -0
  92. package/.codex/skills/genesis-mvp-planning/templates/phase-1-core.md +17 -0
  93. package/.codex/skills/genesis-mvp-planning/templates/phase-2-auth.md +17 -0
  94. package/.codex/skills/genesis-mvp-planning/templates/phase-3-features.md +17 -0
  95. package/.codex/skills/genesis-mvp-planning/templates/phase-4-integrations.md +17 -0
  96. package/.codex/skills/genesis-mvp-planning/templates/phase-5-readiness.md +17 -0
  97. package/.codex/skills/genesis-new-design/agents/openai.yaml +3 -3
  98. package/.codex/skills/genesis-observability-automation/checklists/.gitkeep +0 -0
  99. package/.codex/skills/genesis-observability-automation/observability/.gitkeep +0 -0
  100. package/.codex/skills/genesis-observability-automation/playbooks/.gitkeep +0 -0
  101. package/.codex/skills/genesis-observability-automation/templates/.gitkeep +0 -0
  102. package/.codex/skills/genesis-release-orchestration/SKILL.md +653 -653
  103. package/.codex/skills/genesis-release-orchestration/checklists/post-deployment-verification.md +274 -274
  104. package/.codex/skills/genesis-release-orchestration/checklists/pre-release-validation.md +220 -220
  105. package/.codex/skills/genesis-release-orchestration/observability/release-tracking.md +253 -253
  106. package/.codex/skills/genesis-release-orchestration/playbooks/canary-deployment-orchestration.md +472 -472
  107. package/.codex/skills/genesis-release-orchestration/playbooks/semantic-versioning-automation.md +494 -494
  108. package/.codex/skills/genesis-release-orchestration/templates/deployment-strategy-template.md +303 -303
  109. package/.codex/skills/genesis-release-orchestration/templates/release-runbook-template.md +420 -420
  110. package/.codex/skills/genesis-research-first/SKILL.md +237 -237
  111. package/.codex/skills/genesis-research-first/templates/.gitkeep +0 -0
  112. package/.codex/skills/genesis-spec-propagation/SKILL.md +534 -534
  113. package/.codex/skills/genesis-spec-propagation/checklists/phase-update-verification.md +384 -384
  114. package/.codex/skills/genesis-spec-propagation/checklists/spec-change-detection.md +257 -257
  115. package/.codex/skills/genesis-spec-propagation/observability/propagation-tracking.md +373 -373
  116. package/.codex/skills/genesis-spec-propagation/playbooks/breaking-change-propagation.md +692 -692
  117. package/.codex/skills/genesis-spec-propagation/playbooks/feature-change-propagation.md +434 -434
  118. package/.codex/skills/genesis-spec-propagation/templates/migration-guide-template.md +407 -407
  119. package/.codex/skills/genesis-upgrade-design/agents/openai.yaml +3 -3
  120. package/.codex/skills/spec-impact-engine/SKILL.md +504 -504
  121. package/.codex/skills/spec-impact-engine/detect-spec-changes.sh +0 -0
  122. package/.codex-plugin/plugin.json +19 -19
  123. package/CHANGELOG.md +42 -0
  124. package/LICENSE +22 -22
  125. package/README.EN.md +784 -730
  126. package/README.VI.md +776 -723
  127. package/README.md +102 -247
  128. package/VERSION +2 -2
  129. package/bin/genesis-harness.js +90 -87
  130. package/package.json +9 -3
  131. package/scripts/README.md +342 -342
  132. package/scripts/compact-context.sh +0 -0
  133. package/scripts/contract_integrity_gate.js +83 -0
  134. package/scripts/detect-changes.sh +0 -0
  135. package/scripts/healing_telemetry.js +118 -0
  136. package/scripts/install.sh +4 -1
  137. package/scripts/offload-log.sh +0 -0
  138. package/scripts/prompt_sentinel.js +84 -0
  139. package/scripts/run-evals.sh +1 -0
  140. package/scripts/run-verify-loop.sh +11 -0
  141. package/scripts/spec_visual_sync.js +157 -0
  142. package/scripts/test_generator.js +142 -0
  143. package/scripts/transition_state.sh +0 -0
  144. package/scripts/uninstall.sh +1 -0
  145. package/scripts/validation_gates.sh +40 -1
  146. package/scripts/verify.sh +5 -0
  147. package/tests/unit/contract_integrity_gate.test.js +74 -0
  148. package/tests/unit/healing_telemetry.test.js +58 -0
  149. package/tests/unit/prompt_sentinel.test.js +50 -0
  150. package/tests/unit/spec_visual_sync.test.js +77 -0
  151. package/tests/unit/test_generator.test.js +62 -0
@@ -1,1427 +1,1427 @@
1
- ---
2
- name: 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
- ## Purpose
13
- Operate a repository through test-first, contract-first, memory-aware Codex workflows.
14
-
15
- ## When to use
16
- Use for project initialization, planning, feature work, bug fixes, audits, reviews, verification, and repository memory updates.
17
-
18
- ## When NOT to use
19
- Do not use for simple read-only answers that do not require repository workflow or durable artifacts.
20
-
21
- ## Inputs required
22
- Read `.codebase/state.json` (MANDATORY on boot), `.codebase/CURRENT_STATE.md`, `.codebase/MODULE_INDEX.md`, and `.codebase/TEST_MATRIX.md` when present, then inspect only relevant files.
23
-
24
- ## Outputs required
25
- Plan or implementation artifact, tests, fixtures, verification evidence, docs sync, and codebase memory updates.
26
-
27
- ## Required tests
28
- Create or update failing tests before implementation.
29
-
30
- ## Required fixtures
31
- Create fixtures for expected inputs, outputs, validation notes, and recovery cases.
32
-
33
- ## Required contract updates
34
- Update API, agent, event, or UI contracts when public behavior changes.
35
-
36
- ## Required codebase map updates
37
- Update `.codebase` memory after meaningful changes.
38
-
39
- ## Token saving rules
40
- Read summaries before source files, maps before modules, and avoid loading the entire repository.
41
-
42
- ## Acceptance criteria
43
- Work is complete only when tests pass, contracts and docs are current, and verification evidence is reported.
44
-
45
- ## Common mistakes
46
- Implementing before tests, skipping fixtures, overloading `AGENTS.md`, and duplicating long context across skills.
47
-
48
- ## Recovery workflow
49
- If blocked or interrupted, read `.codebase/state.json` to identify your exact FSM state. Rerun verification, identify the first failing phase, and resume from that point based on the strict state rules.
50
-
51
- ## Core Principle
52
-
53
- Do not code first.
54
-
55
- Correct order:
56
-
57
- ```txt
58
- Confirm intent
59
- -> Inspect repository
60
- -> Initialize planning
61
- -> Research
62
- -> Decide
63
- -> Diagram
64
- -> Plan
65
- -> Test contract
66
- -> Implement
67
- -> Verify
68
- -> Review
69
- -> Sync docs
70
- -> Track completion
71
- -> Report
72
- ```
73
-
74
- Never skip confirmation when intent is unclear, research, planning, test or verification, docs synchronization, task tracking, or review.
75
-
76
- ## Supported Commands
77
-
78
- Support these user intents:
79
-
80
- ```txt
81
- /init
82
- /new-feature <description>
83
- /fix-bug <description>
84
- /plan <description>
85
- /audit
86
- /review
87
- /status
88
- /spec-change <file> [NEW]
89
- /propagate-spec [NEW]
90
- /validate-specs [NEW]
91
- ```
92
-
93
- If the user does not type an exact command but clearly asks for one of these workflows, infer the correct workflow.
94
-
95
- ## NEW: Spec Impact & Propagation Commands
96
-
97
- These commands enable automatic cascade prevention:
98
-
99
- ### `/spec-change <file>` - Detect & Analyze Spec Changes
100
-
101
- ```bash
102
- /spec-change .planning/API_DOCS.md
103
-
104
- What it does:
105
- 1. Detects what changed in the file
106
- 2. Identifies breaking changes vs feature additions
107
- 3. Finds all downstream phases that depend on the change
108
- 4. Calculates impact severity (high/medium/low)
109
- 5. Generates impact report with recommendations
110
- 6. Offers to auto-update all affected phases
111
- ```
112
-
113
- ### `/propagate-spec` - Auto-Update Downstream Phases
114
-
115
- ```bash
116
- /propagate-spec
117
-
118
- What it does:
119
- 1. Checks SPEC_CHANGELOG.md for unpropagated changes
120
- 2. Queries PHASE_DEPENDENCY_MAP for affected phases
121
- 3. AUTO-UPDATES all dependent phase specs
122
- 4. AUTO-UPDATES all affected phase tests
123
- 5. Runs validation tests in all phases
124
- 6. Generates migration guides for breaking changes
125
- 7. Updates ROADMAP.md if timeline affected
126
- 8. Creates comprehensive impact report
127
- ```
128
-
129
- ### `/validate-specs` - Check All Phases Aligned
130
-
131
- ```bash
132
- /validate-specs
133
-
134
- What it does:
135
- 1. Validates all phases against their dependencies
136
- 2. Detects spec drift (phase using stale upstream specs)
137
- 3. Identifies breaking changes not yet propagated
138
- 4. Lists any alignment issues
139
- 5. Suggests fixes
140
- 6. Blocks start of phase if upstream specs incomplete
141
- ```
142
-
143
- ## Resource And Script Map
144
-
145
- Bundled resources live under `resources/`. Use them as starting content when creating `.planning/` files:
146
-
147
- - `planning-tree-template.md`: required `.planning/` tree.
148
- - `agents-template.md`: concise root `AGENTS.md`.
149
- - `project-template.md` through `check-template.md`: starter content for project, phase, feature, bug, ADR, research, review, verification, audit, and check files.
150
- - `post-implementation-guide.md`: Auto-update workflow after successful implementation. Guides doc synchronization, state tracking, and continuity.
151
- - `requirements-validation.md`: Final validation checklist before implementation to ensure all requirements are clear and complete.
152
-
153
- Bundled checklists live under `checklists/`. Use these as structured Q&A before planning:
154
-
155
- - **MANDATORY**: `new-feature-qa.md`: Comprehensive Q&A for new features. Complete before `/new-feature` planning.
156
- - **MANDATORY**: `bug-fix-qa.md`: Comprehensive Q&A for bug fixes. Complete before `/fix-bug` planning.
157
- - **MANDATORY**: `refactor-qa.md`: Comprehensive Q&A for refactors. Complete before refactor planning.
158
- - **MANDATORY**: `requirements-validation.md`: Final validation checklist. Use after Q&A, before contracts and tests.
159
- - `checklist.md`: General Genesis Harness workflow checklist.
160
-
161
- Bundled skills live under `skills/`. These are specialized automation tools:
162
-
163
- - **NEW**: `spec-impact-engine/SKILL.md`: Automatically detect when specs change and update all downstream phases. Prevents cascading rework.
164
- - `api-sync-skill/SKILL.md`: Auto-sync API contracts with implementation after changes.
165
- - `docs-skill/SKILL.md`: Auto-update documentation after implementation.
166
-
167
- Bundled references live under `references/`. Load them only when needed:
168
-
169
- - `references/workflows.md`: command routing, readiness gate, and completion gate.
170
- - `references/planning-schema.md`: detailed `.planning/` file meanings and required subtrees.
171
- - `references/research-rubric.md`: local/external evidence format for research.
172
- - `references/quality-rubric.md`: scoring rubric for `QUALITY_SCORE.md`.
173
-
174
- Bundled scripts live under `scripts/`. Prefer copying or adapting these into `.planning/scripts/` or project scripts during `/init`:
175
-
176
- - `init-planning.sh`: creates `AGENTS.md` and the `.planning/` tree.
177
- - `create-feature.sh`: scaffolds `.planning/features/NNN-feature-slug/`.
178
- - `create-bug.sh`: scaffolds `.planning/bugs/NNN-bug-slug/`.
179
- - `create-adr.sh`: scaffolds `.planning/decisions/ADR-NNN-slug.md`.
180
- - `update-state.sh`: updates common fields in `.planning/STATE.md`.
181
- - **NEW**: `transition_state.sh`: Strict FSM transition script. You MUST use this script to move between `INIT`, `REQUIREMENTS_GATHERING`, `PLANNING`, `IMPLEMENTATION`, `VERIFICATION`, and `COMPLETED` states.
182
- - `offload-log.sh`: captures and trims large command outputs to protect the context window.
183
- - `compact-context.sh`: intelligent context compaction summarizing state to disk.
184
- - `run-verify-loop.sh`: state-tracked Ralph Loop verify-fix loop executor.
185
- - `detect-stack.sh`: inspects repository stack clues.
186
- - `list-changed-files.sh`: lists git changes when git is available.
187
- - `run-verification.sh`: runs detected lint/typecheck/test/build checks.
188
- - `detect-changes.sh`: Auto-detect file changes and identify what `.codebase` docs need updating.
189
- - `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.
190
- - **NEW**: `spec-impact-engine/detect-spec-changes.sh`: Auto-detect spec changes and generate impact report.
191
-
192
- ## `/init` Workflow
193
-
194
- When the user types `/init`, initialize the project planning harness. Before creating files, inspect the current repository.
195
-
196
- **Important**: Do not create feature-specific phases. Create only a Foundation phase (Phase 0) as a planning framework. Feature phases are created only after requirements are confirmed and roadmap is finalized.
197
-
198
- Look for:
199
-
200
- - `README.md`
201
- - `AGENTS.md`
202
- - `package.json`
203
- - `composer.json`
204
- - `pyproject.toml`
205
- - `requirements.txt`
206
- - `Cargo.toml`
207
- - `go.mod`
208
- - `*.csproj` or `*.sln`
209
- - `Dockerfile`
210
- - `docker-compose.yml`
211
- - `src/` or `app/`
212
- - existing docs
213
- - existing tests
214
- - existing API routes
215
- - existing database schema
216
- - existing architecture clues
217
-
218
- ### Confirmation Rule
219
-
220
- If there is enough information to infer the product idea, summarize the detected project brief and ask for confirmation:
221
-
222
- ```md
223
- ## Detected Project Brief
224
-
225
- Product:
226
- Target users:
227
- Core features:
228
- Tech stack:
229
- Integrations:
230
- First milestone:
231
- Out of scope:
232
- Assumptions:
233
-
234
- Please confirm before I initialize `.planning/`.
235
-
236
- Note: I will create a Foundation phase (Phase 0) for documentation
237
- only. Feature phases will be created later when requirements are finalized.
238
- ```
239
-
240
- If the app idea is missing or ambiguous, stop and ask:
241
-
242
- 1. What application are we building?
243
- 2. Who are the target users?
244
- 3. What are the core features?
245
- 4. What tech stack do you prefer?
246
- 5. What integrations are required?
247
- 6. What is explicitly out of scope?
248
- 7. What is the first milestone?
249
- 8. Are there any design, architecture, security, or deployment constraints?
250
-
251
- Do not create implementation code until the project idea is confirmed.
252
-
253
- After confirmation, create root `AGENTS.md`, the `.planning/` structure, initial planning files, base Mermaid diagrams, a Foundation phase (Phase 0) as planning framework only, initial checks, the initial quality score, and the phase dependency map. Use `scripts/init-planning.sh` when it fits the repository.
254
-
255
- **Foundation Phase (Phase 0)**: This is a setup phase only, not a feature phase. It contains:
256
- - Tasks to complete project documentation
257
- - No feature implementation tasks
258
- - Placeholder roadmap with no feature phases yet
259
-
260
- **Phase Dependency Map**: Created as `.codebase/PHASE_DEPENDENCY_MAP.md`, this is:
261
- - Mapping of which phases provide what
262
- - Which phases depend on which other phases
263
- - Impact calculation rules for spec changes
264
- - Timeline sensitivity analysis
265
- - Used by spec-impact-engine for auto-updates
266
-
267
- Feature phases must not be created until requirements are finalized and prioritized. Each feature gets its own numbered phase folder when work begins.
268
-
269
- `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.
270
-
271
- ## Root `AGENTS.md`
272
-
273
- 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/`.
274
-
275
- Minimum contents:
276
-
277
- ```md
278
- # AGENTS.md
279
-
280
- This repository uses the Project Genesis Harness.
281
-
282
- Before doing feature work, bug fixes, refactors, or architecture changes, read:
283
-
284
- 1. `.planning/SUMMARY.md`
285
- 2. `.planning/STATE.md`
286
- 3. `.planning/PROJECT.md`
287
- 4. `.planning/REQUIREMENTS.md`
288
- 5. `.planning/STACK.md`
289
- 6. `.planning/ARCHITECTURE.md`
290
- 7. `.planning/CONVENTIONS.md`
291
- 8. `.planning/PITFALLS.md`
292
- 9. `.planning/LESSONS_LEARNED.md`
293
-
294
- For new features, create a folder under `.planning/features/`.
295
- For bug fixes, create a folder under `.planning/bugs/`.
296
- For major decisions, create an ADR under `.planning/decisions/`.
297
-
298
- Do not claim completion unless verification passed, docs were synchronized, task tracking was updated, and changed files were reviewed.
299
- ```
300
-
301
- Keep `AGENTS.md` concise.
302
-
303
- ## Required `.planning/` Architecture
304
-
305
- Create the full tree described in `resources/planning-tree-template.md`, including:
306
-
307
- - 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`
308
- - diagrams: `system-context.mmd`, `container-architecture.mmd`, `database-erd.mmd`, `deployment-flow.mmd`, `roadmap-flow.mmd`
309
- - research, decisions, phases, features, bugs, audits, checks, quick, codebase, and templates folders.
310
-
311
- ## Meaning Of Core Files
312
-
313
- - `PROJECT.md`: project identity, target users, value, scope, out of scope, constraints, assumptions, current milestone, success criteria.
314
- - `REQUIREMENTS.md`: functional and non-functional requirements, user stories, acceptance criteria, edge cases, known unknowns.
315
- - `ROADMAP.md`: milestones, phases, dependencies, status, acceptance criteria.
316
- - `STATE.md`: current phase, active feature or bug, last completed task, next task, blockers, latest verification.
317
- - `STACK.md`: language, framework, runtime, database, package manager, test framework, lint/typecheck tools, deployment target, versions, local commands.
318
- - `ARCHITECTURE.md`: architecture, module boundaries, data flow, dependency direction, service boundaries, principles, forbidden patterns.
319
- - `DESIGN.md`: UX principles, screens/pages, component conventions, state management, accessibility, constraints.
320
- - `API_DOCS.md`: endpoints, examples, errors, auth, versioning.
321
- - `INTEGRATIONS.md`: services, SDKs, env vars, secrets, failure handling, fallbacks, rate limits.
322
- - `CONVENTIONS.md`: naming, folders, style, errors, logging, tests, API rules, security rules, patterns to follow and avoid.
323
- - `PITFALLS.md`: common mistakes, risky areas, fragile dependencies, historical warnings.
324
- - `LESSONS_LEARNED.md`: fixed bugs, root causes, failed assumptions, correct patterns, prevention rules, changed files, verification evidence.
325
- - `SPEC_CHANGELOG.md`: every spec-affecting change with date/time, reason, impacted docs, impacted tests, migration notes.
326
- - `FEATURE_INDEX.md`: table of features with status, phase, path, notes.
327
- - `CHANGE_IMPACT_MATRIX.md`: mapping from change types to docs that must update.
328
- - `QUALITY_SCORE.md`: quality areas and scores; update during `/audit`, `/review`, major features, and major bug fixes.
329
- - `ESCALATION.md`: when Codex must stop and ask the user.
330
- - `OBSERVABILITY.md`: logs, metrics, traces, errors, health checks, debug commands, local inspection.
331
- - `JOURNEYS.md`: important user journeys with expected UI/API/DB/log state and verification.
332
- - `SMOKE_TESTS.md`: minimal checks proving the app is alive.
333
-
334
- ## Task Tracking Rule
335
-
336
- Every phase, feature, bug, audit, and task must use checkbox tracking:
337
-
338
- ```txt
339
- [ ] not started
340
- [~] in progress
341
- [x] completed
342
- [!] blocked
343
- ```
344
-
345
- When a task is started:
346
-
347
- 1. update checkbox from `[ ]` to `[~]`
348
- 2. update `.planning/STATE.md`
349
-
350
- When a task is completed:
351
-
352
- 1. update checkbox from `[~]` or `[ ]` to `[x]`
353
- 2. update `.planning/STATE.md`
354
- 3. update related phase `TASKS.md`
355
- 4. update related feature or bug `TASKS.md` if applicable
356
- 5. update `.planning/SUMMARY.md`
357
-
358
- Never claim a task is complete unless tracking files were updated.
359
-
360
- ## Definition Of Ready
361
-
362
- Feature, bug, phase, audit, and architecture work is ready to implement only when:
363
-
364
- - [x] product intent or bug report is clear enough to avoid guessing
365
- - [x] required planning docs were read
366
- - [x] relevant local codebase patterns were researched
367
- - [x] best-practice research is recorded or internet unavailability is stated
368
- - [x] impact on API, data, UI, auth, integrations, config, docs, and tests is known
369
- - [x] test contract or verification contract exists
370
- - [x] diagram or ADR impact is handled when architecture changes
371
- - [x] escalation concerns were resolved or explicitly recorded
372
-
373
- If any item is false, do not implement. Update tracking to `[!]` or ask the user.
374
-
375
- ## Validation Gates
376
-
377
- Before moving to the `COMPLETED` state, the agent MUST pass the validation gates:
378
- - Run `bash scripts/validation_gates.sh`
379
- - Ensure no leftover `TODO`, `FIXME`, `console.log`, or `print` statements remain in production code.
380
- - Ensure all tests and `verify.sh` checks pass.
381
- - If the validation gates fail, the agent is forced to remain in `VERIFICATION` or return to `IMPLEMENTATION` to fix the issues.
382
-
383
- ## Definition Of Done
384
-
385
- Work is done only when:
386
-
387
- - [x] implementation is complete and scoped to the plan
388
- - [x] automated tests or documented verification passed
389
- - [x] docs were synchronized (see Docs Sync Rule below)
390
- - [x] task tracking moved from `[ ]` or `[~]` to `[x]`
391
- - [x] `.planning/STATE.md` updated (current phase, active feature, next task)
392
- - [x] `.planning/SUMMARY.md` updated (recent changes, next recommended task)
393
- - [x] `.planning/SPEC_CHANGELOG.md` updated if behavior/API/requirements changed
394
- - [x] `.planning/QUALITY_SCORE.md` recalculated
395
- - [x] `.planning/FEATURE_INDEX.md` updated with feature status
396
- - [x] changed files were reviewed
397
- - [x] debug logs, dead code, unrelated edits, and unnecessary files were removed
398
- - [x] risks and follow-up tasks are recorded
399
-
400
- **Never use completion language until ALL items above are satisfied.**
401
-
402
- If a doc doesn't need updating, explicitly explain why in the completion report.
403
-
404
- ## Research Rule
405
-
406
- Before planning or implementing any non-trivial task:
407
-
408
- 1. Research the existing codebase.
409
- 2. Identify similar patterns already present.
410
- 3. Research best practices using official docs, Google, GitHub, or reputable sources when internet access is available.
411
- 4. Record findings in `.planning/research/`.
412
- 5. Mention evidence in the plan.
413
-
414
- 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.
415
-
416
- Use this evidence format in `.planning/research/`:
417
-
418
- ```md
419
- ## Research: <topic>
420
-
421
- Date:
422
- Question:
423
-
424
- ## Local Evidence
425
-
426
- | File / Command | Finding | Impact |
427
- |---|---|---|
428
- | `path/to/file` | TBD | TBD |
429
-
430
- ## External Evidence
431
-
432
- | Source | Date Checked | Finding | Impact |
433
- |---|---|---|---|
434
- | URL or official doc name | YYYY-MM-DD | TBD | TBD |
435
-
436
- ## Decision Impact
437
-
438
- - [ ] TBD
439
-
440
- ## Confidence / Gaps
441
-
442
- - [ ] TBD
443
- ```
444
-
445
- 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.
446
-
447
- ## Mermaid Diagram Rule
448
-
449
- 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.
450
-
451
- Required base diagrams:
452
-
453
- ```txt
454
- .planning/diagrams/system-context.mmd
455
- .planning/diagrams/container-architecture.mmd
456
- .planning/diagrams/database-erd.mmd
457
- .planning/diagrams/deployment-flow.mmd
458
- .planning/diagrams/roadmap-flow.mmd
459
- ```
460
-
461
- A feature must also have `.planning/features/NNN-feature-name/DIAGRAM.mmd`. Do not implement architecture-changing work before updating the relevant diagram.
462
-
463
- ## `/new-feature` Workflow
464
-
465
- **IMPORTANT**: Always use `checklists/new-feature-qa.md` BEFORE starting any feature work.
466
-
467
- When adding a new feature:
468
-
469
- ### Step 0: Complete Q&A Checklist (MANDATORY)
470
-
471
- ```bash
472
- # Before any planning, complete:
473
- cat .codex/skills/genesis-harness/checklists/new-feature-qa.md
474
-
475
- # Answer all questions:
476
- - User story clearly defined?
477
- - Success criteria measurable?
478
- - Out of scope documented?
479
- - Requirements clear?
480
- - API/database/UI impacts known?
481
- - Edge cases identified?
482
- - Test strategy defined?
483
- - No unknowns remaining?
484
- ```
485
-
486
- If ANY question is unanswered → Stop and get clarification before continuing.
487
-
488
- ### Step 1: Requirements Validation
489
-
490
- After Q&A is complete, validate requirements:
491
-
492
- ```bash
493
- # Use requirements validation checklist:
494
- cat .codex/skills/genesis-harness/checklists/requirements-validation.md
495
-
496
- # Verify:
497
- - All items are specific and measurable
498
- - Scope is bounded
499
- - Technical feasibility confirmed
500
- - Acceptance criteria are testable
501
- - Stakeholder alignment obtained
502
- ```
503
-
504
- If ANY validation fails → Do not continue. Fix before proceeding.
505
-
506
- ### Step 2: Confirm Definition of Ready
507
-
508
- Then read:
509
-
510
- ```txt
511
- .planning/SUMMARY.md
512
- .planning/STATE.md
513
- .planning/PITFALLS.md
514
- .planning/LESSONS_LEARNED.md
515
- .planning/CONVENTIONS.md
516
- .planning/ARCHITECTURE.md
517
- .planning/STACK.md
518
- ```
519
-
520
- Verify ALL of these are TRUE:
521
-
522
- ```
523
- [ ] Q&A checklist completed and all questions answered
524
- [ ] Requirements validation passed
525
- [ ] Product intent is clear enough to avoid guessing
526
- [ ] Required planning docs were read (7 docs above)
527
- [ ] Relevant local codebase patterns were researched
528
- [ ] Best-practice research is recorded or internet unavailability stated
529
- [ ] Impact on API, database, UI, auth, integrations, config, docs, and tests is KNOWN
530
- [ ] Test contract or verification contract will be created
531
- [ ] Diagram or ADR impact is handled if architecture changes
532
- [ ] Escalation concerns are resolved or explicitly recorded
533
-
534
- If ANY checkbox is FALSE → Do not continue.
535
- Ask user for clarification or update tracking to [!] blocked.
536
- ```
537
-
538
- ### Step 3: Research & Plan
539
-
540
- Research local patterns and best practices. Create:
541
-
542
- ```txt
543
- .planning/features/NNN-feature-slug/
544
- ├── SPEC.md
545
- ├── IMPACT.md
546
- ├── PLAN.md
547
- ├── TEST_CONTRACT.md
548
- ├── TASKS.md
549
- ├── VERIFICATION.md
550
- ├── REVIEW.md
551
- └── DIAGRAM.mmd
552
- ```
553
-
554
- `SPEC.md` must include summary, user story, expected behavior, edge cases, out of scope, and acceptance criteria.
555
-
556
- `IMPACT.md` must answer whether the feature affects API, database, UI, auth/security, integrations, environment variables, architecture, docs, tests, migrations, or existing user journeys.
557
-
558
- `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:
559
-
560
- ```md
561
- ### File: `path/to/file`
562
-
563
- Change:
564
- Why:
565
- Risk:
566
- Test:
567
- Docs impact:
568
- ```
569
-
570
- `TEST_CONTRACT.md` must include normal input/output, edge cases, invalid inputs, expected errors, acceptance tests, and manual verification if automated tests are unavailable.
571
-
572
- `TASKS.md` must include checkbox tasks for:
573
-
574
- **Phase 1: Confirmation & Research**
575
- - [ ] Complete `.codex/skills/genesis-harness/checklists/new-feature-qa.md`
576
- - [ ] Complete `.codex/skills/genesis-harness/checklists/requirements-validation.md`
577
- - [ ] Read required `.planning/` docs (SUMMARY, STATE, PITFALLS, LESSONS, CONVENTIONS, ARCHITECTURE, STACK)
578
- - [ ] Verify Definition of Ready (all 10 items confirmed YES)
579
-
580
- **Phase 2: Planning & Contracts**
581
- - [ ] Research codebase patterns for similar features
582
- - [ ] Research best practices (external sources or mark unavailable)
583
- - [ ] Complete SPEC.md with full acceptance criteria
584
- - [ ] Complete IMPACT.md answering all 11 impact questions
585
- - [ ] Complete PLAN.md with file changes, risks, rollback
586
- - [ ] Create TEST_CONTRACT.md with test cases
587
- - [ ] Create DIAGRAM.mmd if architecture affected
588
- - [ ] Identify all docs that will need updates (API_DOCS? REQUIREMENTS? DESIGN? etc.)
589
-
590
- **Phase 3: Implementation**
591
- - [ ] Create failing test or verification
592
- - [ ] Implement to pass test
593
- - [ ] Run verification - all pass?
594
- - [ ] Review code for quality
595
-
596
- **Phase 4: Documentation & Sync**
597
- - [ ] Check CHANGE_IMPACT_MATRIX.md → which docs must update?
598
- - [ ] Update REQUIREMENTS.md (if behavior/feature added)
599
- - [ ] Update API_DOCS.md (if API endpoints changed)
600
- - [ ] Update ARCHITECTURE.md (if structure changed)
601
- - [ ] Update DESIGN.md (if UI/UX changed)
602
- - [ ] Update INTEGRATIONS.md (if external services changed)
603
- - [ ] Update CONVENTIONS.md (if new patterns established)
604
- - [ ] Update STACK.md (if new tech added)
605
- - [ ] Update SPEC_CHANGELOG.md with: date, reason, impacted docs, impacted tests, migration notes
606
- - [ ] Update .planning/STATE.md (current phase, active feature, next task)
607
- - [ ] Update .planning/SUMMARY.md (recent changes, next recommended task)
608
- - [ ] Update .planning/FEATURE_INDEX.md (add feature status)
609
- - [ ] Update .planning/QUALITY_SCORE.md (recalculate scores)
610
- - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
611
-
612
- **Phase 5: Review & Completion**
613
- - [ ] Review changed files (remove debug logs, dead code, unrelated changes)
614
- - [ ] Update feature REVIEW.md with findings
615
- - [ ] Verify cleanup pass complete
616
- - [ ] Create `.codebase/RECOVERY_POINTS.md` entry for resumption
617
- - [ ] Create or update `.codebase/IMPLEMENTATION_HANDOFF.md`
618
- - [ ] Mark TASKS checklist complete [x]
619
-
620
- Prefer `scripts/create-feature.sh` for the initial folder and file scaffold, then fill the generated files with task-specific content.
621
-
622
- ## `/fix-bug` Workflow
623
-
624
- **IMPORTANT**: Always use `checklists/bug-fix-qa.md` BEFORE starting any bug fix work.
625
-
626
- Before fixing a bug, always:
627
-
628
- ### Step 0: Complete Bug Fix Q&A (MANDATORY)
629
-
630
- ```bash
631
- # Complete the bug fix questionnaire:
632
- cat .codex/skills/genesis-harness/checklists/bug-fix-qa.md
633
-
634
- # Answer all questions:
635
- - Bug clearly reproduced?
636
- - Root cause identified?
637
- - Severity assessed?
638
- - Affected versions known?
639
- - Impact assessed?
640
- - Fix approach decided?
641
- - Regression prevention plan?
642
- - Deployment strategy known?
643
- ```
644
-
645
- If ANY question is unanswered → Stop and get clarification before continuing.
646
-
647
- ### Step 1: Requirements Validation
648
-
649
- After bug Q&A is complete:
650
-
651
- ```bash
652
- # Use requirements validation checklist:
653
- cat .codex/skills/genesis-harness/checklists/requirements-validation.md
654
-
655
- # For bugs, verify:
656
- - Root cause is clear
657
- - Fix approach is feasible
658
- - Test strategy is defined
659
- - No scope creep
660
- - Stakeholders aligned
661
- ```
662
-
663
- ### Step 2: Read Context
664
-
665
- Then read:
666
-
667
- ```txt
668
- .planning/PITFALLS.md
669
- .planning/LESSONS_LEARNED.md
670
- .planning/CONVENTIONS.md
671
- .planning/ARCHITECTURE.md
672
- .planning/STACK.md
673
- ```
674
-
675
- Then reproduce and diagnose before changing code. Create:
676
-
677
- ```txt
678
- .planning/bugs/NNN-bug-slug/
679
- ├── REPORT.md
680
- ├── ROOT_CAUSE.md
681
- ├── PLAN.md
682
- ├── TEST_CONTRACT.md
683
- ├── TASKS.md
684
- ├── VERIFICATION.md
685
- └── REVIEW.md
686
- ```
687
-
688
- ### Step 3: Bug Documentation
689
-
690
- Create `TASKS.md` with checkboxes for:
691
-
692
- **Phase 1: Understanding**
693
- - [ ] Complete `.codex/skills/genesis-harness/checklists/bug-fix-qa.md`
694
- - [ ] Complete `.codex/skills/genesis-harness/checklists/requirements-validation.md`
695
- - [ ] Read PITFALLS.md and LESSONS_LEARNED.md
696
- - [ ] Reproduce bug with exact steps
697
- - [ ] Identify root cause
698
- - [ ] Check for similar bugs in LESSONS_LEARNED.md
699
-
700
- **Phase 2: Planning**
701
- - [ ] Complete REPORT.md (what is broken?)
702
- - [ ] Complete ROOT_CAUSE.md (why is it broken?)
703
- - [ ] Complete PLAN.md (how to fix it?)
704
- - [ ] Create TEST_CONTRACT.md (regression test)
705
- - [ ] Identify risk level (low/medium/high)
706
- - [ ] Plan rollback strategy
707
-
708
- **Phase 3: Implementation**
709
- - [ ] Create regression test (should fail with current code)
710
- - [ ] Fix with minimal change (don't refactor unrelated code)
711
- - [ ] Verify regression test now passes
712
- - [ ] Run full test suite - all pass?
713
-
714
- **Phase 4: Documentation & Sync**
715
- - [ ] Update LESSONS_LEARNED.md with bug finding
716
- - [ ] Check which docs affected
717
- - [ ] Update REQUIREMENTS.md (if behavior changed)
718
- - [ ] Update API_DOCS.md (if API changed)
719
- - [ ] Update .planning/STATE.md
720
- - [ ] Update .planning/SUMMARY.md
721
- - [ ] Update .planning/SPEC_CHANGELOG.md if needed
722
- - [ ] Update .planning/QUALITY_SCORE.md
723
- - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
724
-
725
- **Phase 5: Review & Completion**
726
- - [ ] Review changed files (minimal change?)
727
- - [ ] Update bug REVIEW.md
728
- - [ ] Verify cleanup pass complete
729
- - [ ] Create `.codebase/RECOVERY_POINTS.md` entry
730
- - [ ] Create or update `.codebase/IMPLEMENTATION_HANDOFF.md`
731
- - [ ] Mark TASKS checklist complete [x]
732
-
733
- Append to `.planning/LESSONS_LEARNED.md`:
734
-
735
- ```md
736
- ## Bug: <name>
737
-
738
- Date:
739
- Root cause:
740
- Failed assumption:
741
- Correct pattern:
742
- Prevention rule:
743
- Files changed:
744
- Verification:
745
- ```
746
-
747
- Never fix the same type of bug without checking `LESSONS_LEARNED.md`.
748
-
749
- Prefer `scripts/create-bug.sh` for the initial folder and file scaffold, then fill the generated files with task-specific evidence.
750
-
751
- ## `/api-sync` Workflow
752
-
753
- **NEW**: After implementing API-related features or changes, use the **api-sync-skill** to automatically sync contracts with implementation.
754
-
755
- When API code is modified, invoke:
756
-
757
- ```bash
758
- invoke api-sync-skill
759
-
760
- # Parameters:
761
- - changed_files: [list of API files modified]
762
- - contract_file: ".codebase/API_CONTRACTS.md"
763
- - breaking_changes: true/false
764
- - version_bump: "major/minor/patch"
765
- ```
766
-
767
- This workflow:
768
-
769
- 1. Detects API endpoint changes (new, modified, deprecated)
770
- 2. Extracts request/response schemas from code
771
- 3. Updates API_CONTRACTS.md with all changes
772
- 4. Identifies breaking changes
773
- 5. Generates test contracts
774
- 6. Creates migration guide if needed
775
- 7. Documents version changes
776
-
777
- See `.codex/skills/api-sync-skill/SKILL.md` for full workflow.
778
-
779
- **Important**: Run before committing API changes.
780
-
781
- ## `/spec-change` Workflow
782
-
783
- **NEW**: When a specification document changes, use this to propagate changes to downstream phases.
784
-
785
- When user calls `/spec-change <file>` or notifies you of spec changes:
786
-
787
- ### Step 1: Detect the Change
788
-
789
- ```bash
790
- # User says: "I updated the API response format in API_DOCS.md"
791
-
792
- Harness:
793
- 1. Reads old vs new version of .planning/API_DOCS.md
794
- 2. Identifies what changed (breaking vs additive)
795
- 3. Classifies severity (high/medium/low)
796
- 4. Extracts specific changes (what field changed, how)
797
- ```
798
-
799
- ### Step 2: Query Impact
800
-
801
- ```bash
802
- # Using PHASE_DEPENDENCY_MAP.md
803
-
804
- Query: Which phases depend on the API_DOCS.md changes?
805
-
806
- Example:
807
- - Phase 1 changed: GET /api/users/:id response format
808
- - PHASE_DEPENDENCY_MAP shows:
809
- - Phase 2 imports user_api ← AFFECTED
810
- - Phase 3 imports user_api ← AFFECTED
811
- - Phase 4 imports user_api ← AFFECTED
812
- ```
813
-
814
- ### Step 3: Generate Impact Report
815
-
816
- ```bash
817
- # Create .codebase/IMPACT_REPORT_<timestamp>.md
818
-
819
- Contains:
820
- - What changed (before/after)
821
- - Severity level
822
- - All affected phases
823
- - Estimated impact time (30 min? 2 hours?)
824
- - Recommended fix order
825
- - Rollback strategy
826
- ```
827
-
828
- ### Step 4: Auto-Update (Optional)
829
-
830
- ```bash
831
- # If user says: "Auto-update all affected phases"
832
-
833
- For each affected phase:
834
- 1. Auto-update SPEC.md (replace old API calls)
835
- 2. Auto-update TEST_CONTRACT.md (update assertions)
836
- 3. Auto-update PLAN.md (note breaking change)
837
- 4. Run validation tests
838
- 5. Flag for developer review if HIGH severity
839
- ```
840
-
841
- ### Step 5: Update Tracking
842
-
843
- ```bash
844
- 1. Add entry to SPEC_CHANGELOG.md
845
- 2. Update STATE.md with status
846
- 3. Create notification with impact details
847
- 4. Suggest next steps
848
- ```
849
-
850
- ---
851
-
852
- ## `/propagate-spec` Workflow
853
-
854
- **NEW**: Automatically propagate all pending spec changes to downstream phases.
855
-
856
- When user calls `/propagate-spec`:
857
-
858
- ### Step 1: Find Pending Changes
859
-
860
- ```bash
861
- # Scan SPEC_CHANGELOG.md for entries marked "pending_propagation"
862
-
863
- These are changes that were made but not yet pushed to dependent phases.
864
- ```
865
-
866
- ### Step 2: Identify Affected Phases
867
-
868
- ```bash
869
- # For each pending change:
870
- # 1. Query PHASE_DEPENDENCY_MAP
871
- # 2. Find phases that depend on the changed capability
872
- # 3. Build execution order (upstream first)
873
- ```
874
-
875
- ### Step 3: Auto-Update All Phases
876
-
877
- ```bash
878
- # For each affected phase (in order):
879
-
880
- 1. Update SPEC.md
881
- - Replace old patterns with new ones
882
- - Update examples
883
- - Note breaking changes
884
-
885
- 2. Update TEST_CONTRACT.md
886
- - Update test expectations
887
- - Add migration notes
888
-
889
- 3. Update PLAN.md
890
- - Note: "Depends on Phase N spec change"
891
- - Estimate new work time
892
-
893
- 4. Generate migration guide if breaking change
894
-
895
- 5. Run tests
896
- - If PASS: Mark phase as ready ✓
897
- - If FAIL: Flag for manual review ⚠️
898
- ```
899
-
900
- ### Step 4: Update Timeline
901
-
902
- ```bash
903
- # If any phase specs changed significantly:
904
-
905
- 1. Recalculate ROADMAP.md
906
- - Update phase timelines
907
- - Recalculate critical path
908
- - Notify if project delay > 1 day
909
-
910
- 2. Update STATE.md
911
- - Note propagation completed
912
- - Mark phases as ready to resume
913
- ```
914
-
915
- ### Step 5: Generate Summary
916
-
917
- ```bash
918
- # Create comprehensive report:
919
-
920
- "Spec propagation complete
921
-
922
- Updated phases:
923
- - Phase 2: 1 spec, 3 tests (HIGH severity - requires review)
924
- - Phase 3: 2 specs, 5 tests (MEDIUM - ready to resume)
925
- - Phase 4: 0 changes (LOW severity, no impact)
926
-
927
- Timeline impact: +2 hours estimated work
928
- Critical path: No changes
929
- Status: Ready to proceed
930
-
931
- Next steps:
932
- 1. Review Phase 2 changes
933
- 2. Run tests in Phase 2
934
- 3. Continue Phase 2 implementation"
935
- ```
936
-
937
- ---
938
-
939
- ## `/validate-specs` Workflow
940
-
941
- **NEW**: Check that all phases are aligned with their dependencies.
942
-
943
- When user calls `/validate-specs`:
944
-
945
- ### Step 1: Load Dependency Map
946
-
947
- ```bash
948
- # Read PHASE_DEPENDENCY_MAP.md
949
-
950
- For each phase:
951
- - What it provides
952
- - What it requires
953
- - Which phases it depends on
954
- ```
955
-
956
- ### Step 2: Validate Each Phase
957
-
958
- ```bash
959
- # For each phase N:
960
-
961
- Check: Does phase N's SPEC.md match what upstream provides?
962
-
963
- Example:
964
- Phase 2 spec says: "Uses user_api with { name, email, role }"
965
- Phase 1 API_DOCS says: "Returns { id, name, email, roles[] }"
966
-
967
- Result: MISALIGNED ❌
968
- Phase 2 spec is STALE (3 days old)
969
-
970
- Action: Flag for update
971
- ```
972
-
973
- ### Step 3: Check for Drift
974
-
975
- ```bash
976
- # Detect stale specs:
977
-
978
- For each phase:
979
- 1. How old is SPEC.md?
980
- 2. How old is TEST_CONTRACT.md?
981
- 3. Have upstream phases changed since?
982
- 4. If spec older than upstream change → DRIFT DETECTED
983
-
984
- Report all drifted phases.
985
- ```
986
-
987
- ### Step 4: Identify Breaking Changes Not Propagated
988
-
989
- ```bash
990
- # Query: Are there HIGH severity changes in SPEC_CHANGELOG?
991
- # That haven't been propagated to dependent phases?
992
-
993
- If YES:
994
- - Flag as blocker
995
- - Cannot start downstream phase work until propagated
996
- - Suggest running /propagate-spec
997
- ```
998
-
999
- ### Step 5: Generate Alignment Report
1000
-
1001
- ```bash
1002
- # Create report with:
1003
-
1004
- ✓ Phases in alignment:
1005
- - Phase 1, 3, 4
1006
-
1007
- ❌ Phases with issues:
1008
- - Phase 2: Spec STALE (3 days, Phase 1 changed 2 days ago)
1009
- - Phase 5: Cannot start until Phase 4 propagation complete
1010
-
1011
- ⚠️ Risky:
1012
- - Phase 3 depends on Phase 2 which depends on Phase 1
1013
- - Both Phase 1 and 2 have HIGH severity changes
1014
- - Timeline risk: +4 hours if cascading changes needed
1015
-
1016
- Recommendations:
1017
- 1. Run /propagate-spec immediately
1018
- 2. Re-validate after propagation
1019
- 3. Run tests in all phases
1020
- ```
1021
-
1022
- ---
1023
-
1024
- ## Spec Impact Integration into `/new-feature`
1025
-
1026
- When a feature is completed and phases are affected:
1027
-
1028
- ### Phase 4: Documentation & Sync (Updated)
1029
-
1030
- - [ ] Check CHANGE_IMPACT_MATRIX.md → which docs must update?
1031
- - [ ] Update REQUIREMENTS.md (if behavior/feature added)
1032
- - [ ] Update API_DOCS.md (if API endpoints changed)
1033
- - [ ] Update ARCHITECTURE.md (if structure changed)
1034
- - [ ] Update DESIGN.md (if UI/UX changed)
1035
- - [ ] Update INTEGRATIONS.md (if external services changed)
1036
- - [ ] Update CONVENTIONS.md (if new patterns established)
1037
- - [ ] Update STACK.md (if new tech added)
1038
- - [ ] Update SPEC_CHANGELOG.md with: date, reason, impacted docs, impacted tests, migration notes
1039
- - [ ] Update .planning/STATE.md (current phase, active feature, next task)
1040
- - [ ] Update .planning/SUMMARY.md (recent changes, next recommended task)
1041
- - [ ] Update .planning/FEATURE_INDEX.md (add feature status)
1042
- - [ ] Update .planning/QUALITY_SCORE.md (recalculate scores)
1043
- - [ ] **NEW**: Run `/spec-change <changed-file>` for each updated spec file
1044
- - [ ] **NEW**: Review impact report from spec-impact-engine
1045
- - [ ] **NEW**: Run `/propagate-spec` to auto-update downstream phases
1046
- - [ ] **NEW**: Run `/validate-specs` to confirm all phases aligned
1047
- - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
1048
-
1049
- When the user asks for a plan:
1050
-
1051
- 1. Read required planning docs.
1052
- 2. Research the codebase.
1053
- 3. Research best practices if internet is available.
1054
- 4. Create or update relevant diagrams.
1055
- 5. Write a plan with:
1056
-
1057
- ```md
1058
- ## Goal
1059
-
1060
- ## Current State
1061
-
1062
- ## Research Findings
1063
-
1064
- ## Files to Change
1065
-
1066
- ### File: `path/to/file`
1067
- Change:
1068
- Why:
1069
- Risk:
1070
- Test:
1071
- Docs impact:
1072
-
1073
- ## Test Contract
1074
-
1075
- ## Verification Commands
1076
-
1077
- ## Docs to Update
1078
-
1079
- ## Risks
1080
-
1081
- ## Rollback Plan
1082
- ```
1083
-
1084
- Do not implement unless the user asks to implement or the workflow clearly requires implementation.
1085
-
1086
- ## `/audit` Workflow
1087
-
1088
- 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.
1089
-
1090
- Update:
1091
-
1092
- ```txt
1093
- .planning/audits/architecture-drift.md
1094
- .planning/audits/dependency-audit.md
1095
- .planning/audits/dead-code-audit.md
1096
- .planning/audits/security-audit.md
1097
- .planning/audits/docs-freshness-audit.md
1098
- .planning/QUALITY_SCORE.md
1099
- .planning/STATE.md
1100
- .planning/SUMMARY.md
1101
- ```
1102
-
1103
- Create follow-up tasks if needed. Do not make risky code changes during `/audit` unless explicitly requested.
1104
-
1105
- ## `/review` Workflow
1106
-
1107
- 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.
1108
-
1109
- 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.
1110
-
1111
- ## `/status` Workflow
1112
-
1113
- 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.
1114
-
1115
- Use `.planning/STATE.md`, `.planning/ROADMAP.md`, `.planning/FEATURE_INDEX.md`, and `.planning/SUMMARY.md`. Do not guess.
1116
-
1117
- ## Test-First Rule
1118
-
1119
- Before implementation:
1120
-
1121
- 1. create or update tests
1122
- 2. define input/output expectations
1123
- 3. define edge cases
1124
- 4. run tests and confirm they fail for the expected reason
1125
-
1126
- 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.
1127
-
1128
- ## Implementation Rule
1129
-
1130
- 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.
1131
-
1132
- ## State Continuity & Resumption
1133
-
1134
- **NEW**: After each implementation phase, document state for resumption:
1135
-
1136
- ### Create `.codebase/IMPLEMENTATION_HANDOFF.md`
1137
-
1138
- After successful implementation completion:
1139
-
1140
- ```bash
1141
- # Create handoff document with:
1142
- - What was built (modules created/modified)
1143
- - Current state (what's complete, known issues)
1144
- - Files changed (detailed list)
1145
- - Metrics and status
1146
- - For continuation (resumption instructions)
1147
- - Recovery points (where to resume if paused)
1148
- - Architecture decisions (why this approach?)
1149
- ```
1150
-
1151
- See `.codebase/IMPLEMENTATION_HANDOFF.md` for template.
1152
-
1153
- ### Create `.codebase/RECOVERY_POINTS.md`
1154
-
1155
- Track where work can be safely paused:
1156
-
1157
- ```bash
1158
- # For each phase, document:
1159
- - Phase status (complete, in-progress, paused)
1160
- - What was completed
1161
- - What remains
1162
- - How to resume from this point
1163
- - Rollback procedures
1164
- ```
1165
-
1166
- See `.codebase/RECOVERY_POINTS.md` for template and examples.
1167
-
1168
- ### Use After Implementation
1169
-
1170
- Run this workflow after implementation passes tests:
1171
-
1172
- ```bash
1173
- # 1. Verify all tests passing
1174
- npm test
1175
-
1176
- # 2. Auto-detect changes and sync docs
1177
- ./scripts/detect-changes.sh
1178
-
1179
- # 3. Follow post-implementation guide
1180
- cat .codex/skills/genesis-harness/resources/post-implementation-guide.md
1181
-
1182
- # 4. Update state tracking
1183
- cat .codebase/IMPLEMENTATION_HANDOFF.md # Fill out
1184
- cat .codebase/RECOVERY_POINTS.md # Fill out
1185
-
1186
- # 5. Verify all docs in sync
1187
- ./scripts/check-docs-sync.sh
1188
- ```
1189
-
1190
- ## Docs Sync Rule
1191
-
1192
- **CRITICAL**: Whenever implementation changes behavior, API, data model, UI, integration, architecture, convention, config, environment variable, security behavior, or requirement, update ALL related docs.
1193
-
1194
- Reference `.planning/CHANGE_IMPACT_MATRIX.md` to identify which docs must be updated based on change type.
1195
-
1196
- Possible docs to update:
1197
-
1198
- - `.planning/REQUIREMENTS.md` - If feature/behavior/requirement changed
1199
- - `.planning/API_DOCS.md` - If endpoints/schemas/auth changed
1200
- - `.planning/ARCHITECTURE.md` - If module boundaries/data flow changed
1201
- - `.planning/DESIGN.md` - If UI/UX/screens/components changed
1202
- - `.planning/INTEGRATIONS.md` - If external services/env vars changed
1203
- - `.planning/STACK.md` - If tech stack/versions/commands changed
1204
- - `.planning/CONVENTIONS.md` - If patterns/style/rules changed
1205
- - `.planning/ROADMAP.md` - If timeline/phases/priorities changed
1206
- - `.planning/STATE.md` - ALWAYS update (current phase, active work, next task)
1207
- - `.planning/SPEC_CHANGELOG.md` - ALWAYS update (date, reason, impacted docs)
1208
- - `.planning/QUALITY_SCORE.md` - Update with new metrics
1209
- - `.planning/OBSERVABILITY.md` - If logging/metrics/traces changed
1210
- - `.planning/SMOKE_TESTS.md` - If verification paths changed
1211
- - `.planning/JOURNEYS.md` - If user flows changed
1212
- - `.planning/diagrams/*.mmd` - If architecture/flow changed
1213
- - `.planning/decisions/*.md` - If ADR-level changes made
1214
- - `.planning/features/*/*.md` - Update feature folder docs
1215
- - `.planning/FEATURE_INDEX.md` - Update feature table
1216
-
1217
- **Docs Sync Checklist (from TASKS.md)**:
1218
- - [ ] Check CHANGE_IMPACT_MATRIX.md for required updates
1219
- - [ ] Update all applicable docs from list above
1220
- - [ ] Add entry to SPEC_CHANGELOG.md with date and reason
1221
- - [ ] Update STATE.md and SUMMARY.md
1222
- - [ ] Recalculate QUALITY_SCORE.md
1223
-
1224
- If no docs need updating, explicitly state why in the completion report (e.g., "Internal refactor, no behavior change").
1225
-
1226
- ## Decision Record Rule
1227
-
1228
- Use ADR files for important decisions. Create files like `.planning/decisions/ADR-003-use-postgres.md`.
1229
-
1230
- Each ADR must include status, context, decision, alternatives considered, consequences, risks, mitigation, and verification evidence.
1231
-
1232
- 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.
1233
-
1234
- Prefer `scripts/create-adr.sh` for ADR numbering and starter content.
1235
-
1236
- ## Quality Rubric
1237
-
1238
- Use this rubric when updating `QUALITY_SCORE.md`:
1239
-
1240
- | Score | Meaning |
1241
- |---:|---|
1242
- | 0 | Unknown, absent, or not evaluated |
1243
- | 2 | Known major gaps with no mitigation |
1244
- | 4 | Basic structure exists but is inconsistent or mostly manual |
1245
- | 6 | Working baseline with known gaps and follow-up tasks |
1246
- | 8 | Strong, verified, documented, and mostly automated |
1247
- | 10 | Mature, automated, documented, reviewed, and low-risk |
1248
-
1249
- Area guidance:
1250
-
1251
- - Architecture: module boundaries, dependency direction, diagrams, ADRs, forbidden patterns.
1252
- - Tests: regression coverage, smoke tests, edge cases, failing-first evidence, CI/local repeatability.
1253
- - Docs Sync: docs updated with behavior changes, changelog entries, impact matrix compliance.
1254
- - Security: auth, secrets, data protection, dependency risk, destructive-operation safeguards.
1255
- - Maintainability: naming, duplication, dead code, conventions, file/module size, refactor risk.
1256
- - Observability: logs, metrics, traces, errors, health checks, debug commands, inspection workflow.
1257
-
1258
- ## Mechanical Checks Rule
1259
-
1260
- When possible, use or create scripts that check harness consistency. Scripts should include:
1261
-
1262
- ```txt
1263
- scripts/check-docs-sync.sh
1264
- scripts/check-task-tracking.sh
1265
- scripts/check-no-debug-logs.sh
1266
- scripts/check-spec-changelog.sh
1267
- scripts/check-required-planning-files.sh
1268
- scripts/check-architecture-boundaries.sh
1269
- scripts/run-verification.sh
1270
- ```
1271
-
1272
- These scripts do not need to be perfect, but they should provide practical guardrails. Document all checks in `.planning/checks/CHECKS.md`.
1273
-
1274
- ## Escalation Rule
1275
-
1276
- 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.
1277
-
1278
- Record escalations in `.planning/ESCALATION.md`.
1279
-
1280
- ## Review Rule
1281
-
1282
- 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.
1283
-
1284
- Record the review in the related feature `REVIEW.md`, bug `REVIEW.md`, phase `REVIEW.md`, and `.planning/SUMMARY.md`.
1285
-
1286
- ## Completion Report Rule
1287
-
1288
- Final response must include:
1289
-
1290
- ```md
1291
- ## Completed
1292
-
1293
- - What was done
1294
-
1295
- ## Planning Updated
1296
-
1297
- - Files updated under `.planning/`
1298
-
1299
- ## Code Changed
1300
-
1301
- - Files changed
1302
-
1303
- ## Tests / Verification
1304
-
1305
- - Tests added/updated
1306
- - Commands run
1307
- - Result
1308
-
1309
- ## Docs Sync
1310
-
1311
- - Docs updated
1312
- - If none, explain why
1313
-
1314
- ## Tracking
1315
-
1316
- - Tasks changed from `[ ]` or `[~]` to `[x]`
1317
-
1318
- ## Review
1319
-
1320
- - Changed files reviewed
1321
- - Cleanup performed
1322
-
1323
- ## Risks / Follow-up
1324
-
1325
- - Remaining risks
1326
- - Suggested next step
1327
- ```
1328
-
1329
- 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.
1330
-
1331
- ## Default `config.json`
1332
-
1333
- When initializing, create:
1334
-
1335
- ```json
1336
- {
1337
- "workflow": {
1338
- "init_requires_confirmation": true,
1339
- "research_before_plan": true,
1340
- "best_practice_research": true,
1341
- "diagram_before_implementation": true,
1342
- "test_first": true,
1343
- "task_tracking": true,
1344
- "docs_sync_required": true,
1345
- "lessons_read_required": true,
1346
- "code_review": true,
1347
- "cleanup_pass": true,
1348
- "mechanical_checks": true,
1349
- "audit_supported": true,
1350
- "escalation_required": true
1351
- },
1352
- "tracking": {
1353
- "todo": "[ ]",
1354
- "in_progress": "[~]",
1355
- "done": "[x]",
1356
- "blocked": "[!]"
1357
- },
1358
- "required_reads_before_work": [
1359
- ".planning/SUMMARY.md",
1360
- ".planning/STATE.md",
1361
- ".planning/PITFALLS.md",
1362
- ".planning/LESSONS_LEARNED.md",
1363
- ".planning/CONVENTIONS.md",
1364
- ".planning/ARCHITECTURE.md",
1365
- ".planning/STACK.md"
1366
- ],
1367
- "docs_sync_targets": [
1368
- ".planning/REQUIREMENTS.md",
1369
- ".planning/API_DOCS.md",
1370
- ".planning/ARCHITECTURE.md",
1371
- ".planning/DESIGN.md",
1372
- ".planning/INTEGRATIONS.md",
1373
- ".planning/CONVENTIONS.md",
1374
- ".planning/ROADMAP.md",
1375
- ".planning/STATE.md",
1376
- ".planning/SPEC_CHANGELOG.md",
1377
- ".planning/QUALITY_SCORE.md",
1378
- ".planning/OBSERVABILITY.md",
1379
- ".planning/JOURNEYS.md",
1380
- ".planning/SMOKE_TESTS.md"
1381
- ],
1382
- "mermaid_required_for": [
1383
- "architecture",
1384
- "database",
1385
- "api_flow",
1386
- "integration",
1387
- "deployment",
1388
- "feature_flow",
1389
- "auth_flow",
1390
- "background_job_flow"
1391
- ],
1392
- "escalate_when": [
1393
- "ambiguous_product_intent",
1394
- "conflicting_requirements",
1395
- "breaking_api_change",
1396
- "destructive_migration",
1397
- "possible_user_data_loss",
1398
- "missing_credentials",
1399
- "paid_external_service_required",
1400
- "unclear_security_tradeoff",
1401
- "legal_or_compliance_risk"
1402
- ]
1403
- }
1404
- ```
1405
-
1406
- ## Final Hard Rules
1407
-
1408
- 1. `/init` must not blindly create implementation code.
1409
- 2. If the app idea is missing or ambiguous, ask for confirmation first.
1410
- 3. Create root `AGENTS.md` as a concise table of contents.
1411
- 4. Every task must be tracked with `[ ]`, `[~]`, `[x]`, or `[!]`.
1412
- 5. Do not say a task is done unless tracking files are updated.
1413
- 6. Every behavior/spec/API/DB/UI/integration/config/security change must update related docs.
1414
- 7. Before bug fix or feature work, always read `PITFALLS.md`, `LESSONS_LEARNED.md`, `CONVENTIONS.md`, `ARCHITECTURE.md`, and `STACK.md`.
1415
- 8. Every bug fix must append a lesson to `LESSONS_LEARNED.md`.
1416
- 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`.
1417
- 10. Plans must clearly say what changes, where it changes, why it changes, risks, docs impact, and verification commands.
1418
- 11. Research best practices before planning when internet is available.
1419
- 12. Never invent external research results.
1420
- 13. Mermaid diagrams must be updated before architecture-impacting implementation.
1421
- 14. Tests or verification must be created before implementation.
1422
- 15. Review changed files after verification passes.
1423
- 16. Remove unnecessary files, debug logs, dead code, and unrelated changes.
1424
- 17. Use ADRs for major technical decisions.
1425
- 18. Use `/audit` to detect architecture drift, stale docs, dead code, missing tests, and quality gaps.
1426
- 19. Escalate to the user when human judgment is required.
1427
- 20. Final response must include changed files, tests, docs sync, tracking updates, review result, and remaining risks.
1
+ ---
2
+ name: 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
+ ## Purpose
13
+ Operate a repository through test-first, contract-first, memory-aware Codex workflows.
14
+
15
+ ## When to use
16
+ Use for project initialization, planning, feature work, bug fixes, audits, reviews, verification, and repository memory updates.
17
+
18
+ ## When NOT to use
19
+ Do not use for simple read-only answers that do not require repository workflow or durable artifacts.
20
+
21
+ ## Inputs required
22
+ Read `.codebase/state.json` (MANDATORY on boot), `.codebase/CURRENT_STATE.md`, `.codebase/MODULE_INDEX.md`, and `.codebase/TEST_MATRIX.md` when present, then inspect only relevant files.
23
+
24
+ ## Outputs required
25
+ Plan or implementation artifact, tests, fixtures, verification evidence, docs sync, and codebase memory updates.
26
+
27
+ ## Required tests
28
+ Create or update failing tests before implementation.
29
+
30
+ ## Required fixtures
31
+ Create fixtures for expected inputs, outputs, validation notes, and recovery cases.
32
+
33
+ ## Required contract updates
34
+ Update API, agent, event, or UI contracts when public behavior changes.
35
+
36
+ ## Required codebase map updates
37
+ Update `.codebase` memory after meaningful changes.
38
+
39
+ ## Token saving rules
40
+ Read summaries before source files, maps before modules, and avoid loading the entire repository.
41
+
42
+ ## Acceptance criteria
43
+ Work is complete only when tests pass, contracts and docs are current, and verification evidence is reported.
44
+
45
+ ## Common mistakes
46
+ Implementing before tests, skipping fixtures, overloading `AGENTS.md`, and duplicating long context across skills.
47
+
48
+ ## Recovery workflow
49
+ If blocked or interrupted, read `.codebase/state.json` to identify your exact FSM state. Rerun verification, identify the first failing phase, and resume from that point based on the strict state rules.
50
+
51
+ ## Core Principle
52
+
53
+ Do not code first.
54
+
55
+ Correct order:
56
+
57
+ ```txt
58
+ Confirm intent
59
+ -> Inspect repository
60
+ -> Initialize planning
61
+ -> Research
62
+ -> Decide
63
+ -> Diagram
64
+ -> Plan
65
+ -> Test contract
66
+ -> Implement
67
+ -> Verify
68
+ -> Review
69
+ -> Sync docs
70
+ -> Track completion
71
+ -> Report
72
+ ```
73
+
74
+ Never skip confirmation when intent is unclear, research, planning, test or verification, docs synchronization, task tracking, or review.
75
+
76
+ ## Supported Commands
77
+
78
+ Support these user intents:
79
+
80
+ ```txt
81
+ /init
82
+ /new-feature <description>
83
+ /fix-bug <description>
84
+ /plan <description>
85
+ /audit
86
+ /review
87
+ /status
88
+ /spec-change <file> [NEW]
89
+ /propagate-spec [NEW]
90
+ /validate-specs [NEW]
91
+ ```
92
+
93
+ If the user does not type an exact command but clearly asks for one of these workflows, infer the correct workflow.
94
+
95
+ ## NEW: Spec Impact & Propagation Commands
96
+
97
+ These commands enable automatic cascade prevention:
98
+
99
+ ### `/spec-change <file>` - Detect & Analyze Spec Changes
100
+
101
+ ```bash
102
+ /spec-change .planning/API_DOCS.md
103
+
104
+ What it does:
105
+ 1. Detects what changed in the file
106
+ 2. Identifies breaking changes vs feature additions
107
+ 3. Finds all downstream phases that depend on the change
108
+ 4. Calculates impact severity (high/medium/low)
109
+ 5. Generates impact report with recommendations
110
+ 6. Offers to auto-update all affected phases
111
+ ```
112
+
113
+ ### `/propagate-spec` - Auto-Update Downstream Phases
114
+
115
+ ```bash
116
+ /propagate-spec
117
+
118
+ What it does:
119
+ 1. Checks SPEC_CHANGELOG.md for unpropagated changes
120
+ 2. Queries PHASE_DEPENDENCY_MAP for affected phases
121
+ 3. AUTO-UPDATES all dependent phase specs
122
+ 4. AUTO-UPDATES all affected phase tests
123
+ 5. Runs validation tests in all phases
124
+ 6. Generates migration guides for breaking changes
125
+ 7. Updates ROADMAP.md if timeline affected
126
+ 8. Creates comprehensive impact report
127
+ ```
128
+
129
+ ### `/validate-specs` - Check All Phases Aligned
130
+
131
+ ```bash
132
+ /validate-specs
133
+
134
+ What it does:
135
+ 1. Validates all phases against their dependencies
136
+ 2. Detects spec drift (phase using stale upstream specs)
137
+ 3. Identifies breaking changes not yet propagated
138
+ 4. Lists any alignment issues
139
+ 5. Suggests fixes
140
+ 6. Blocks start of phase if upstream specs incomplete
141
+ ```
142
+
143
+ ## Resource And Script Map
144
+
145
+ Bundled resources live under `resources/`. Use them as starting content when creating `.planning/` files:
146
+
147
+ - `planning-tree-template.md`: required `.planning/` tree.
148
+ - `agents-template.md`: concise root `AGENTS.md`.
149
+ - `project-template.md` through `check-template.md`: starter content for project, phase, feature, bug, ADR, research, review, verification, audit, and check files.
150
+ - `post-implementation-guide.md`: Auto-update workflow after successful implementation. Guides doc synchronization, state tracking, and continuity.
151
+ - `requirements-validation.md`: Final validation checklist before implementation to ensure all requirements are clear and complete.
152
+
153
+ Bundled checklists live under `checklists/`. Use these as structured Q&A before planning:
154
+
155
+ - **MANDATORY**: `new-feature-qa.md`: Comprehensive Q&A for new features. Complete before `/new-feature` planning.
156
+ - **MANDATORY**: `bug-fix-qa.md`: Comprehensive Q&A for bug fixes. Complete before `/fix-bug` planning.
157
+ - **MANDATORY**: `refactor-qa.md`: Comprehensive Q&A for refactors. Complete before refactor planning.
158
+ - **MANDATORY**: `requirements-validation.md`: Final validation checklist. Use after Q&A, before contracts and tests.
159
+ - `checklist.md`: General Genesis Harness workflow checklist.
160
+
161
+ Bundled skills live under `skills/`. These are specialized automation tools:
162
+
163
+ - **NEW**: `spec-impact-engine/SKILL.md`: Automatically detect when specs change and update all downstream phases. Prevents cascading rework.
164
+ - `api-sync-skill/SKILL.md`: Auto-sync API contracts with implementation after changes.
165
+ - `docs-skill/SKILL.md`: Auto-update documentation after implementation.
166
+
167
+ Bundled references live under `references/`. Load them only when needed:
168
+
169
+ - `references/workflows.md`: command routing, readiness gate, and completion gate.
170
+ - `references/planning-schema.md`: detailed `.planning/` file meanings and required subtrees.
171
+ - `references/research-rubric.md`: local/external evidence format for research.
172
+ - `references/quality-rubric.md`: scoring rubric for `QUALITY_SCORE.md`.
173
+
174
+ Bundled scripts live under `scripts/`. Prefer copying or adapting these into `.planning/scripts/` or project scripts during `/init`:
175
+
176
+ - `init-planning.sh`: creates `AGENTS.md` and the `.planning/` tree.
177
+ - `create-feature.sh`: scaffolds `.planning/features/NNN-feature-slug/`.
178
+ - `create-bug.sh`: scaffolds `.planning/bugs/NNN-bug-slug/`.
179
+ - `create-adr.sh`: scaffolds `.planning/decisions/ADR-NNN-slug.md`.
180
+ - `update-state.sh`: updates common fields in `.planning/STATE.md`.
181
+ - **NEW**: `transition_state.sh`: Strict FSM transition script. You MUST use this script to move between `INIT`, `REQUIREMENTS_GATHERING`, `PLANNING`, `IMPLEMENTATION`, `VERIFICATION`, and `COMPLETED` states.
182
+ - `offload-log.sh`: captures and trims large command outputs to protect the context window.
183
+ - `compact-context.sh`: intelligent context compaction summarizing state to disk.
184
+ - `run-verify-loop.sh`: state-tracked Ralph Loop verify-fix loop executor.
185
+ - `detect-stack.sh`: inspects repository stack clues.
186
+ - `list-changed-files.sh`: lists git changes when git is available.
187
+ - `run-verification.sh`: runs detected lint/typecheck/test/build checks.
188
+ - `detect-changes.sh`: Auto-detect file changes and identify what `.codebase` docs need updating.
189
+ - `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.
190
+ - **NEW**: `spec-impact-engine/detect-spec-changes.sh`: Auto-detect spec changes and generate impact report.
191
+
192
+ ## `/init` Workflow
193
+
194
+ When the user types `/init`, initialize the project planning harness. Before creating files, inspect the current repository.
195
+
196
+ **Important**: Do not create feature-specific phases. Create only a Foundation phase (Phase 0) as a planning framework. Feature phases are created only after requirements are confirmed and roadmap is finalized.
197
+
198
+ Look for:
199
+
200
+ - `README.md`
201
+ - `AGENTS.md`
202
+ - `package.json`
203
+ - `composer.json`
204
+ - `pyproject.toml`
205
+ - `requirements.txt`
206
+ - `Cargo.toml`
207
+ - `go.mod`
208
+ - `*.csproj` or `*.sln`
209
+ - `Dockerfile`
210
+ - `docker-compose.yml`
211
+ - `src/` or `app/`
212
+ - existing docs
213
+ - existing tests
214
+ - existing API routes
215
+ - existing database schema
216
+ - existing architecture clues
217
+
218
+ ### Confirmation Rule
219
+
220
+ If there is enough information to infer the product idea, summarize the detected project brief and ask for confirmation:
221
+
222
+ ```md
223
+ ## Detected Project Brief
224
+
225
+ Product:
226
+ Target users:
227
+ Core features:
228
+ Tech stack:
229
+ Integrations:
230
+ First milestone:
231
+ Out of scope:
232
+ Assumptions:
233
+
234
+ Please confirm before I initialize `.planning/`.
235
+
236
+ Note: I will create a Foundation phase (Phase 0) for documentation
237
+ only. Feature phases will be created later when requirements are finalized.
238
+ ```
239
+
240
+ If the app idea is missing or ambiguous, stop and ask:
241
+
242
+ 1. What application are we building?
243
+ 2. Who are the target users?
244
+ 3. What are the core features?
245
+ 4. What tech stack do you prefer?
246
+ 5. What integrations are required?
247
+ 6. What is explicitly out of scope?
248
+ 7. What is the first milestone?
249
+ 8. Are there any design, architecture, security, or deployment constraints?
250
+
251
+ Do not create implementation code until the project idea is confirmed.
252
+
253
+ After confirmation, create root `AGENTS.md`, the `.planning/` structure, initial planning files, base Mermaid diagrams, a Foundation phase (Phase 0) as planning framework only, initial checks, the initial quality score, and the phase dependency map. Use `scripts/init-planning.sh` when it fits the repository.
254
+
255
+ **Foundation Phase (Phase 0)**: This is a setup phase only, not a feature phase. It contains:
256
+ - Tasks to complete project documentation
257
+ - No feature implementation tasks
258
+ - Placeholder roadmap with no feature phases yet
259
+
260
+ **Phase Dependency Map**: Created as `.codebase/PHASE_DEPENDENCY_MAP.md`, this is:
261
+ - Mapping of which phases provide what
262
+ - Which phases depend on which other phases
263
+ - Impact calculation rules for spec changes
264
+ - Timeline sensitivity analysis
265
+ - Used by spec-impact-engine for auto-updates
266
+
267
+ Feature phases must not be created until requirements are finalized and prioritized. Each feature gets its own numbered phase folder when work begins.
268
+
269
+ `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.
270
+
271
+ ## Root `AGENTS.md`
272
+
273
+ 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/`.
274
+
275
+ Minimum contents:
276
+
277
+ ```md
278
+ # AGENTS.md
279
+
280
+ This repository uses the Project Genesis Harness.
281
+
282
+ Before doing feature work, bug fixes, refactors, or architecture changes, read:
283
+
284
+ 1. `.planning/SUMMARY.md`
285
+ 2. `.planning/STATE.md`
286
+ 3. `.planning/PROJECT.md`
287
+ 4. `.planning/REQUIREMENTS.md`
288
+ 5. `.planning/STACK.md`
289
+ 6. `.planning/ARCHITECTURE.md`
290
+ 7. `.planning/CONVENTIONS.md`
291
+ 8. `.planning/PITFALLS.md`
292
+ 9. `.planning/LESSONS_LEARNED.md`
293
+
294
+ For new features, create a folder under `.planning/features/`.
295
+ For bug fixes, create a folder under `.planning/bugs/`.
296
+ For major decisions, create an ADR under `.planning/decisions/`.
297
+
298
+ Do not claim completion unless verification passed, docs were synchronized, task tracking was updated, and changed files were reviewed.
299
+ ```
300
+
301
+ Keep `AGENTS.md` concise.
302
+
303
+ ## Required `.planning/` Architecture
304
+
305
+ Create the full tree described in `resources/planning-tree-template.md`, including:
306
+
307
+ - 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`
308
+ - diagrams: `system-context.mmd`, `container-architecture.mmd`, `database-erd.mmd`, `deployment-flow.mmd`, `roadmap-flow.mmd`
309
+ - research, decisions, phases, features, bugs, audits, checks, quick, codebase, and templates folders.
310
+
311
+ ## Meaning Of Core Files
312
+
313
+ - `PROJECT.md`: project identity, target users, value, scope, out of scope, constraints, assumptions, current milestone, success criteria.
314
+ - `REQUIREMENTS.md`: functional and non-functional requirements, user stories, acceptance criteria, edge cases, known unknowns.
315
+ - `ROADMAP.md`: milestones, phases, dependencies, status, acceptance criteria.
316
+ - `STATE.md`: current phase, active feature or bug, last completed task, next task, blockers, latest verification.
317
+ - `STACK.md`: language, framework, runtime, database, package manager, test framework, lint/typecheck tools, deployment target, versions, local commands.
318
+ - `ARCHITECTURE.md`: architecture, module boundaries, data flow, dependency direction, service boundaries, principles, forbidden patterns.
319
+ - `DESIGN.md`: UX principles, screens/pages, component conventions, state management, accessibility, constraints.
320
+ - `API_DOCS.md`: endpoints, examples, errors, auth, versioning.
321
+ - `INTEGRATIONS.md`: services, SDKs, env vars, secrets, failure handling, fallbacks, rate limits.
322
+ - `CONVENTIONS.md`: naming, folders, style, errors, logging, tests, API rules, security rules, patterns to follow and avoid.
323
+ - `PITFALLS.md`: common mistakes, risky areas, fragile dependencies, historical warnings.
324
+ - `LESSONS_LEARNED.md`: fixed bugs, root causes, failed assumptions, correct patterns, prevention rules, changed files, verification evidence.
325
+ - `SPEC_CHANGELOG.md`: every spec-affecting change with date/time, reason, impacted docs, impacted tests, migration notes.
326
+ - `FEATURE_INDEX.md`: table of features with status, phase, path, notes.
327
+ - `CHANGE_IMPACT_MATRIX.md`: mapping from change types to docs that must update.
328
+ - `QUALITY_SCORE.md`: quality areas and scores; update during `/audit`, `/review`, major features, and major bug fixes.
329
+ - `ESCALATION.md`: when Codex must stop and ask the user.
330
+ - `OBSERVABILITY.md`: logs, metrics, traces, errors, health checks, debug commands, local inspection.
331
+ - `JOURNEYS.md`: important user journeys with expected UI/API/DB/log state and verification.
332
+ - `SMOKE_TESTS.md`: minimal checks proving the app is alive.
333
+
334
+ ## Task Tracking Rule
335
+
336
+ Every phase, feature, bug, audit, and task must use checkbox tracking:
337
+
338
+ ```txt
339
+ [ ] not started
340
+ [~] in progress
341
+ [x] completed
342
+ [!] blocked
343
+ ```
344
+
345
+ When a task is started:
346
+
347
+ 1. update checkbox from `[ ]` to `[~]`
348
+ 2. update `.planning/STATE.md`
349
+
350
+ When a task is completed:
351
+
352
+ 1. update checkbox from `[~]` or `[ ]` to `[x]`
353
+ 2. update `.planning/STATE.md`
354
+ 3. update related phase `TASKS.md`
355
+ 4. update related feature or bug `TASKS.md` if applicable
356
+ 5. update `.planning/SUMMARY.md`
357
+
358
+ Never claim a task is complete unless tracking files were updated.
359
+
360
+ ## Definition Of Ready
361
+
362
+ Feature, bug, phase, audit, and architecture work is ready to implement only when:
363
+
364
+ - [x] product intent or bug report is clear enough to avoid guessing
365
+ - [x] required planning docs were read
366
+ - [x] relevant local codebase patterns were researched
367
+ - [x] best-practice research is recorded or internet unavailability is stated
368
+ - [x] impact on API, data, UI, auth, integrations, config, docs, and tests is known
369
+ - [x] test contract or verification contract exists
370
+ - [x] diagram or ADR impact is handled when architecture changes
371
+ - [x] escalation concerns were resolved or explicitly recorded
372
+
373
+ If any item is false, do not implement. Update tracking to `[!]` or ask the user.
374
+
375
+ ## Validation Gates
376
+
377
+ Before moving to the `COMPLETED` state, the agent MUST pass the validation gates:
378
+ - Run `bash scripts/validation_gates.sh`
379
+ - Ensure no leftover `TODO`, `FIXME`, `console.log`, or `print` statements remain in production code.
380
+ - Ensure all tests and `verify.sh` checks pass.
381
+ - If the validation gates fail, the agent is forced to remain in `VERIFICATION` or return to `IMPLEMENTATION` to fix the issues.
382
+
383
+ ## Definition Of Done
384
+
385
+ Work is done only when:
386
+
387
+ - [x] implementation is complete and scoped to the plan
388
+ - [x] automated tests or documented verification passed
389
+ - [x] docs were synchronized (see Docs Sync Rule below)
390
+ - [x] task tracking moved from `[ ]` or `[~]` to `[x]`
391
+ - [x] `.planning/STATE.md` updated (current phase, active feature, next task)
392
+ - [x] `.planning/SUMMARY.md` updated (recent changes, next recommended task)
393
+ - [x] `.planning/SPEC_CHANGELOG.md` updated if behavior/API/requirements changed
394
+ - [x] `.planning/QUALITY_SCORE.md` recalculated
395
+ - [x] `.planning/FEATURE_INDEX.md` updated with feature status
396
+ - [x] changed files were reviewed
397
+ - [x] debug logs, dead code, unrelated edits, and unnecessary files were removed
398
+ - [x] risks and follow-up tasks are recorded
399
+
400
+ **Never use completion language until ALL items above are satisfied.**
401
+
402
+ If a doc doesn't need updating, explicitly explain why in the completion report.
403
+
404
+ ## Research Rule
405
+
406
+ Before planning or implementing any non-trivial task:
407
+
408
+ 1. Research the existing codebase.
409
+ 2. Identify similar patterns already present.
410
+ 3. Research best practices using official docs, Google, GitHub, or reputable sources when internet access is available.
411
+ 4. Record findings in `.planning/research/`.
412
+ 5. Mention evidence in the plan.
413
+
414
+ 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.
415
+
416
+ Use this evidence format in `.planning/research/`:
417
+
418
+ ```md
419
+ ## Research: <topic>
420
+
421
+ Date:
422
+ Question:
423
+
424
+ ## Local Evidence
425
+
426
+ | File / Command | Finding | Impact |
427
+ |---|---|---|
428
+ | `path/to/file` | TBD | TBD |
429
+
430
+ ## External Evidence
431
+
432
+ | Source | Date Checked | Finding | Impact |
433
+ |---|---|---|---|
434
+ | URL or official doc name | YYYY-MM-DD | TBD | TBD |
435
+
436
+ ## Decision Impact
437
+
438
+ - [ ] TBD
439
+
440
+ ## Confidence / Gaps
441
+
442
+ - [ ] TBD
443
+ ```
444
+
445
+ 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.
446
+
447
+ ## Mermaid Diagram Rule
448
+
449
+ 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.
450
+
451
+ Required base diagrams:
452
+
453
+ ```txt
454
+ .planning/diagrams/system-context.mmd
455
+ .planning/diagrams/container-architecture.mmd
456
+ .planning/diagrams/database-erd.mmd
457
+ .planning/diagrams/deployment-flow.mmd
458
+ .planning/diagrams/roadmap-flow.mmd
459
+ ```
460
+
461
+ A feature must also have `.planning/features/NNN-feature-name/DIAGRAM.mmd`. Do not implement architecture-changing work before updating the relevant diagram.
462
+
463
+ ## `/new-feature` Workflow
464
+
465
+ **IMPORTANT**: Always use `checklists/new-feature-qa.md` BEFORE starting any feature work.
466
+
467
+ When adding a new feature:
468
+
469
+ ### Step 0: Complete Q&A Checklist (MANDATORY)
470
+
471
+ ```bash
472
+ # Before any planning, complete:
473
+ cat .codex/skills/genesis-harness/checklists/new-feature-qa.md
474
+
475
+ # Answer all questions:
476
+ - User story clearly defined?
477
+ - Success criteria measurable?
478
+ - Out of scope documented?
479
+ - Requirements clear?
480
+ - API/database/UI impacts known?
481
+ - Edge cases identified?
482
+ - Test strategy defined?
483
+ - No unknowns remaining?
484
+ ```
485
+
486
+ If ANY question is unanswered → Stop and get clarification before continuing.
487
+
488
+ ### Step 1: Requirements Validation
489
+
490
+ After Q&A is complete, validate requirements:
491
+
492
+ ```bash
493
+ # Use requirements validation checklist:
494
+ cat .codex/skills/genesis-harness/checklists/requirements-validation.md
495
+
496
+ # Verify:
497
+ - All items are specific and measurable
498
+ - Scope is bounded
499
+ - Technical feasibility confirmed
500
+ - Acceptance criteria are testable
501
+ - Stakeholder alignment obtained
502
+ ```
503
+
504
+ If ANY validation fails → Do not continue. Fix before proceeding.
505
+
506
+ ### Step 2: Confirm Definition of Ready
507
+
508
+ Then read:
509
+
510
+ ```txt
511
+ .planning/SUMMARY.md
512
+ .planning/STATE.md
513
+ .planning/PITFALLS.md
514
+ .planning/LESSONS_LEARNED.md
515
+ .planning/CONVENTIONS.md
516
+ .planning/ARCHITECTURE.md
517
+ .planning/STACK.md
518
+ ```
519
+
520
+ Verify ALL of these are TRUE:
521
+
522
+ ```
523
+ [ ] Q&A checklist completed and all questions answered
524
+ [ ] Requirements validation passed
525
+ [ ] Product intent is clear enough to avoid guessing
526
+ [ ] Required planning docs were read (7 docs above)
527
+ [ ] Relevant local codebase patterns were researched
528
+ [ ] Best-practice research is recorded or internet unavailability stated
529
+ [ ] Impact on API, database, UI, auth, integrations, config, docs, and tests is KNOWN
530
+ [ ] Test contract or verification contract will be created
531
+ [ ] Diagram or ADR impact is handled if architecture changes
532
+ [ ] Escalation concerns are resolved or explicitly recorded
533
+
534
+ If ANY checkbox is FALSE → Do not continue.
535
+ Ask user for clarification or update tracking to [!] blocked.
536
+ ```
537
+
538
+ ### Step 3: Research & Plan
539
+
540
+ Research local patterns and best practices. Create:
541
+
542
+ ```txt
543
+ .planning/features/NNN-feature-slug/
544
+ ├── SPEC.md
545
+ ├── IMPACT.md
546
+ ├── PLAN.md
547
+ ├── TEST_CONTRACT.md
548
+ ├── TASKS.md
549
+ ├── VERIFICATION.md
550
+ ├── REVIEW.md
551
+ └── DIAGRAM.mmd
552
+ ```
553
+
554
+ `SPEC.md` must include summary, user story, expected behavior, edge cases, out of scope, and acceptance criteria.
555
+
556
+ `IMPACT.md` must answer whether the feature affects API, database, UI, auth/security, integrations, environment variables, architecture, docs, tests, migrations, or existing user journeys.
557
+
558
+ `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:
559
+
560
+ ```md
561
+ ### File: `path/to/file`
562
+
563
+ Change:
564
+ Why:
565
+ Risk:
566
+ Test:
567
+ Docs impact:
568
+ ```
569
+
570
+ `TEST_CONTRACT.md` must include normal input/output, edge cases, invalid inputs, expected errors, acceptance tests, and manual verification if automated tests are unavailable.
571
+
572
+ `TASKS.md` must include checkbox tasks for:
573
+
574
+ **Phase 1: Confirmation & Research**
575
+ - [ ] Complete `.codex/skills/genesis-harness/checklists/new-feature-qa.md`
576
+ - [ ] Complete `.codex/skills/genesis-harness/checklists/requirements-validation.md`
577
+ - [ ] Read required `.planning/` docs (SUMMARY, STATE, PITFALLS, LESSONS, CONVENTIONS, ARCHITECTURE, STACK)
578
+ - [ ] Verify Definition of Ready (all 10 items confirmed YES)
579
+
580
+ **Phase 2: Planning & Contracts**
581
+ - [ ] Research codebase patterns for similar features
582
+ - [ ] Research best practices (external sources or mark unavailable)
583
+ - [ ] Complete SPEC.md with full acceptance criteria
584
+ - [ ] Complete IMPACT.md answering all 11 impact questions
585
+ - [ ] Complete PLAN.md with file changes, risks, rollback
586
+ - [ ] Create TEST_CONTRACT.md with test cases
587
+ - [ ] Create DIAGRAM.mmd if architecture affected
588
+ - [ ] Identify all docs that will need updates (API_DOCS? REQUIREMENTS? DESIGN? etc.)
589
+
590
+ **Phase 3: Implementation**
591
+ - [ ] Create failing test or verification
592
+ - [ ] Implement to pass test
593
+ - [ ] Run verification - all pass?
594
+ - [ ] Review code for quality
595
+
596
+ **Phase 4: Documentation & Sync**
597
+ - [ ] Check CHANGE_IMPACT_MATRIX.md → which docs must update?
598
+ - [ ] Update REQUIREMENTS.md (if behavior/feature added)
599
+ - [ ] Update API_DOCS.md (if API endpoints changed)
600
+ - [ ] Update ARCHITECTURE.md (if structure changed)
601
+ - [ ] Update DESIGN.md (if UI/UX changed)
602
+ - [ ] Update INTEGRATIONS.md (if external services changed)
603
+ - [ ] Update CONVENTIONS.md (if new patterns established)
604
+ - [ ] Update STACK.md (if new tech added)
605
+ - [ ] Update SPEC_CHANGELOG.md with: date, reason, impacted docs, impacted tests, migration notes
606
+ - [ ] Update .planning/STATE.md (current phase, active feature, next task)
607
+ - [ ] Update .planning/SUMMARY.md (recent changes, next recommended task)
608
+ - [ ] Update .planning/FEATURE_INDEX.md (add feature status)
609
+ - [ ] Update .planning/QUALITY_SCORE.md (recalculate scores)
610
+ - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
611
+
612
+ **Phase 5: Review & Completion**
613
+ - [ ] Review changed files (remove debug logs, dead code, unrelated changes)
614
+ - [ ] Update feature REVIEW.md with findings
615
+ - [ ] Verify cleanup pass complete
616
+ - [ ] Create `.codebase/RECOVERY_POINTS.md` entry for resumption
617
+ - [ ] Create or update `.codebase/IMPLEMENTATION_HANDOFF.md`
618
+ - [ ] Mark TASKS checklist complete [x]
619
+
620
+ Prefer `scripts/create-feature.sh` for the initial folder and file scaffold, then fill the generated files with task-specific content.
621
+
622
+ ## `/fix-bug` Workflow
623
+
624
+ **IMPORTANT**: Always use `checklists/bug-fix-qa.md` BEFORE starting any bug fix work.
625
+
626
+ Before fixing a bug, always:
627
+
628
+ ### Step 0: Complete Bug Fix Q&A (MANDATORY)
629
+
630
+ ```bash
631
+ # Complete the bug fix questionnaire:
632
+ cat .codex/skills/genesis-harness/checklists/bug-fix-qa.md
633
+
634
+ # Answer all questions:
635
+ - Bug clearly reproduced?
636
+ - Root cause identified?
637
+ - Severity assessed?
638
+ - Affected versions known?
639
+ - Impact assessed?
640
+ - Fix approach decided?
641
+ - Regression prevention plan?
642
+ - Deployment strategy known?
643
+ ```
644
+
645
+ If ANY question is unanswered → Stop and get clarification before continuing.
646
+
647
+ ### Step 1: Requirements Validation
648
+
649
+ After bug Q&A is complete:
650
+
651
+ ```bash
652
+ # Use requirements validation checklist:
653
+ cat .codex/skills/genesis-harness/checklists/requirements-validation.md
654
+
655
+ # For bugs, verify:
656
+ - Root cause is clear
657
+ - Fix approach is feasible
658
+ - Test strategy is defined
659
+ - No scope creep
660
+ - Stakeholders aligned
661
+ ```
662
+
663
+ ### Step 2: Read Context
664
+
665
+ Then read:
666
+
667
+ ```txt
668
+ .planning/PITFALLS.md
669
+ .planning/LESSONS_LEARNED.md
670
+ .planning/CONVENTIONS.md
671
+ .planning/ARCHITECTURE.md
672
+ .planning/STACK.md
673
+ ```
674
+
675
+ Then reproduce and diagnose before changing code. Create:
676
+
677
+ ```txt
678
+ .planning/bugs/NNN-bug-slug/
679
+ ├── REPORT.md
680
+ ├── ROOT_CAUSE.md
681
+ ├── PLAN.md
682
+ ├── TEST_CONTRACT.md
683
+ ├── TASKS.md
684
+ ├── VERIFICATION.md
685
+ └── REVIEW.md
686
+ ```
687
+
688
+ ### Step 3: Bug Documentation
689
+
690
+ Create `TASKS.md` with checkboxes for:
691
+
692
+ **Phase 1: Understanding**
693
+ - [ ] Complete `.codex/skills/genesis-harness/checklists/bug-fix-qa.md`
694
+ - [ ] Complete `.codex/skills/genesis-harness/checklists/requirements-validation.md`
695
+ - [ ] Read PITFALLS.md and LESSONS_LEARNED.md
696
+ - [ ] Reproduce bug with exact steps
697
+ - [ ] Identify root cause
698
+ - [ ] Check for similar bugs in LESSONS_LEARNED.md
699
+
700
+ **Phase 2: Planning**
701
+ - [ ] Complete REPORT.md (what is broken?)
702
+ - [ ] Complete ROOT_CAUSE.md (why is it broken?)
703
+ - [ ] Complete PLAN.md (how to fix it?)
704
+ - [ ] Create TEST_CONTRACT.md (regression test)
705
+ - [ ] Identify risk level (low/medium/high)
706
+ - [ ] Plan rollback strategy
707
+
708
+ **Phase 3: Implementation**
709
+ - [ ] Create regression test (should fail with current code)
710
+ - [ ] Fix with minimal change (don't refactor unrelated code)
711
+ - [ ] Verify regression test now passes
712
+ - [ ] Run full test suite - all pass?
713
+
714
+ **Phase 4: Documentation & Sync**
715
+ - [ ] Update LESSONS_LEARNED.md with bug finding
716
+ - [ ] Check which docs affected
717
+ - [ ] Update REQUIREMENTS.md (if behavior changed)
718
+ - [ ] Update API_DOCS.md (if API changed)
719
+ - [ ] Update .planning/STATE.md
720
+ - [ ] Update .planning/SUMMARY.md
721
+ - [ ] Update .planning/SPEC_CHANGELOG.md if needed
722
+ - [ ] Update .planning/QUALITY_SCORE.md
723
+ - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
724
+
725
+ **Phase 5: Review & Completion**
726
+ - [ ] Review changed files (minimal change?)
727
+ - [ ] Update bug REVIEW.md
728
+ - [ ] Verify cleanup pass complete
729
+ - [ ] Create `.codebase/RECOVERY_POINTS.md` entry
730
+ - [ ] Create or update `.codebase/IMPLEMENTATION_HANDOFF.md`
731
+ - [ ] Mark TASKS checklist complete [x]
732
+
733
+ Append to `.planning/LESSONS_LEARNED.md`:
734
+
735
+ ```md
736
+ ## Bug: <name>
737
+
738
+ Date:
739
+ Root cause:
740
+ Failed assumption:
741
+ Correct pattern:
742
+ Prevention rule:
743
+ Files changed:
744
+ Verification:
745
+ ```
746
+
747
+ Never fix the same type of bug without checking `LESSONS_LEARNED.md`.
748
+
749
+ Prefer `scripts/create-bug.sh` for the initial folder and file scaffold, then fill the generated files with task-specific evidence.
750
+
751
+ ## `/api-sync` Workflow
752
+
753
+ **NEW**: After implementing API-related features or changes, use the **api-sync-skill** to automatically sync contracts with implementation.
754
+
755
+ When API code is modified, invoke:
756
+
757
+ ```bash
758
+ invoke api-sync-skill
759
+
760
+ # Parameters:
761
+ - changed_files: [list of API files modified]
762
+ - contract_file: ".codebase/API_CONTRACTS.md"
763
+ - breaking_changes: true/false
764
+ - version_bump: "major/minor/patch"
765
+ ```
766
+
767
+ This workflow:
768
+
769
+ 1. Detects API endpoint changes (new, modified, deprecated)
770
+ 2. Extracts request/response schemas from code
771
+ 3. Updates API_CONTRACTS.md with all changes
772
+ 4. Identifies breaking changes
773
+ 5. Generates test contracts
774
+ 6. Creates migration guide if needed
775
+ 7. Documents version changes
776
+
777
+ See `.codex/skills/api-sync-skill/SKILL.md` for full workflow.
778
+
779
+ **Important**: Run before committing API changes.
780
+
781
+ ## `/spec-change` Workflow
782
+
783
+ **NEW**: When a specification document changes, use this to propagate changes to downstream phases.
784
+
785
+ When user calls `/spec-change <file>` or notifies you of spec changes:
786
+
787
+ ### Step 1: Detect the Change
788
+
789
+ ```bash
790
+ # User says: "I updated the API response format in API_DOCS.md"
791
+
792
+ Harness:
793
+ 1. Reads old vs new version of .planning/API_DOCS.md
794
+ 2. Identifies what changed (breaking vs additive)
795
+ 3. Classifies severity (high/medium/low)
796
+ 4. Extracts specific changes (what field changed, how)
797
+ ```
798
+
799
+ ### Step 2: Query Impact
800
+
801
+ ```bash
802
+ # Using PHASE_DEPENDENCY_MAP.md
803
+
804
+ Query: Which phases depend on the API_DOCS.md changes?
805
+
806
+ Example:
807
+ - Phase 1 changed: GET /api/users/:id response format
808
+ - PHASE_DEPENDENCY_MAP shows:
809
+ - Phase 2 imports user_api ← AFFECTED
810
+ - Phase 3 imports user_api ← AFFECTED
811
+ - Phase 4 imports user_api ← AFFECTED
812
+ ```
813
+
814
+ ### Step 3: Generate Impact Report
815
+
816
+ ```bash
817
+ # Create .codebase/IMPACT_REPORT_<timestamp>.md
818
+
819
+ Contains:
820
+ - What changed (before/after)
821
+ - Severity level
822
+ - All affected phases
823
+ - Estimated impact time (30 min? 2 hours?)
824
+ - Recommended fix order
825
+ - Rollback strategy
826
+ ```
827
+
828
+ ### Step 4: Auto-Update (Optional)
829
+
830
+ ```bash
831
+ # If user says: "Auto-update all affected phases"
832
+
833
+ For each affected phase:
834
+ 1. Auto-update SPEC.md (replace old API calls)
835
+ 2. Auto-update TEST_CONTRACT.md (update assertions)
836
+ 3. Auto-update PLAN.md (note breaking change)
837
+ 4. Run validation tests
838
+ 5. Flag for developer review if HIGH severity
839
+ ```
840
+
841
+ ### Step 5: Update Tracking
842
+
843
+ ```bash
844
+ 1. Add entry to SPEC_CHANGELOG.md
845
+ 2. Update STATE.md with status
846
+ 3. Create notification with impact details
847
+ 4. Suggest next steps
848
+ ```
849
+
850
+ ---
851
+
852
+ ## `/propagate-spec` Workflow
853
+
854
+ **NEW**: Automatically propagate all pending spec changes to downstream phases.
855
+
856
+ When user calls `/propagate-spec`:
857
+
858
+ ### Step 1: Find Pending Changes
859
+
860
+ ```bash
861
+ # Scan SPEC_CHANGELOG.md for entries marked "pending_propagation"
862
+
863
+ These are changes that were made but not yet pushed to dependent phases.
864
+ ```
865
+
866
+ ### Step 2: Identify Affected Phases
867
+
868
+ ```bash
869
+ # For each pending change:
870
+ # 1. Query PHASE_DEPENDENCY_MAP
871
+ # 2. Find phases that depend on the changed capability
872
+ # 3. Build execution order (upstream first)
873
+ ```
874
+
875
+ ### Step 3: Auto-Update All Phases
876
+
877
+ ```bash
878
+ # For each affected phase (in order):
879
+
880
+ 1. Update SPEC.md
881
+ - Replace old patterns with new ones
882
+ - Update examples
883
+ - Note breaking changes
884
+
885
+ 2. Update TEST_CONTRACT.md
886
+ - Update test expectations
887
+ - Add migration notes
888
+
889
+ 3. Update PLAN.md
890
+ - Note: "Depends on Phase N spec change"
891
+ - Estimate new work time
892
+
893
+ 4. Generate migration guide if breaking change
894
+
895
+ 5. Run tests
896
+ - If PASS: Mark phase as ready ✓
897
+ - If FAIL: Flag for manual review ⚠️
898
+ ```
899
+
900
+ ### Step 4: Update Timeline
901
+
902
+ ```bash
903
+ # If any phase specs changed significantly:
904
+
905
+ 1. Recalculate ROADMAP.md
906
+ - Update phase timelines
907
+ - Recalculate critical path
908
+ - Notify if project delay > 1 day
909
+
910
+ 2. Update STATE.md
911
+ - Note propagation completed
912
+ - Mark phases as ready to resume
913
+ ```
914
+
915
+ ### Step 5: Generate Summary
916
+
917
+ ```bash
918
+ # Create comprehensive report:
919
+
920
+ "Spec propagation complete
921
+
922
+ Updated phases:
923
+ - Phase 2: 1 spec, 3 tests (HIGH severity - requires review)
924
+ - Phase 3: 2 specs, 5 tests (MEDIUM - ready to resume)
925
+ - Phase 4: 0 changes (LOW severity, no impact)
926
+
927
+ Timeline impact: +2 hours estimated work
928
+ Critical path: No changes
929
+ Status: Ready to proceed
930
+
931
+ Next steps:
932
+ 1. Review Phase 2 changes
933
+ 2. Run tests in Phase 2
934
+ 3. Continue Phase 2 implementation"
935
+ ```
936
+
937
+ ---
938
+
939
+ ## `/validate-specs` Workflow
940
+
941
+ **NEW**: Check that all phases are aligned with their dependencies.
942
+
943
+ When user calls `/validate-specs`:
944
+
945
+ ### Step 1: Load Dependency Map
946
+
947
+ ```bash
948
+ # Read PHASE_DEPENDENCY_MAP.md
949
+
950
+ For each phase:
951
+ - What it provides
952
+ - What it requires
953
+ - Which phases it depends on
954
+ ```
955
+
956
+ ### Step 2: Validate Each Phase
957
+
958
+ ```bash
959
+ # For each phase N:
960
+
961
+ Check: Does phase N's SPEC.md match what upstream provides?
962
+
963
+ Example:
964
+ Phase 2 spec says: "Uses user_api with { name, email, role }"
965
+ Phase 1 API_DOCS says: "Returns { id, name, email, roles[] }"
966
+
967
+ Result: MISALIGNED ❌
968
+ Phase 2 spec is STALE (3 days old)
969
+
970
+ Action: Flag for update
971
+ ```
972
+
973
+ ### Step 3: Check for Drift
974
+
975
+ ```bash
976
+ # Detect stale specs:
977
+
978
+ For each phase:
979
+ 1. How old is SPEC.md?
980
+ 2. How old is TEST_CONTRACT.md?
981
+ 3. Have upstream phases changed since?
982
+ 4. If spec older than upstream change → DRIFT DETECTED
983
+
984
+ Report all drifted phases.
985
+ ```
986
+
987
+ ### Step 4: Identify Breaking Changes Not Propagated
988
+
989
+ ```bash
990
+ # Query: Are there HIGH severity changes in SPEC_CHANGELOG?
991
+ # That haven't been propagated to dependent phases?
992
+
993
+ If YES:
994
+ - Flag as blocker
995
+ - Cannot start downstream phase work until propagated
996
+ - Suggest running /propagate-spec
997
+ ```
998
+
999
+ ### Step 5: Generate Alignment Report
1000
+
1001
+ ```bash
1002
+ # Create report with:
1003
+
1004
+ ✓ Phases in alignment:
1005
+ - Phase 1, 3, 4
1006
+
1007
+ ❌ Phases with issues:
1008
+ - Phase 2: Spec STALE (3 days, Phase 1 changed 2 days ago)
1009
+ - Phase 5: Cannot start until Phase 4 propagation complete
1010
+
1011
+ ⚠️ Risky:
1012
+ - Phase 3 depends on Phase 2 which depends on Phase 1
1013
+ - Both Phase 1 and 2 have HIGH severity changes
1014
+ - Timeline risk: +4 hours if cascading changes needed
1015
+
1016
+ Recommendations:
1017
+ 1. Run /propagate-spec immediately
1018
+ 2. Re-validate after propagation
1019
+ 3. Run tests in all phases
1020
+ ```
1021
+
1022
+ ---
1023
+
1024
+ ## Spec Impact Integration into `/new-feature`
1025
+
1026
+ When a feature is completed and phases are affected:
1027
+
1028
+ ### Phase 4: Documentation & Sync (Updated)
1029
+
1030
+ - [ ] Check CHANGE_IMPACT_MATRIX.md → which docs must update?
1031
+ - [ ] Update REQUIREMENTS.md (if behavior/feature added)
1032
+ - [ ] Update API_DOCS.md (if API endpoints changed)
1033
+ - [ ] Update ARCHITECTURE.md (if structure changed)
1034
+ - [ ] Update DESIGN.md (if UI/UX changed)
1035
+ - [ ] Update INTEGRATIONS.md (if external services changed)
1036
+ - [ ] Update CONVENTIONS.md (if new patterns established)
1037
+ - [ ] Update STACK.md (if new tech added)
1038
+ - [ ] Update SPEC_CHANGELOG.md with: date, reason, impacted docs, impacted tests, migration notes
1039
+ - [ ] Update .planning/STATE.md (current phase, active feature, next task)
1040
+ - [ ] Update .planning/SUMMARY.md (recent changes, next recommended task)
1041
+ - [ ] Update .planning/FEATURE_INDEX.md (add feature status)
1042
+ - [ ] Update .planning/QUALITY_SCORE.md (recalculate scores)
1043
+ - [ ] **NEW**: Run `/spec-change <changed-file>` for each updated spec file
1044
+ - [ ] **NEW**: Review impact report from spec-impact-engine
1045
+ - [ ] **NEW**: Run `/propagate-spec` to auto-update downstream phases
1046
+ - [ ] **NEW**: Run `/validate-specs` to confirm all phases aligned
1047
+ - [ ] Run post-implementation state sync: `.codex/skills/genesis-harness/resources/post-implementation-guide.md`
1048
+
1049
+ When the user asks for a plan:
1050
+
1051
+ 1. Read required planning docs.
1052
+ 2. Research the codebase.
1053
+ 3. Research best practices if internet is available.
1054
+ 4. Create or update relevant diagrams.
1055
+ 5. Write a plan with:
1056
+
1057
+ ```md
1058
+ ## Goal
1059
+
1060
+ ## Current State
1061
+
1062
+ ## Research Findings
1063
+
1064
+ ## Files to Change
1065
+
1066
+ ### File: `path/to/file`
1067
+ Change:
1068
+ Why:
1069
+ Risk:
1070
+ Test:
1071
+ Docs impact:
1072
+
1073
+ ## Test Contract
1074
+
1075
+ ## Verification Commands
1076
+
1077
+ ## Docs to Update
1078
+
1079
+ ## Risks
1080
+
1081
+ ## Rollback Plan
1082
+ ```
1083
+
1084
+ Do not implement unless the user asks to implement or the workflow clearly requires implementation.
1085
+
1086
+ ## `/audit` Workflow
1087
+
1088
+ 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.
1089
+
1090
+ Update:
1091
+
1092
+ ```txt
1093
+ .planning/audits/architecture-drift.md
1094
+ .planning/audits/dependency-audit.md
1095
+ .planning/audits/dead-code-audit.md
1096
+ .planning/audits/security-audit.md
1097
+ .planning/audits/docs-freshness-audit.md
1098
+ .planning/QUALITY_SCORE.md
1099
+ .planning/STATE.md
1100
+ .planning/SUMMARY.md
1101
+ ```
1102
+
1103
+ Create follow-up tasks if needed. Do not make risky code changes during `/audit` unless explicitly requested.
1104
+
1105
+ ## `/review` Workflow
1106
+
1107
+ 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.
1108
+
1109
+ 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.
1110
+
1111
+ ## `/status` Workflow
1112
+
1113
+ 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.
1114
+
1115
+ Use `.planning/STATE.md`, `.planning/ROADMAP.md`, `.planning/FEATURE_INDEX.md`, and `.planning/SUMMARY.md`. Do not guess.
1116
+
1117
+ ## Test-First Rule
1118
+
1119
+ Before implementation:
1120
+
1121
+ 1. create or update tests
1122
+ 2. define input/output expectations
1123
+ 3. define edge cases
1124
+ 4. run tests and confirm they fail for the expected reason
1125
+
1126
+ 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.
1127
+
1128
+ ## Implementation Rule
1129
+
1130
+ 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.
1131
+
1132
+ ## State Continuity & Resumption
1133
+
1134
+ **NEW**: After each implementation phase, document state for resumption:
1135
+
1136
+ ### Create `.codebase/IMPLEMENTATION_HANDOFF.md`
1137
+
1138
+ After successful implementation completion:
1139
+
1140
+ ```bash
1141
+ # Create handoff document with:
1142
+ - What was built (modules created/modified)
1143
+ - Current state (what's complete, known issues)
1144
+ - Files changed (detailed list)
1145
+ - Metrics and status
1146
+ - For continuation (resumption instructions)
1147
+ - Recovery points (where to resume if paused)
1148
+ - Architecture decisions (why this approach?)
1149
+ ```
1150
+
1151
+ See `.codebase/IMPLEMENTATION_HANDOFF.md` for template.
1152
+
1153
+ ### Create `.codebase/RECOVERY_POINTS.md`
1154
+
1155
+ Track where work can be safely paused:
1156
+
1157
+ ```bash
1158
+ # For each phase, document:
1159
+ - Phase status (complete, in-progress, paused)
1160
+ - What was completed
1161
+ - What remains
1162
+ - How to resume from this point
1163
+ - Rollback procedures
1164
+ ```
1165
+
1166
+ See `.codebase/RECOVERY_POINTS.md` for template and examples.
1167
+
1168
+ ### Use After Implementation
1169
+
1170
+ Run this workflow after implementation passes tests:
1171
+
1172
+ ```bash
1173
+ # 1. Verify all tests passing
1174
+ npm test
1175
+
1176
+ # 2. Auto-detect changes and sync docs
1177
+ ./scripts/detect-changes.sh
1178
+
1179
+ # 3. Follow post-implementation guide
1180
+ cat .codex/skills/genesis-harness/resources/post-implementation-guide.md
1181
+
1182
+ # 4. Update state tracking
1183
+ cat .codebase/IMPLEMENTATION_HANDOFF.md # Fill out
1184
+ cat .codebase/RECOVERY_POINTS.md # Fill out
1185
+
1186
+ # 5. Verify all docs in sync
1187
+ ./scripts/check-docs-sync.sh
1188
+ ```
1189
+
1190
+ ## Docs Sync Rule
1191
+
1192
+ **CRITICAL**: Whenever implementation changes behavior, API, data model, UI, integration, architecture, convention, config, environment variable, security behavior, or requirement, update ALL related docs.
1193
+
1194
+ Reference `.planning/CHANGE_IMPACT_MATRIX.md` to identify which docs must be updated based on change type.
1195
+
1196
+ Possible docs to update:
1197
+
1198
+ - `.planning/REQUIREMENTS.md` - If feature/behavior/requirement changed
1199
+ - `.planning/API_DOCS.md` - If endpoints/schemas/auth changed
1200
+ - `.planning/ARCHITECTURE.md` - If module boundaries/data flow changed
1201
+ - `.planning/DESIGN.md` - If UI/UX/screens/components changed
1202
+ - `.planning/INTEGRATIONS.md` - If external services/env vars changed
1203
+ - `.planning/STACK.md` - If tech stack/versions/commands changed
1204
+ - `.planning/CONVENTIONS.md` - If patterns/style/rules changed
1205
+ - `.planning/ROADMAP.md` - If timeline/phases/priorities changed
1206
+ - `.planning/STATE.md` - ALWAYS update (current phase, active work, next task)
1207
+ - `.planning/SPEC_CHANGELOG.md` - ALWAYS update (date, reason, impacted docs)
1208
+ - `.planning/QUALITY_SCORE.md` - Update with new metrics
1209
+ - `.planning/OBSERVABILITY.md` - If logging/metrics/traces changed
1210
+ - `.planning/SMOKE_TESTS.md` - If verification paths changed
1211
+ - `.planning/JOURNEYS.md` - If user flows changed
1212
+ - `.planning/diagrams/*.mmd` - If architecture/flow changed
1213
+ - `.planning/decisions/*.md` - If ADR-level changes made
1214
+ - `.planning/features/*/*.md` - Update feature folder docs
1215
+ - `.planning/FEATURE_INDEX.md` - Update feature table
1216
+
1217
+ **Docs Sync Checklist (from TASKS.md)**:
1218
+ - [ ] Check CHANGE_IMPACT_MATRIX.md for required updates
1219
+ - [ ] Update all applicable docs from list above
1220
+ - [ ] Add entry to SPEC_CHANGELOG.md with date and reason
1221
+ - [ ] Update STATE.md and SUMMARY.md
1222
+ - [ ] Recalculate QUALITY_SCORE.md
1223
+
1224
+ If no docs need updating, explicitly state why in the completion report (e.g., "Internal refactor, no behavior change").
1225
+
1226
+ ## Decision Record Rule
1227
+
1228
+ Use ADR files for important decisions. Create files like `.planning/decisions/ADR-003-use-postgres.md`.
1229
+
1230
+ Each ADR must include status, context, decision, alternatives considered, consequences, risks, mitigation, and verification evidence.
1231
+
1232
+ 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.
1233
+
1234
+ Prefer `scripts/create-adr.sh` for ADR numbering and starter content.
1235
+
1236
+ ## Quality Rubric
1237
+
1238
+ Use this rubric when updating `QUALITY_SCORE.md`:
1239
+
1240
+ | Score | Meaning |
1241
+ |---:|---|
1242
+ | 0 | Unknown, absent, or not evaluated |
1243
+ | 2 | Known major gaps with no mitigation |
1244
+ | 4 | Basic structure exists but is inconsistent or mostly manual |
1245
+ | 6 | Working baseline with known gaps and follow-up tasks |
1246
+ | 8 | Strong, verified, documented, and mostly automated |
1247
+ | 10 | Mature, automated, documented, reviewed, and low-risk |
1248
+
1249
+ Area guidance:
1250
+
1251
+ - Architecture: module boundaries, dependency direction, diagrams, ADRs, forbidden patterns.
1252
+ - Tests: regression coverage, smoke tests, edge cases, failing-first evidence, CI/local repeatability.
1253
+ - Docs Sync: docs updated with behavior changes, changelog entries, impact matrix compliance.
1254
+ - Security: auth, secrets, data protection, dependency risk, destructive-operation safeguards.
1255
+ - Maintainability: naming, duplication, dead code, conventions, file/module size, refactor risk.
1256
+ - Observability: logs, metrics, traces, errors, health checks, debug commands, inspection workflow.
1257
+
1258
+ ## Mechanical Checks Rule
1259
+
1260
+ When possible, use or create scripts that check harness consistency. Scripts should include:
1261
+
1262
+ ```txt
1263
+ scripts/check-docs-sync.sh
1264
+ scripts/check-task-tracking.sh
1265
+ scripts/check-no-debug-logs.sh
1266
+ scripts/check-spec-changelog.sh
1267
+ scripts/check-required-planning-files.sh
1268
+ scripts/check-architecture-boundaries.sh
1269
+ scripts/run-verification.sh
1270
+ ```
1271
+
1272
+ These scripts do not need to be perfect, but they should provide practical guardrails. Document all checks in `.planning/checks/CHECKS.md`.
1273
+
1274
+ ## Escalation Rule
1275
+
1276
+ 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.
1277
+
1278
+ Record escalations in `.planning/ESCALATION.md`.
1279
+
1280
+ ## Review Rule
1281
+
1282
+ 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.
1283
+
1284
+ Record the review in the related feature `REVIEW.md`, bug `REVIEW.md`, phase `REVIEW.md`, and `.planning/SUMMARY.md`.
1285
+
1286
+ ## Completion Report Rule
1287
+
1288
+ Final response must include:
1289
+
1290
+ ```md
1291
+ ## Completed
1292
+
1293
+ - What was done
1294
+
1295
+ ## Planning Updated
1296
+
1297
+ - Files updated under `.planning/`
1298
+
1299
+ ## Code Changed
1300
+
1301
+ - Files changed
1302
+
1303
+ ## Tests / Verification
1304
+
1305
+ - Tests added/updated
1306
+ - Commands run
1307
+ - Result
1308
+
1309
+ ## Docs Sync
1310
+
1311
+ - Docs updated
1312
+ - If none, explain why
1313
+
1314
+ ## Tracking
1315
+
1316
+ - Tasks changed from `[ ]` or `[~]` to `[x]`
1317
+
1318
+ ## Review
1319
+
1320
+ - Changed files reviewed
1321
+ - Cleanup performed
1322
+
1323
+ ## Risks / Follow-up
1324
+
1325
+ - Remaining risks
1326
+ - Suggested next step
1327
+ ```
1328
+
1329
+ 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.
1330
+
1331
+ ## Default `config.json`
1332
+
1333
+ When initializing, create:
1334
+
1335
+ ```json
1336
+ {
1337
+ "workflow": {
1338
+ "init_requires_confirmation": true,
1339
+ "research_before_plan": true,
1340
+ "best_practice_research": true,
1341
+ "diagram_before_implementation": true,
1342
+ "test_first": true,
1343
+ "task_tracking": true,
1344
+ "docs_sync_required": true,
1345
+ "lessons_read_required": true,
1346
+ "code_review": true,
1347
+ "cleanup_pass": true,
1348
+ "mechanical_checks": true,
1349
+ "audit_supported": true,
1350
+ "escalation_required": true
1351
+ },
1352
+ "tracking": {
1353
+ "todo": "[ ]",
1354
+ "in_progress": "[~]",
1355
+ "done": "[x]",
1356
+ "blocked": "[!]"
1357
+ },
1358
+ "required_reads_before_work": [
1359
+ ".planning/SUMMARY.md",
1360
+ ".planning/STATE.md",
1361
+ ".planning/PITFALLS.md",
1362
+ ".planning/LESSONS_LEARNED.md",
1363
+ ".planning/CONVENTIONS.md",
1364
+ ".planning/ARCHITECTURE.md",
1365
+ ".planning/STACK.md"
1366
+ ],
1367
+ "docs_sync_targets": [
1368
+ ".planning/REQUIREMENTS.md",
1369
+ ".planning/API_DOCS.md",
1370
+ ".planning/ARCHITECTURE.md",
1371
+ ".planning/DESIGN.md",
1372
+ ".planning/INTEGRATIONS.md",
1373
+ ".planning/CONVENTIONS.md",
1374
+ ".planning/ROADMAP.md",
1375
+ ".planning/STATE.md",
1376
+ ".planning/SPEC_CHANGELOG.md",
1377
+ ".planning/QUALITY_SCORE.md",
1378
+ ".planning/OBSERVABILITY.md",
1379
+ ".planning/JOURNEYS.md",
1380
+ ".planning/SMOKE_TESTS.md"
1381
+ ],
1382
+ "mermaid_required_for": [
1383
+ "architecture",
1384
+ "database",
1385
+ "api_flow",
1386
+ "integration",
1387
+ "deployment",
1388
+ "feature_flow",
1389
+ "auth_flow",
1390
+ "background_job_flow"
1391
+ ],
1392
+ "escalate_when": [
1393
+ "ambiguous_product_intent",
1394
+ "conflicting_requirements",
1395
+ "breaking_api_change",
1396
+ "destructive_migration",
1397
+ "possible_user_data_loss",
1398
+ "missing_credentials",
1399
+ "paid_external_service_required",
1400
+ "unclear_security_tradeoff",
1401
+ "legal_or_compliance_risk"
1402
+ ]
1403
+ }
1404
+ ```
1405
+
1406
+ ## Final Hard Rules
1407
+
1408
+ 1. `/init` must not blindly create implementation code.
1409
+ 2. If the app idea is missing or ambiguous, ask for confirmation first.
1410
+ 3. Create root `AGENTS.md` as a concise table of contents.
1411
+ 4. Every task must be tracked with `[ ]`, `[~]`, `[x]`, or `[!]`.
1412
+ 5. Do not say a task is done unless tracking files are updated.
1413
+ 6. Every behavior/spec/API/DB/UI/integration/config/security change must update related docs.
1414
+ 7. Before bug fix or feature work, always read `PITFALLS.md`, `LESSONS_LEARNED.md`, `CONVENTIONS.md`, `ARCHITECTURE.md`, and `STACK.md`.
1415
+ 8. Every bug fix must append a lesson to `LESSONS_LEARNED.md`.
1416
+ 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`.
1417
+ 10. Plans must clearly say what changes, where it changes, why it changes, risks, docs impact, and verification commands.
1418
+ 11. Research best practices before planning when internet is available.
1419
+ 12. Never invent external research results.
1420
+ 13. Mermaid diagrams must be updated before architecture-impacting implementation.
1421
+ 14. Tests or verification must be created before implementation.
1422
+ 15. Review changed files after verification passes.
1423
+ 16. Remove unnecessary files, debug logs, dead code, and unrelated changes.
1424
+ 17. Use ADRs for major technical decisions.
1425
+ 18. Use `/audit` to detect architecture drift, stale docs, dead code, missing tests, and quality gaps.
1426
+ 19. Escalate to the user when human judgment is required.
1427
+ 20. Final response must include changed files, tests, docs sync, tracking updates, review result, and remaining risks.