@jamie-tam/forge 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +389 -0
  3. package/agents/architect.md +92 -0
  4. package/agents/builder.md +122 -0
  5. package/agents/code-reviewer.md +107 -0
  6. package/agents/concept-designer.md +207 -0
  7. package/agents/craft-reviewer.md +132 -0
  8. package/agents/critic.md +130 -0
  9. package/agents/doc-writer.md +85 -0
  10. package/agents/dreamer.md +129 -0
  11. package/agents/e2e-runner.md +89 -0
  12. package/agents/gotcha-hunter.md +127 -0
  13. package/agents/prototype-builder.md +193 -0
  14. package/agents/prototype-codifier.md +204 -0
  15. package/agents/prototype-reviewer.md +163 -0
  16. package/agents/security-reviewer.md +108 -0
  17. package/agents/spec-reviewer.md +94 -0
  18. package/agents/tracer.md +98 -0
  19. package/agents/wireframer.md +109 -0
  20. package/commands/abort.md +25 -0
  21. package/commands/bugfix.md +151 -0
  22. package/commands/evolve.md +118 -0
  23. package/commands/feature.md +236 -0
  24. package/commands/forge.md +100 -0
  25. package/commands/greenfield.md +185 -0
  26. package/commands/hotfix.md +98 -0
  27. package/commands/refactor.md +147 -0
  28. package/commands/resume.md +25 -0
  29. package/commands/setup.md +201 -0
  30. package/commands/status.md +27 -0
  31. package/commands/task-force.md +110 -0
  32. package/commands/validate.md +12 -0
  33. package/dist/__tests__/active-manifest.test.js +272 -0
  34. package/dist/__tests__/copy.test.js +96 -0
  35. package/dist/__tests__/gate-check.test.js +384 -0
  36. package/dist/__tests__/wiki.test.js +472 -0
  37. package/dist/__tests__/work-manifest.test.js +304 -0
  38. package/dist/active-manifest.js +229 -0
  39. package/dist/cli.js +158 -0
  40. package/dist/copy.js +124 -0
  41. package/dist/gate-check.js +326 -0
  42. package/dist/hooks.js +60 -0
  43. package/dist/init.js +140 -0
  44. package/dist/manifest.js +90 -0
  45. package/dist/merge.js +77 -0
  46. package/dist/paths.js +36 -0
  47. package/dist/uninstall.js +216 -0
  48. package/dist/update.js +158 -0
  49. package/dist/verify-manifest.js +65 -0
  50. package/dist/verify.js +98 -0
  51. package/dist/wiki-ui.js +310 -0
  52. package/dist/wiki.js +364 -0
  53. package/dist/work-manifest.js +798 -0
  54. package/hooks/config/gate-requirements.json +79 -0
  55. package/hooks/hooks.json +143 -0
  56. package/hooks/scripts/analyze-telemetry.sh +114 -0
  57. package/hooks/scripts/gate-enforcer.sh +164 -0
  58. package/hooks/scripts/pre-compact.sh +90 -0
  59. package/hooks/scripts/session-start.sh +81 -0
  60. package/hooks/scripts/telemetry.sh +41 -0
  61. package/hooks/scripts/wiki-lint.sh +87 -0
  62. package/hooks/templates/AGENTS.md.template +48 -0
  63. package/hooks/templates/CLAUDE.md.template +45 -0
  64. package/package.json +55 -0
  65. package/protocols/README.md +40 -0
  66. package/protocols/codex.md +151 -0
  67. package/protocols/graphify.md +156 -0
  68. package/references/common/agent-coordination.md +65 -0
  69. package/references/common/coding-standards.md +54 -0
  70. package/references/common/feature-tracking.md +21 -0
  71. package/references/common/io-protocol.md +36 -0
  72. package/references/common/phases.md +57 -0
  73. package/references/common/quality-gates.md +130 -0
  74. package/references/common/skill-authoring.md +154 -0
  75. package/references/common/skill-compliance.md +30 -0
  76. package/references/python/standards.md +44 -0
  77. package/references/react/standards.md +61 -0
  78. package/references/typescript/standards.md +42 -0
  79. package/rules/common/forge-system.md +59 -0
  80. package/rules/common/git-workflow.md +40 -0
  81. package/rules/common/guardrails.md +37 -0
  82. package/rules/common/quality-gates.md +18 -0
  83. package/rules/common/security.md +50 -0
  84. package/rules/common/skill-selection.md +78 -0
  85. package/rules/common/testing.md +58 -0
  86. package/rules/common/verification.md +39 -0
  87. package/skills/build-pr-workflow/SKILL.md +301 -0
  88. package/skills/build-pr-workflow/references/pr-template.md +62 -0
  89. package/skills/build-pr-workflow/references/subagent-merge.md +47 -0
  90. package/skills/build-pr-workflow/references/worktree-setup.md +125 -0
  91. package/skills/build-prototype/SKILL.md +264 -0
  92. package/skills/build-scaffold/SKILL.md +340 -0
  93. package/skills/build-tdd/SKILL.md +89 -0
  94. package/skills/build-wireframe/SKILL.md +110 -0
  95. package/skills/build-wireframe/assets/baseline-template.html +486 -0
  96. package/skills/build-wireframe/references/demo-walkthroughs.md +170 -0
  97. package/skills/build-wireframe/references/gotchas.md +188 -0
  98. package/skills/build-wireframe/references/legend-lines.md +141 -0
  99. package/skills/concept-slides/SKILL.md +192 -0
  100. package/skills/deliver-db-migration/SKILL.md +466 -0
  101. package/skills/deliver-deploy/SKILL.md +407 -0
  102. package/skills/deliver-onboarding/SKILL.md +198 -0
  103. package/skills/deliver-onboarding/references/document-templates.md +393 -0
  104. package/skills/deliver-onboarding/templates/getting-started.md +122 -0
  105. package/skills/discover-codebase-analysis/SKILL.md +448 -0
  106. package/skills/discover-requirements/SKILL.md +418 -0
  107. package/skills/discover-requirements/templates/prd.md +99 -0
  108. package/skills/discover-requirements/templates/technical-spec.md +123 -0
  109. package/skills/discover-requirements/templates/user-stories.md +76 -0
  110. package/skills/harden/SKILL.md +214 -0
  111. package/skills/iterate-prototype/SKILL.md +241 -0
  112. package/skills/plan-architecture/SKILL.md +457 -0
  113. package/skills/plan-architecture/templates/adr-template.md +52 -0
  114. package/skills/plan-architecture/templates/api-contract.md +99 -0
  115. package/skills/plan-architecture/templates/db-schema.md +81 -0
  116. package/skills/plan-architecture/templates/system-design.md +111 -0
  117. package/skills/plan-brainstorm/SKILL.md +433 -0
  118. package/skills/plan-design-system/SKILL.md +279 -0
  119. package/skills/plan-task-decompose/SKILL.md +454 -0
  120. package/skills/quality-code-review/SKILL.md +286 -0
  121. package/skills/quality-security-audit/SKILL.md +292 -0
  122. package/skills/quality-security-audit/references/audit-report-template.md +89 -0
  123. package/skills/quality-security-audit/references/owasp-checks.md +178 -0
  124. package/skills/quality-test-execution/SKILL.md +435 -0
  125. package/skills/quality-test-plan/SKILL.md +297 -0
  126. package/skills/quality-test-plan/references/test-type-guide.md +263 -0
  127. package/skills/quality-test-plan/templates/e2e-test-plan.md +72 -0
  128. package/skills/quality-test-plan/templates/integration-test-plan.md +74 -0
  129. package/skills/quality-test-plan/templates/load-test-plan.md +111 -0
  130. package/skills/quality-test-plan/templates/smoke-test-plan.md +68 -0
  131. package/skills/quality-test-plan/templates/unit-test-plan.md +56 -0
  132. package/skills/quality-uiux/SKILL.md +481 -0
  133. package/skills/support-debug/SKILL.md +464 -0
  134. package/skills/support-dream/SKILL.md +213 -0
  135. package/skills/support-gotcha/SKILL.md +249 -0
  136. package/skills/support-runtime-reachability/SKILL.md +190 -0
  137. package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/app.ts +7 -0
  138. package/skills/support-runtime-reachability/scripts/__fixtures__/case-01-passes-app-use/src/handlers/cases.ts +7 -0
  139. package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/app.ts +8 -0
  140. package/skills/support-runtime-reachability/scripts/__fixtures__/case-02-orphan-no-app-use/src/handlers/cases.ts +7 -0
  141. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/App.tsx +5 -0
  142. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/components/RingingBanner.tsx +7 -0
  143. package/skills/support-runtime-reachability/scripts/__fixtures__/case-03-orphan-import-only/src/hooks/useTwilio.ts +6 -0
  144. package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/App.tsx +5 -0
  145. package/skills/support-runtime-reachability/scripts/__fixtures__/case-04-jsx-component-rendered/src/components/MyComp.tsx +3 -0
  146. package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/App.tsx +3 -0
  147. package/skills/support-runtime-reachability/scripts/__fixtures__/case-05-jsx-component-not-rendered/src/components/Orphan.tsx +3 -0
  148. package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/lib/Service.ts +6 -0
  149. package/skills/support-runtime-reachability/scripts/__fixtures__/case-06-class-instantiated/src/main.ts +4 -0
  150. package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/lib/Lonely.ts +5 -0
  151. package/skills/support-runtime-reachability/scripts/__fixtures__/case-07-class-not-instantiated/src/main.ts +2 -0
  152. package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/handler.ts +3 -0
  153. package/skills/support-runtime-reachability/scripts/__fixtures__/case-08-default-export-imported-and-called/src/main.ts +3 -0
  154. package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/handler.ts +3 -0
  155. package/skills/support-runtime-reachability/scripts/__fixtures__/case-09-default-export-orphan/src/main.ts +2 -0
  156. package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/lib.ts +5 -0
  157. package/skills/support-runtime-reachability/scripts/__fixtures__/case-10-aliased-named-export/src/main.ts +3 -0
  158. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/index.ts +1 -0
  159. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/lib/internal.ts +3 -0
  160. package/skills/support-runtime-reachability/scripts/__fixtures__/case-11-re-export-chain/src/main.ts +3 -0
  161. package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.test.ts +5 -0
  162. package/skills/support-runtime-reachability/scripts/__fixtures__/case-12-test-only-caller/src/util.ts +3 -0
  163. package/skills/support-runtime-reachability/scripts/__fixtures__/case-13-gated-pending-annotation/src/future.ts +4 -0
  164. package/skills/support-runtime-reachability/scripts/__fixtures__/case-14-untraceable-annotation/src/decorated.ts +4 -0
  165. package/skills/support-runtime-reachability/scripts/__fixtures__/case-15-untraceable-empty/src/lazy.ts +4 -0
  166. package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/lib.py +15 -0
  167. package/skills/support-runtime-reachability/scripts/__fixtures__/case-16-python-module/src/main.py +5 -0
  168. package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/parent.ts +5 -0
  169. package/skills/support-runtime-reachability/scripts/__fixtures__/case-17-router-use/src/routes/cases.ts +5 -0
  170. package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/lib/foo.ts +3 -0
  171. package/skills/support-runtime-reachability/scripts/__fixtures__/case-18-shadowed-name-fp/src/other.ts +8 -0
  172. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/cases.ts +4 -0
  173. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/handlers/users.ts +4 -0
  174. package/skills/support-runtime-reachability/scripts/__fixtures__/case-19-same-name-different-module/src/main.ts +5 -0
  175. package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/handlers/cases.ts +3 -0
  176. package/skills/support-runtime-reachability/scripts/__fixtures__/case-20-aliased-import-usage/src/main.ts +4 -0
  177. package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/lib.ts +5 -0
  178. package/skills/support-runtime-reachability/scripts/__fixtures__/case-21-mixed-default-and-named/src/main.ts +5 -0
  179. package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/lib.ts +3 -0
  180. package/skills/support-runtime-reachability/scripts/__fixtures__/case-22-dynamic-import-then-caller/src/main.ts +8 -0
  181. package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/lib.ts +3 -0
  182. package/skills/support-runtime-reachability/scripts/__fixtures__/case-23-dynamic-import-with-space/src/main.ts +7 -0
  183. package/skills/support-runtime-reachability/scripts/check.mjs +638 -0
  184. package/skills/support-runtime-reachability/scripts/check.test.mjs +244 -0
  185. package/skills/support-skill-validator/SKILL.md +194 -0
  186. package/skills/support-skill-validator/references/false-positives.md +59 -0
  187. package/skills/support-skill-validator/references/validation-checks.md +280 -0
  188. package/skills/support-system-guide/SKILL.md +311 -0
  189. package/skills/support-task-force/SKILL.md +265 -0
  190. package/skills/support-task-force/references/dispatch-pattern.md +178 -0
  191. package/skills/support-task-force/references/synthesis-template.md +126 -0
  192. package/skills/support-wiki-bootstrap/SKILL.md +37 -0
  193. package/skills/support-wiki-lint/SKILL.md +196 -0
  194. package/skills/support-wiki-lint/scripts/lint.mjs +488 -0
  195. package/skills/support-wiki-lint/scripts/lint.test.mjs +196 -0
  196. package/templates/README.md +23 -0
  197. package/templates/aiwiki/CLAUDE.md.template +78 -0
  198. package/templates/aiwiki/schemas/architecture.md +118 -0
  199. package/templates/aiwiki/schemas/convention.md +112 -0
  200. package/templates/aiwiki/schemas/decision.md +144 -0
  201. package/templates/aiwiki/schemas/gotcha.md +118 -0
  202. package/templates/aiwiki/schemas/oracle.md +105 -0
  203. package/templates/aiwiki/schemas/session.md +125 -0
  204. package/templates/manifests/bugfix.yaml +41 -0
  205. package/templates/manifests/feature.yaml +69 -0
  206. package/templates/manifests/greenfield.yaml +61 -0
  207. package/templates/manifests/hotfix.yaml +45 -0
  208. package/templates/manifests/refactor.yaml +44 -0
  209. package/templates/manifests/v5/SCHEMA.md +327 -0
  210. package/templates/manifests/v5/feature.yaml +77 -0
  211. package/templates/manifests/v6/SCHEMA.md +199 -0
  212. package/templates/wiki-html/dream-detail.html +378 -0
  213. package/templates/wiki-html/dreams-list.html +155 -0
@@ -0,0 +1,464 @@
1
+ ---
2
+ name: support-debug
3
+ description: "Use when encountering any bug, test failure, error, crash, or unexpected behavior — enforces systematic root cause investigation."
4
+ ---
5
+
6
+ # Support: Debug
7
+
8
+ ## Overview
9
+
10
+ Random fixes waste time and create new bugs. Quick patches mask underlying issues. This skill enforces a rigorous four-phase debugging process that finds root causes before attempting fixes.
11
+
12
+ **Core Principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
13
+
14
+ **Violating the letter of this process is violating the spirit of debugging.**
15
+
16
+ ## The Iron Laws
17
+
18
+ ```
19
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.
20
+ FACT-CHECK THE PROBLEM BEFORE ASSUMING THE SYSTEM IS WRONG.
21
+ IF 3 FIXES FAIL, STOP AND DISCUSS ARCHITECTURE.
22
+ AFTER EVERY FIX, RECORD THE LESSON IN SUPPORT-GOTCHA.
23
+ ```
24
+
25
+ If you have not completed Phase 1, you cannot propose fixes. Period.
26
+
27
+ ## When to Use
28
+
29
+ Use for ANY technical issue:
30
+ - Test failures
31
+ - Bugs in production
32
+ - Unexpected behavior
33
+ - Performance problems
34
+ - Build failures
35
+ - Integration issues
36
+ - "It was working yesterday"
37
+
38
+ **Use this ESPECIALLY when:**
39
+ - Under time pressure (emergencies make guessing tempting)
40
+ - "Just one quick fix" seems obvious
41
+ - You have already tried multiple fixes
42
+ - Previous fix did not work
43
+ - You do not fully understand the issue
44
+
45
+ **Do NOT skip when:**
46
+ - Issue seems simple (simple bugs have root causes too)
47
+ - You are in a hurry (systematic debugging is faster than thrashing)
48
+ - User wants it fixed NOW (systematic is faster than guess-and-check)
49
+ - You think you already know the answer (verify first)
50
+
51
+ ## I/O Contract
52
+
53
+ | Field | Value |
54
+ |---|---|
55
+ | **Requires** | Bug description, error output, or unexpected behavior report |
56
+ | **Produces** | Root cause analysis + implemented fix + test demonstrating the fix |
57
+ | **Feeds into** | `support-gotcha` (record lesson learned) |
58
+ | **Updates** | `.forge/work/{type}/{name}/manifest.yaml` if bug is part of a feature |
59
+
60
+ ### Output Format
61
+
62
+ When debugging is complete, produce:
63
+
64
+ ```markdown
65
+ ## Debug Report: {brief description}
66
+
67
+ ### Root Cause
68
+ {What actually caused the problem and why}
69
+
70
+ ### Investigation Path
71
+ {Key steps taken to find root cause, including dead ends}
72
+
73
+ ### Fix Applied
74
+ {What was changed and why this addresses the root cause}
75
+
76
+ ### Test Added
77
+ {Test that demonstrates the fix and prevents regression}
78
+
79
+ ### Lesson Learned
80
+ {What to watch for in the future -- feeds into support-gotcha}
81
+ ```
82
+
83
+ ## Phase 0: Fact-Check First
84
+
85
+ **BEFORE starting the four-phase process, verify the reported problem is real.**
86
+
87
+ This phase applies the `rules/common/verification.md` rule specifically to bug reports. The verification rule is the authority on when and how to verify; this phase is how support-debug implements that rule for debugging contexts.
88
+
89
+ 1. **Verify the Reported Behavior**
90
+ - Can you reproduce exactly what the user describes?
91
+ - Is the error message exactly what they reported?
92
+ - Is the behavior actually wrong, or is it correct behavior they did not expect?
93
+
94
+ 2. **Verify Assumptions About Libraries/APIs**
95
+ - User says "library X should do Y" -- verify via documentation
96
+ - Use context7 or web search to confirm library behavior
97
+ - Check the actual version of the library in use (behavior may differ between versions)
98
+ - Read the library's changelog if behavior recently changed
99
+
100
+ 3. **Verify Environment Assumptions**
101
+ - "It works on my machine" -- check environment differences
102
+ - "It was working yesterday" -- check what changed (git log, dependency updates, env changes)
103
+ - "The API returns X" -- actually call the API and verify
104
+
105
+ 4. **If the Problem Is Not What Was Reported**
106
+ - State clearly: "I investigated and the actual issue is different from what was reported."
107
+ - Explain what is actually happening
108
+ - Then proceed with Phases 1-4 for the real issue
109
+
110
+ **Example of fact-checking catching a misreport:**
111
+ ```
112
+ User: "The fetch API is broken -- it's not sending the Content-Type header."
113
+ Fact-check: Fetch API does send Content-Type for POST requests with body.
114
+ The actual issue: fetch was sending a GET request (missing method: 'POST').
115
+ Real root cause: Missing method parameter, not a broken API.
116
+ ```
117
+
118
+ ## Adaptive Triage: Linear vs. Trace
119
+
120
+ After Phase 0 (fact-checking), assess bug complexity to choose the investigation method:
121
+
122
+ ### Quick Triage (main agent, 2 minutes)
123
+
124
+ **Prerequisite:** This triage assumes you completed Phase 0 (fact-check). If you did not reproduce the bug and verify assumptions, go back to Phase 0 first. Do not triage based on the user's description alone.
125
+
126
+ Can you identify the likely cause from the stack trace, error message, or a single code path?
127
+
128
+ **YES → Linear debugging (Phases 1-4 below).** Fast, cheap, sufficient for most bugs.
129
+
130
+ **NO → Trace methodology.** Use when:
131
+ - No clear stack trace or error message
132
+ - Intermittent or non-deterministic behavior
133
+ - Bug spans multiple systems or services
134
+ - Previous fix attempts failed
135
+ - User says "we've been trying to fix this"
136
+
137
+ ### Trace Methodology (for complex bugs)
138
+
139
+ Dispatch the **tracer** subagent which investigates with 3 competing hypotheses in parallel:
140
+
141
+ 1. **Lane 1 (code-path):** Implementation bug, wrong logic, missing check
142
+ 2. **Lane 2 (config/env):** Wrong env var, version mismatch, deploy issue
143
+ 3. **Lane 3 (assumption):** Test is wrong, expectation is wrong, data changed
144
+
145
+ Each lane gathers evidence FOR and AGAINST its hypothesis, ranked by strength:
146
+ > controlled reproduction > primary artifacts > multiple sources > inference > speculation
147
+
148
+ After investigation, a rebuttal round between top hypotheses determines the most likely root cause with a confidence rating (HIGH/MEDIUM/LOW).
149
+
150
+ When the tracer returns its verdict, proceed to Phase 4 (Implementation) with the identified root cause. If confidence is LOW, the tracer will recommend a discriminating probe — run it before attempting a fix.
151
+
152
+ ## The Four Phases (Linear Debugging)
153
+
154
+ You MUST complete each phase before proceeding to the next.
155
+
156
+ ### Phase 0: Codex Mode Check
157
+
158
+ The user has already described the bug in their message. Run the Codex consent flow from `protocols/codex.md`. The selected mode applies for the rest of this skill's invocation.
159
+
160
+ - **Takeover:** Dispatch Codex with the bug description, error messages/stack trace from the user's message, and skill methodology. Codex performs the 4-phase investigation. Claude reviews hypotheses and tests the fix.
161
+ - **Verify** or **Skip / Codex unavailable:** Proceed with Phases 1-4 below. Phase 2.5 will dispatch Codex to propose alternative hypotheses (Verify only).
162
+
163
+ ### Phase 1: Root Cause Investigation
164
+
165
+ **BEFORE attempting ANY fix:**
166
+
167
+ 1. **Read Error Messages Carefully**
168
+ - Do not skip past errors or warnings
169
+ - They often contain the exact solution
170
+ - Read stack traces completely
171
+ - Note line numbers, file paths, error codes
172
+ - Search for the exact error message in the codebase
173
+
174
+ 2. **Reproduce Consistently**
175
+ - Can you trigger it reliably?
176
+ - What are the exact steps?
177
+ - Does it happen every time?
178
+ - If not reproducible, gather more data -- do NOT guess
179
+
180
+ 3. **Check Recent Changes**
181
+ - What changed that could cause this?
182
+ - `git diff`, recent commits, `git log --oneline -20`
183
+ - New dependencies, config changes
184
+ - Environmental differences (Node version, OS, Docker image)
185
+
186
+ 4. **Gather Evidence in Multi-Component Systems**
187
+
188
+ When the system has multiple components (CI -> build -> signing, API -> service -> database):
189
+
190
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
191
+
192
+ ```
193
+ For EACH component boundary:
194
+ - Log what data enters the component
195
+ - Log what data exits the component
196
+ - Verify environment/config propagation
197
+ - Check state at each layer
198
+
199
+ Run once to gather evidence showing WHERE it breaks.
200
+ THEN analyze evidence to identify the failing component.
201
+ THEN investigate that specific component.
202
+ ```
203
+
204
+ **Example (multi-layer system):**
205
+ ```bash
206
+ # Layer 1: API Gateway
207
+ echo "=== Request received: ==="
208
+ echo "Method: $METHOD, Path: $PATH, Headers: $HEADERS"
209
+
210
+ # Layer 2: Service
211
+ echo "=== Service input: ==="
212
+ echo "Parsed body: $BODY"
213
+
214
+ # Layer 3: Database
215
+ echo "=== Query executed: ==="
216
+ echo "SQL: $QUERY, Params: $PARAMS"
217
+
218
+ # Layer 4: Response
219
+ echo "=== Response: ==="
220
+ echo "Status: $STATUS, Body: $RESPONSE_BODY"
221
+ ```
222
+
223
+ This reveals which layer fails (API -> Service OK, Service -> Database FAIL).
224
+
225
+ 5. **Trace Data Flow (Backward Tracing)**
226
+
227
+ When the error is deep in the call stack:
228
+
229
+ - Start at the error location
230
+ - Where does the bad value come from?
231
+ - What called this function with the bad value?
232
+ - Keep tracing backward until you find the SOURCE
233
+ - Fix at the source, not at the symptom
234
+
235
+ ```
236
+ Error: Cannot read property 'name' of undefined
237
+ at renderUser (user.tsx:42) <- symptom
238
+ at UserList (list.tsx:18) <- passed undefined user
239
+ at loadUsers (api.ts:55) <- returned null instead of []
240
+ at fetchData (fetch.ts:12) <- ROOT CAUSE: missing error handling
241
+ ```
242
+
243
+ Fix at `fetch.ts:12`, not at `user.tsx:42`.
244
+
245
+ ### Phase 2: Pattern Analysis
246
+
247
+ **Find the pattern before fixing:**
248
+
249
+ 1. **Find Working Examples**
250
+ - Locate similar working code in the same codebase
251
+ - What works that is similar to what is broken?
252
+ - If a similar feature works, diff the two implementations
253
+
254
+ 2. **Compare Against References**
255
+ - If implementing a known pattern, read the reference implementation COMPLETELY
256
+ - Do not skim -- read every line
257
+ - Understand the pattern fully before applying
258
+ - Use context7 to fetch current documentation for the library/framework
259
+
260
+ 3. **Identify Differences**
261
+ - What is different between working and broken?
262
+ - List every difference, however small
263
+ - Do not assume "that can't matter" -- small differences often matter
264
+
265
+ 4. **Understand Dependencies**
266
+ - What other components does this need?
267
+ - What settings, config, environment?
268
+ - What assumptions does it make?
269
+ - Check versions of all involved dependencies
270
+
271
+ #### Phase 2.5: Codex Alternative Hypotheses
272
+ After pattern analysis, check the mode recorded at Phase 0. If **Verify** was selected, dispatch Codex to propose alternative root causes and different hypotheses. Merge Claude's analysis + Codex alternatives into Phase 3 hypothesis testing. If **Takeover** was selected, skip this step (Codex already ran the investigation). If **Skip**, do nothing. Do NOT re-run the consent flow. See **Codex Integration** section below for full details.
273
+
274
+ #### Graphify Context (Query-only)
275
+
276
+ **Protocol:** `protocols/graphify.md` | **Mode:** Query-only — no guard, no build prompts.
277
+
278
+ If `graphify-out/graph.json` exists and the `graphify` CLI is available, check the `graphify.query` preference in `.forge/local.yaml`:
279
+ - `always` → run CLI queries below
280
+ - `never` → skip CLI queries, trace manually
281
+ - `ask` or absent → prompt once before the first query ("Graphify CLI detected. Use graph queries for dependency tracing? (a) Yes (b) Always (c) No (d) Never")
282
+
283
+ If graph.json is missing OR CLI is unavailable, trace manually. Do not prompt for install or build — debugging should stay fast.
284
+
285
+ **CLI queries:**
286
+ - `graphify path "[error source]" "[suspected cause]" --graph graphify-out/graph.json` — trace dependency chain from symptom to potential root cause
287
+ - `graphify explain "[unfamiliar component]" --graph graphify-out/graph.json` — understand components encountered during investigation
288
+ - `graphify query "what calls [failing function]" --budget 1000 --graph graphify-out/graph.json` — find all callers of the failing code
289
+
290
+ **Codex bridge:** Pass graph-traced dependency paths to the Codex verify step below for alternative hypothesis generation.
291
+
292
+ #### Codex Integration
293
+ **Modes:** Verify or Takeover | **Protocol:** `protocols/codex.md`
294
+
295
+ - **Verify:** Claude investigates, Codex proposes alternative hypotheses.
296
+ - **Takeover:** Codex investigates root cause, Claude reviews and tests hypotheses.
297
+
298
+ **When:** After Phase 2 pattern analysis, before forming hypotheses in Phase 3.
299
+
300
+ **Context to pass:**
301
+ - Path to the file(s) containing the bug
302
+ - Claude's pattern analysis findings (inline summary)
303
+ - Error output / stack trace (inline)
304
+
305
+ **What Codex reviews:**
306
+ - Alternative hypotheses Claude hasn't considered
307
+ - Different root causes based on different assumptions
308
+ - Similar patterns in other parts of the codebase that might have the same bug
309
+
310
+ **Prompt focus:** "Given this bug and this pattern analysis, propose alternative root causes. What assumptions might be wrong? What other code paths could produce this symptom? Don't confirm existing analysis — generate new angles."
311
+
312
+ **Presentation:** Claude's analysis + Codex's alternative hypotheses. Both feed into Phase 3 hypothesis testing.
313
+
314
+ ### Phase 3: Hypothesis and Testing
315
+
316
+ **Scientific method:**
317
+
318
+ 1. **Form Single Hypothesis**
319
+ - State clearly: "I think X is the root cause because Y"
320
+ - Write it down explicitly
321
+ - Be specific, not vague
322
+ - The hypothesis must explain ALL observed symptoms
323
+
324
+ 2. **Test Minimally**
325
+ - Make the SMALLEST possible change to test the hypothesis
326
+ - One variable at a time
327
+ - Do NOT fix multiple things at once
328
+ - Predict what should happen if your hypothesis is correct
329
+
330
+ 3. **Verify Before Continuing**
331
+ - Did the test confirm your hypothesis? Yes -> Phase 4
332
+ - Did it not? Form a NEW hypothesis based on what you learned
333
+ - Do NOT add more fixes on top of an unconfirmed hypothesis
334
+
335
+ 4. **When You Do Not Know**
336
+ - Say "I don't understand X" explicitly
337
+ - Do not pretend to know
338
+ - Research more: read source code, check documentation, search for the error
339
+ - Ask the user for additional context if needed
340
+
341
+ ### Phase 4: Implementation
342
+
343
+ **Fix the root cause, not the symptom:**
344
+
345
+ 1. **Create Failing Test Case**
346
+ - Write the simplest possible test that demonstrates the bug
347
+ - It must FAIL before the fix (this proves it tests the right thing)
348
+ - Automated test if possible, one-off test script if no framework
349
+ - This test MUST exist before you write the fix
350
+ - Use `build-tdd` discipline for writing proper failing tests
351
+
352
+ 2. **Implement Single Fix**
353
+ - Address the ROOT CAUSE identified in Phase 1-3
354
+ - ONE change at a time
355
+ - No "while I'm here" improvements
356
+ - No bundled refactoring
357
+ - No "let me also fix this other thing"
358
+
359
+ 3. **Verify Fix**
360
+ - The new test passes
361
+ - All existing tests still pass
362
+ - The original reported issue is resolved
363
+ - No new warnings or errors introduced
364
+
365
+ 4. **If Fix Does Not Work**
366
+ - STOP
367
+ - Count: How many fixes have you tried?
368
+ - If fewer than 3: Return to Phase 1, re-analyze with new information from the failed fix
369
+ - **If 3 or more: STOP and question the architecture (see step 5)**
370
+ - Do NOT attempt Fix #4 without architectural discussion
371
+
372
+ 5. **If 3+ Fixes Have Failed: Escalate**
373
+
374
+ Before concluding this is an architectural problem, if you have not yet used trace methodology, dispatch the **tracer** subagent now. Multiple failed fixes often indicate a wrong assumption (Lane 3) rather than a wrong architecture.
375
+
376
+ **Patterns indicating an architectural problem:**
377
+ - Each fix reveals new shared state, coupling, or a problem in a different place
378
+ - Fixes require "massive refactoring" to implement
379
+ - Each fix creates new symptoms elsewhere
380
+ - The code path is so tangled that isolating the issue is nearly impossible
381
+
382
+ **STOP and question fundamentals:**
383
+ - Is this pattern fundamentally sound?
384
+ - Are we sticking with it through sheer inertia?
385
+ - Should we refactor the architecture instead of continuing to fix symptoms?
386
+ - Is there a simpler design that would eliminate this class of bugs?
387
+
388
+ **Discuss with the user before attempting more fixes.**
389
+
390
+ This is NOT a failed hypothesis -- this is a wrong architecture.
391
+
392
+ 6. **After Fix: Record the Lesson**
393
+ - Invoke `support-gotcha` to record what went wrong
394
+ - Include: what happened, why, how to prevent it in the future
395
+ - Tag which skills should incorporate this lesson
396
+ - This is how the system learns and improves
397
+
398
+ ## STOP Signals
399
+
400
+ If you catch yourself thinking any of these, or the user says anything similar — **STOP and return to Phase 1:**
401
+
402
+ | Trigger | What It Means | Action |
403
+ |---|---|---|
404
+ | "Quick fix" / "Just try X" | Guessing, not debugging | Return to Phase 1 |
405
+ | "Add multiple changes at once" | Can't isolate what worked | One change at a time |
406
+ | "Skip the test" | Untested fixes don't stick | Write test first |
407
+ | "One more fix" (after 2+ failures) | 3-fix threshold hit | Question architecture |
408
+ | "The library must be broken" | Almost certainly your code | Verify via docs/context7 |
409
+ | "I see the problem, let me fix it" | Symptoms ≠ root cause | Verify before fixing |
410
+ | "I don't fully understand but this might work" | Incomplete understanding | Research more before proceeding |
411
+ | "Pattern says X but I'll adapt it" | Partial pattern reading | Read the FULL reference first |
412
+ | "The user said it's X so let me fix X" | Unchecked user report | Fact-check first (Phase 0) |
413
+ | User: "Stop guessing" / "Did you check?" | You assumed without evidence | Return to Phase 1 |
414
+ | User: "Think harder" / frustrated tone | Your approach isn't working | Change strategy |
415
+
416
+ ## Integration with the forge Harness
417
+
418
+ ### How Debug Fits in Commands
419
+
420
+ - `/bugfix` command: invokes `support-debug` as the primary skill
421
+ - `/hotfix` command: invokes `support-debug` with expedited gates (but same four phases)
422
+ - `/feature` command: invokes `support-debug` if build phase encounters issues
423
+
424
+ ### Post-Fix Workflow
425
+
426
+ After a successful fix:
427
+
428
+ 1. **Invoke support-gotcha** -- Record the lesson
429
+ 2. **Update manifest** -- If debugging was part of a feature, update the manifest status
430
+ 3. **Check for pattern** -- If this is the 3rd time a similar bug occurred, gotcha system will flag it for promotion to a rule
431
+
432
+ ### Tools for Fact-Checking
433
+
434
+ When verifying library behavior or API specifications:
435
+
436
+ - **context7**: Fetch current documentation for any library
437
+ - `mcp__plugin_context7_context7__resolve-library-id` to find the library
438
+ - `mcp__plugin_context7_context7__query-docs` to read the docs
439
+ - **Web search**: For recent changes, CVEs, or migration guides
440
+ - **Project dependencies**: Check `package.json`, `pyproject.toml`, etc. for exact versions
441
+ - **Changelogs**: Check if behavior changed between versions
442
+
443
+ ## When Process Reveals No Clear Root Cause
444
+
445
+ If systematic investigation reveals the issue is truly environmental, timing-dependent, or external:
446
+
447
+ 1. You have completed the process (this is valid)
448
+ 2. Document what you investigated and ruled out
449
+ 3. Implement appropriate handling (retry logic, timeout, descriptive error message)
450
+ 4. Add monitoring/logging for future investigation
451
+ 5. Record in `support-gotcha` for awareness
452
+
453
+ **But:** 95% of "no root cause" cases are incomplete investigation. Be honest about whether you truly exhausted all avenues.
454
+
455
+ ## Quick Reference
456
+
457
+ | Phase | Key Activities | Success Criteria |
458
+ |---|---|---|
459
+ | **0. Fact-Check** | Verify reported problem, check library docs, confirm environment | Problem confirmed as described (or real issue identified) |
460
+ | **1. Root Cause** | Read errors, reproduce, check changes, gather evidence, trace data flow | Understand WHAT is wrong and WHERE it originates |
461
+ | **2. Pattern** | Find working examples, compare, identify differences | Differences between working and broken are cataloged |
462
+ | **3. Hypothesis** | Form theory, test with minimal change, verify | Confirmed hypothesis or new hypothesis formed |
463
+ | **4. Implementation** | Create failing test, implement single fix, verify all tests pass | Bug fixed, test added, no regressions |
464
+ | **Post-Fix** | Record lesson in support-gotcha, update manifest | Lesson recorded for future prevention |
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: support-dream
3
+ description: "Use when the user asks to 'consolidate the wiki', 'clean up aiwiki', 'merge duplicate notes', 'prune stale gotchas', or when /evolve runs maintenance. Also auto-fires on phase-close or when context approaches compaction (~85%). Merges aiwiki duplicates, resolves contradictions, refreshes the session index. Output goes to aiwiki/proposed/ for user review — input is never modified."
4
+ ---
5
+
6
+ # Support: Dream (Wiki Consolidation)
7
+
8
+ ## Overview
9
+
10
+ The `aiwiki/` accumulates noise: raw notes that need to be classified, gotcha files that overlap, conventions that drift, session files that need to be summarized before context is lost. Dream consolidates all of it.
11
+
12
+ **Core principle:** input store is never modified. Dream produces a NEW reviewable state in `aiwiki/proposed/{dream_id}/`; the user accepts (atomic swap) or rejects (discard).
13
+
14
+ **Announce at start:** "I'm using the support-dream skill to consolidate `aiwiki/` for [trigger]."
15
+
16
+ This skill orchestrates wiki consolidation. It dispatches the `dreamer` subagent to do the actual LLM consolidation work. Different providers (forge-local default, anthropic-managed optional) supply different consolidation backends behind the same skill interface.
17
+
18
+ ## When to Use
19
+
20
+ Three triggers, distinct intents:
21
+
22
+ | Trigger | Intent | Scope |
23
+ |---|---|---|
24
+ | **Phase close** (Phase 4 (iterate) lock, Phase 5 (codify) lock, Phase 6 (production-build) per-slice close, Phase 7 (deliver) retrospective) | Promote phase outputs into curated wiki state | Subfolders touched by the phase |
25
+ | **PreCompact hook fire** (~85% context utilization) | Consolidate session signal into durable form before lossy compaction | `aiwiki/sessions/{current}` + `aiwiki/raw/` + recently-touched typed pages |
26
+ | **Manual `/dream`** | User-driven cleanup (after major refactor, branch merge, accumulated noise) | User-specified |
27
+
28
+ **Do NOT skip when:**
29
+ - Phase close — the next phase's work depends on consolidated state
30
+ - PreCompact — fires once before compaction; missing it means session signal is lost on compact
31
+
32
+ **Do NOT run when:**
33
+ - The wiki has no recent changes (no raw entries, no recent typed-page writes, no session events) — there's nothing to consolidate; the cycle would no-op
34
+
35
+ ## What Dream Does NOT Do
36
+
37
+ - Does NOT modify `aiwiki/` directly (writes only to `aiwiki/proposed/{dream_id}/`)
38
+ - Does NOT modify `.forge/work/` (manifest is operational state, not knowledge)
39
+ - Does NOT delete or archive accepted typed pages (only the user does, via `forge wiki accept` / `reject`)
40
+ - Does NOT enforce schemas (LINT does that — runs on the proposed output before marking the dream complete)
41
+ - Does NOT promote raw entries on its own judgment if they fail their target schema (flags them in the manifest; user reviews)
42
+
43
+ ## Trigger Flow
44
+
45
+ ### Phase-close trigger
46
+
47
+ Fired by phase-close hooks (after user emits the phase-lock signal):
48
+
49
+ 1. Skill detects phase-close event (e.g. Phase 4 lock)
50
+ 2. Determines scope based on which phase closed (e.g. Phase 4 → `aiwiki/raw/` written during Phase 4 + Phase 4 gotchas/conventions)
51
+ 3. Dispatches `dreamer` subagent with scope + provider config
52
+ 4. Dreamer produces `aiwiki/proposed/{dream_id}/` + `.dream-manifest.json`
53
+ 5. LINT runs on proposed output; results recorded in manifest
54
+ 6. Phase-close gate **blocks the next phase** until the user reviews this dream — the next phase reads consolidated wiki state, so it cannot proceed against pending unreviewed proposals
55
+
56
+ ### PreCompact trigger
57
+
58
+ Fired by forge's existing pre-compact hook (~85% context):
59
+
60
+ 1. Hook calls skill with scope `[aiwiki/sessions/{current}, aiwiki/raw/, recently-touched-typed-pages]`
61
+ 2. **Sync prerequisite** — session checkpoint hook has already updated `aiwiki/sessions/{current}.md` with all events. Dream IMPROVES this file; does not produce its existence.
62
+ 3. Dispatches `dreamer` subagent
63
+ 4. Output to `aiwiki/proposed/{dream_id}/`
64
+ 5. LINT runs on proposed output
65
+ 6. Native compaction proceeds (does not wait for user review — the consolidated session file is already on disk)
66
+
67
+ ### Manual /dream trigger
68
+
69
+ User invokes `/dream [scope]`:
70
+
71
+ 1. Skill parses scope (default: full `aiwiki/`; alternatives: `aiwiki/raw/`, `aiwiki/gotchas/`, etc.)
72
+ 2. Dispatches `dreamer` subagent
73
+ 3. Output to `aiwiki/proposed/{dream_id}/`
74
+ 4. LINT runs on proposed output
75
+ 5. User reviews via `forge wiki review {dream_id}`
76
+
77
+ ## Inputs (per trigger)
78
+
79
+ | Source | Always | Phase-close | PreCompact | Manual |
80
+ |---|---|---|---|---|
81
+ | Current `aiwiki/` (typed pages) | ✓ | ✓ | ✓ | ✓ |
82
+ | Page schemas (`aiwiki/schemas/`) | ✓ | ✓ | ✓ | ✓ |
83
+ | `aiwiki/raw/` | ✓ | ✓ | ✓ | ✓ |
84
+ | `aiwiki/sessions/{current}.md` | — | — | ✓ | optional |
85
+ | Recent commits (since last dream) | — | ✓ (since phase start) | ✓ (since session start) | optional |
86
+ | Phase 4 prototype iteration logs | — | ✓ (Phase 4 close only) | — | — |
87
+ | Anthropic Managed Agents session IDs | — | — | — | — (only with `anthropic-managed` provider) |
88
+
89
+ The dispatch prompt carries the scope; the dreamer subagent reads from disk.
90
+
91
+ ## Outputs
92
+
93
+ Dream produces a directory `aiwiki/proposed/{dream_id}/` mirroring `aiwiki/` structure, plus a manifest:
94
+
95
+ `aiwiki/proposed/{dream_id}/.dream-manifest.json`:
96
+
97
+ ```json
98
+ {
99
+ "dream_id": "2026-05-10-1042-phase4-close",
100
+ "trigger": "phase-close",
101
+ "trigger_detail": "Phase 4 lock (feature/auth-refactor)",
102
+ "scope": ["aiwiki/raw/", "aiwiki/gotchas/2026-05/", "aiwiki/conventions/"],
103
+ "base_aiwiki_hash": "sha256:a3f2bc1...",
104
+ "created_at": "2026-05-10T10:42:00Z",
105
+ "provider": "forge-local",
106
+ "changed_pages": 3,
107
+ "new_pages": 1,
108
+ "deleted_pages": 0,
109
+ "lint_status": "passed",
110
+ "lint_warnings": [],
111
+ "review_status": "pending",
112
+ "reviewed_at": null,
113
+ "operations": [
114
+ {"op": "merge", "files": ["aiwiki/gotchas/2026-05-08-x.md", "aiwiki/gotchas/2026-05-09-x-recur.md"], "into": "aiwiki/gotchas/2026-05-10-x-merged.md", "reason": "duplicate root cause"},
115
+ {"op": "promote", "from": "aiwiki/raw/2026-05-09-handler-naming.md", "into": "aiwiki/conventions/handler-naming.md", "reason": "matches convention schema"},
116
+ {"op": "prune", "file": "aiwiki/raw/2026-05-01-investigate-cache.md", "reason": "investigation completed; ADR 0042 captures outcome"}
117
+ ]
118
+ }
119
+ ```
120
+
121
+ The `operations` log lets the user understand the diff at a glance without reading every file.
122
+
123
+ ## Consolidation pipeline
124
+
125
+ The actual consolidation work — read aiwiki, identify merges/promotions/prunes, write proposed output, build the manifest — runs in the `dreamer` subagent. The pipeline is canonical in `agents/dreamer.md`; do not duplicate it here. This skill's job is dispatch (decide provider, scope, trigger detail) and post-dispatch handling (run LINT on the proposed output, update the manifest, surface to the user).
126
+
127
+ ## Provider model
128
+
129
+ The skill dispatches different consolidation backends based on configuration:
130
+
131
+ ### `forge-local` (default)
132
+
133
+ - Dispatches `dreamer` subagent locally (Claude Code subagent dispatch)
134
+ - Reads from local filesystem (`aiwiki/`, schemas, session events)
135
+ - Writes proposed output locally
136
+ - No cloud dependency; free with subscription
137
+
138
+ ### `anthropic-managed` (optional)
139
+
140
+ Enabled by `forge config set wiki.dream.provider anthropic-managed` or `FORGE_DREAM_PROVIDER=anthropic-managed`.
141
+
142
+ - Adapts accepted `aiwiki/` pages into Anthropic memory-store format
143
+ - Calls Anthropic Dreams API with optional Managed Agents session IDs
144
+ - Maps the output store back into typed markdown in `aiwiki/proposed/{dream_id}/`
145
+ - Runs forge LINT on the result (Anthropic output may not match forge schemas; LINT catches drift)
146
+
147
+ The skill detects the provider from config and dispatches accordingly. The `dreamer` subagent's instructions are provider-aware (see `agents/dreamer.md`).
148
+
149
+ ## CLI Surface
150
+
151
+ This skill operates the dream side; the user-facing CLI is separate but documented here for completeness:
152
+
153
+ | Command | Purpose |
154
+ |---|---|
155
+ | `forge wiki status` | List pending dreams (sorted by `created_at`, oldest first) |
156
+ | `forge wiki review [dream_id]` | Open per-page review flow (`$EDITOR` opens diff for each changed file) |
157
+ | `forge wiki accept [dream_id]` | Atomic swap: `aiwiki/proposed/{dream_id}/` contents replace `aiwiki/` per-file. Old contents archived to `.forge/wiki-history/{timestamp}/`. |
158
+ | `forge wiki reject [dream_id] --reason "..."` | Discard. Logged in `.forge/dream-history.jsonl` with reason. |
159
+
160
+ ## Invariants
161
+
162
+ **Never:**
163
+ - Write to `aiwiki/` directly (only `aiwiki/proposed/{dream_id}/`)
164
+ - Write to `.forge/work/` (operational state, not knowledge)
165
+ - Skip LINT on proposed output
166
+ - Promote a raw entry that fails its target schema without flagging it in the manifest's `lint_warnings`
167
+ - Run a new dream while the current one's `aiwiki/proposed/{dream_id}/` is still pending review (queue them; do not overwrite)
168
+
169
+ **Always:**
170
+ - Record the `base_aiwiki_hash` so the user can detect if `aiwiki/` changed mid-dream (rare, but possible if a session writes during dream)
171
+ - Include the `operations` log in the manifest so review is one-glance, not file-by-file fishing
172
+ - Keep the proposed output's structure mirroring `aiwiki/` exactly (so atomic swap is per-file safe)
173
+
174
+ ## Common Mistakes
175
+
176
+ | Mistake | Fix |
177
+ |---|---|
178
+ | Modifying `aiwiki/` directly during consolidation | All writes go to `aiwiki/proposed/{dream_id}/`; the swap is the user's action |
179
+ | Writing to `aiwiki/sessions/{current}.md` to "create" the file | Session checkpoint hook creates the file; dream only refines an existing file |
180
+ | Running dream when there's no signal to consolidate | Skip the dream entirely; record nothing |
181
+ | Skipping LINT on proposed output | LINT MUST run; lint warnings go into the manifest, surface during review |
182
+ | Promoting raw entries without reading the target schema | Read `aiwiki/schemas/{type}.md` first; the raw entry must satisfy required sections + frontmatter |
183
+ | Overwriting a previous proposed dream | New dreams create new `{dream_id}` directories; queue accumulates; the user reviews in order |
184
+
185
+ ## I/O Contract
186
+
187
+ | Field | Value |
188
+ |---|---|
189
+ | **Requires** | `aiwiki/` (or empty), `aiwiki/schemas/` (the typed-page schemas), provider config (`forge-local` default) |
190
+ | **Produces** | `aiwiki/proposed/{dream_id}/` (mirror structure), `aiwiki/proposed/{dream_id}/.dream-manifest.json` |
191
+ | **Triggers** | Phase-close hooks, pre-compact hook, manual `/dream` |
192
+ | **Updates manifest** | `.forge/dream-history.jsonl` (one append per dream cycle, regardless of accept/reject) |
193
+
194
+ ## Integration
195
+
196
+ **Called by:**
197
+ - Phase-close hooks (Phase 4 (iterate) lock, Phase 5 (codify) lock, Phase 6 (production-build) per-slice close, Phase 7 (deliver) retrospective)
198
+ - Pre-compact hook (forge's existing context-monitor at ~85%)
199
+ - `/dream` slash command
200
+
201
+ **Dispatches:**
202
+ - `dreamer` subagent (forge-local provider) — see `agents/dreamer.md`
203
+ - Anthropic Dreams API (anthropic-managed provider) — via the `support-dream` skill's provider adapter
204
+
205
+ **Pairs with:**
206
+ - `support-wiki-lint` — LINT runs on dream's proposed output
207
+ - `support-context-monitor` — fires the pre-compact trigger
208
+ - `support-gotcha` — provides the gotcha files dream may merge
209
+ - Phase-close hooks for Phase 4 (`iterate-prototype`), Phase 5 (`harden`), Phase 6 (per-slice gates), Phase 7 (deliver) (`support-gotcha` retrospective)
210
+
211
+ **Forbidden integrations:**
212
+ - Cannot be called from inside another dream (no nested dreams)
213
+ - Cannot be called as a write target by other skills (other skills write to `aiwiki/raw/` or typed pages directly; dream consolidates separately)