@jamie-tam/forge 6.0.0 → 6.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/README.md +77 -59
  2. package/agents/dreamer.md +10 -7
  3. package/agents/gotcha-hunter.md +1 -1
  4. package/agents/prototype-codifier.md +2 -2
  5. package/commands/{forge.md → discover.md} +13 -9
  6. package/commands/dream.md +71 -0
  7. package/commands/feature.md +57 -10
  8. package/commands/{evolve.md → forge-evolve.md} +3 -3
  9. package/commands/greenfield.md +5 -5
  10. package/commands/note.md +64 -0
  11. package/commands/{task-force.md → parallel.md} +15 -15
  12. package/commands/resume.md +2 -2
  13. package/commands/setup.md +18 -17
  14. package/commands/status.md +2 -2
  15. package/commands/wrap.md +130 -0
  16. package/dist/__tests__/hooks.test.js +334 -0
  17. package/dist/__tests__/init.test.js +110 -0
  18. package/dist/__tests__/work-manifest.test.js +48 -14
  19. package/dist/cli.js +0 -0
  20. package/dist/hooks.js +88 -6
  21. package/dist/init.js +39 -1
  22. package/dist/uninstall.js +11 -5
  23. package/dist/work-manifest.js +63 -24
  24. package/hooks/config/gate-requirements.json +1 -1
  25. package/hooks/hooks.json +14 -1
  26. package/hooks/scripts/gate-enforcer.sh +51 -6
  27. package/hooks/scripts/pre-compact.sh +120 -55
  28. package/hooks/scripts/session-start.sh +43 -4
  29. package/hooks/scripts/telemetry.sh +32 -2
  30. package/hooks/templates/CLAUDE.md.template +6 -3
  31. package/package.json +1 -1
  32. package/references/common/phases.md +8 -6
  33. package/references/common/skill-authoring.md +1 -1
  34. package/rules/common/forge-system.md +64 -6
  35. package/rules/common/quality-gates.md +2 -0
  36. package/skills/build-prototype/SKILL.md +4 -4
  37. package/skills/build-tdd/SKILL.md +14 -0
  38. package/skills/concept-slides/SKILL.md +11 -11
  39. package/skills/deliver-deploy/SKILL.md +10 -1
  40. package/skills/harden/SKILL.md +22 -8
  41. package/skills/iterate-prototype/SKILL.md +22 -0
  42. package/skills/quality-test-execution/SKILL.md +26 -1
  43. package/skills/quality-test-plan/SKILL.md +21 -1
  44. package/skills/support-debug/SKILL.md +1 -1
  45. package/skills/support-dream/SKILL.md +8 -7
  46. package/skills/support-gotcha/SKILL.md +3 -3
  47. package/skills/{support-task-force → support-parallel}/SKILL.md +22 -22
  48. package/skills/{support-task-force → support-parallel}/references/dispatch-pattern.md +10 -10
  49. package/skills/{support-task-force → support-parallel}/references/synthesis-template.md +10 -10
  50. package/skills/support-skill-validator/SKILL.md +5 -5
  51. package/skills/support-skill-validator/references/validation-checks.md +1 -1
  52. package/skills/support-system-guide/SKILL.md +4 -3
  53. package/skills/support-wiki-lint/scripts/lint.mjs +52 -0
  54. package/templates/README.md +1 -1
  55. package/templates/aiwiki/CLAUDE.md.template +48 -22
  56. package/templates/aiwiki/schemas/session.md +134 -49
  57. package/templates/manifests/bugfix.yaml +1 -1
  58. package/templates/manifests/feature.yaml +1 -1
  59. package/templates/manifests/greenfield.yaml +1 -1
  60. package/templates/manifests/hotfix.yaml +1 -1
  61. package/templates/manifests/refactor.yaml +1 -1
  62. package/templates/manifests/v5/SCHEMA.md +14 -17
  63. package/templates/manifests/v5/feature.yaml +1 -1
  64. package/templates/manifests/v6/SCHEMA.md +14 -10
  65. package/commands/abort.md +0 -25
  66. package/dist/__tests__/active-manifest.test.js +0 -272
  67. package/dist/__tests__/gate-check.test.js +0 -384
  68. package/dist/active-manifest.js +0 -229
  69. package/dist/gate-check.js +0 -326
@@ -1,12 +1,19 @@
1
1
  #!/usr/bin/env bash
2
2
  # Session start check: surface promotion-pending gotchas, unresolved hotfix
3
- # workarounds, and paused work items. Runs as a SessionStart hook — warns
4
- # loudly via stderr but does not block (Claude Code treats SessionStart exit
5
- # codes advisorily).
3
+ # workarounds, paused work items, and the latest session handoff. Runs as a
4
+ # SessionStart hook — warns loudly via stderr but does not block (Claude Code
5
+ # treats SessionStart exit codes advisorily).
6
6
  #
7
7
  # Resolves .forge at the repo root via `git rev-parse --show-toplevel` to match
8
8
  # pre-compact.sh and telemetry.sh. Scans `.forge/work/*/` (typed subdirs) and
9
9
  # skips `escalated`/`completed` manifests (terminal states).
10
+ #
11
+ # Session handoff: reads the LATEST aiwiki/sessions/*.md (by mtime, within
12
+ # 7 days) and surfaces:
13
+ # - one-line summary (focus + status)
14
+ # - any "Status: unconsumed" Checkpoints directives the next agent should act on
15
+ # The session file is created lazily by pre-compact.sh / /wrap / /dream / harden —
16
+ # NOT by this hook (avoids empty-file noise from trivial 30-second sessions).
10
17
 
11
18
  set -u
12
19
 
@@ -15,6 +22,38 @@ FORGE_DIR="$PROJECT_ROOT/.forge"
15
22
  GLOBAL_GOTCHAS="$HOME/.claude/gotchas"
16
23
  WARNINGS=""
17
24
 
25
+ # Latest session handoff: find the most recently modified session file within
26
+ # the last 7 days and surface its focus + any unconsumed checkpoints.
27
+ if [ -d "$PROJECT_ROOT/aiwiki/sessions" ]; then
28
+ LATEST_SESSION="$(find "$PROJECT_ROOT/aiwiki/sessions" -maxdepth 1 -type f -name '*.md' \
29
+ ! -name 'INDEX.md' ! -name 'CLAUDE.md' \
30
+ -mtime -7 -print0 2>/dev/null \
31
+ | xargs -0 stat -f '%m %N' 2>/dev/null \
32
+ | sort -rn | head -1 | cut -d' ' -f2-)"
33
+
34
+ if [ -n "$LATEST_SESSION" ] && [ -f "$LATEST_SESSION" ]; then
35
+ SESSION_NAME="$(basename "$LATEST_SESSION" .md)"
36
+ FOCUS="$(grep -m1 '^focus:' "$LATEST_SESSION" 2>/dev/null | sed 's/^focus:[[:space:]]*//')"
37
+ STATUS="$(grep -m1 '^status:' "$LATEST_SESSION" 2>/dev/null | sed 's/^status:[[:space:]]*//')"
38
+ # Count active directives by the exact bold-header pattern. Loose patterns
39
+ # like 'Status: unconsumed' false-positive on prose mentions of the
40
+ # mark-consumed protocol (surfaced during dogfood, 2026-05-18).
41
+ # `grep -c` already prints "0" when no matches; the `|| true` swallows the
42
+ # exit-1 without appending a second "0" (which would break the -gt check
43
+ # below — also dogfood-found).
44
+ UNCONSUMED_COUNT="$(grep -c '^\*\*Dream directive (unconsumed):\*\*$' "$LATEST_SESSION" 2>/dev/null || true)"
45
+ UNCONSUMED_COUNT="${UNCONSUMED_COUNT:-0}"
46
+
47
+ WARNINGS="${WARNINGS}SESSION HANDOFF: previous session ${SESSION_NAME} (status: ${STATUS:-unknown}, focus: ${FOCUS:-unset}).\n"
48
+ WARNINGS="${WARNINGS} File: ${LATEST_SESSION}\n"
49
+ if [ "$UNCONSUMED_COUNT" -gt 0 ]; then
50
+ WARNINGS="${WARNINGS} HARD-INTERRUPT: ${UNCONSUMED_COUNT} unconsumed checkpoint directive(s) — read ## Checkpoints in this file, act on the directive (typically: invoke support-dream), then mark the entry consumed before doing other work.\n"
51
+ elif [ "${STATUS:-}" = "active" ]; then
52
+ WARNINGS="${WARNINGS} Previous session left active (no /wrap fired). Read ## Files touched / ## Next steps for context, then continue or run /wrap to finalize.\n"
53
+ fi
54
+ fi
55
+ fi
56
+
18
57
  # Hard-interrupt: promotion-pending gotchas.
19
58
  # When `support-gotcha` auto-drafts a proposed rule at the 3rd occurrence,
20
59
  # the gotcha's INDEX status column flips to `promotion-pending` and a
@@ -52,7 +91,7 @@ if [ -d "$PROJECT_ROOT/aiwiki/gotchas" ]; then
52
91
 
53
92
  if [ -n "$HOTFIX_FILES" ]; then
54
93
  COUNT=$(echo "$HOTFIX_FILES" | wc -l | tr -d ' ')
55
- WARNINGS="${WARNINGS}WARNING: ${COUNT} unresolved hotfix workaround(s) in aiwiki/gotchas/. Run /evolve or address these before starting new work.\n"
94
+ WARNINGS="${WARNINGS}WARNING: ${COUNT} unresolved hotfix workaround(s) in aiwiki/gotchas/. Run /forge-evolve or address these before starting new work.\n"
56
95
  fi
57
96
  fi
58
97
 
@@ -5,6 +5,12 @@
5
5
  #
6
6
  # Output: .forge/state/telemetry.jsonl (one JSON object per line)
7
7
  #
8
+ # Each record now includes work_id when there's an in-progress manifest.
9
+ # gate-enforcer.sh filters by work_id so a stale invocation from another work
10
+ # item no longer satisfies a fresh gate — closes the cross-work-item bypass
11
+ # vector flagged in v6.1-beta audit P0-5. Records with no in-progress work
12
+ # omit the work_id field (null on the consuming side).
13
+ #
8
14
  # Note: the subagent-dispatch tool was renamed `Agent` → `Task` (canonical name
9
15
  # in current Claude Code releases). Both names are accepted here for backward
10
16
  # compatibility with existing telemetry written before the rename; `Task` is
@@ -24,17 +30,41 @@ INPUT=$(cat)
24
30
  TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // "unknown"')
25
31
  TIMESTAMP=$(date -u '+%Y-%m-%dT%H:%M:%SZ')
26
32
 
33
+ # Locate the in-progress work item (if any). Same scan pattern used by
34
+ # pre-compact.sh and session-start.sh. Cost is sub-millisecond — a small
35
+ # loop over a handful of manifest files — well within PostToolUse overhead.
36
+ ACTIVE_WORK=""
37
+ if [ -d "$PROJECT_ROOT/.forge/work" ]; then
38
+ for manifest in "$PROJECT_ROOT/.forge/work"/*/*/manifest.yaml; do
39
+ if [ -f "$manifest" ] && grep -q 'status: in-progress' "$manifest" 2>/dev/null; then
40
+ WORK_NAME="$(basename "$(dirname "$manifest")")"
41
+ WORK_TYPE="$(basename "$(dirname "$(dirname "$manifest")")")"
42
+ ACTIVE_WORK="$WORK_TYPE/$WORK_NAME"
43
+ break
44
+ fi
45
+ done
46
+ fi
47
+
48
+ # work_id field — emitted only when we resolved an in-progress manifest.
49
+ # Records without work_id naturally fail the enforcer's per-work-id filter,
50
+ # which is the desired behavior (an invocation that happened with no
51
+ # work-in-progress context cannot satisfy a gate on a specific work item).
52
+ WORK_FIELD=""
53
+ if [ -n "$ACTIVE_WORK" ]; then
54
+ WORK_FIELD=",\"work_id\":\"$ACTIVE_WORK\""
55
+ fi
56
+
27
57
  # Extract relevant fields based on tool type.
28
58
  # Task and Agent share input shape (subagent_type + description); accept either.
29
59
  case "$TOOL_NAME" in
30
60
  Skill)
31
61
  SKILL_NAME=$(echo "$INPUT" | jq -r '.tool_input.skill // "unknown"')
32
- echo "{\"timestamp\":\"$TIMESTAMP\",\"type\":\"skill\",\"name\":\"$SKILL_NAME\"}" >> "$TELEMETRY_FILE"
62
+ echo "{\"timestamp\":\"$TIMESTAMP\",\"type\":\"skill\",\"name\":\"$SKILL_NAME\"$WORK_FIELD}" >> "$TELEMETRY_FILE"
33
63
  ;;
34
64
  Task|Agent)
35
65
  AGENT_TYPE=$(echo "$INPUT" | jq -r '.tool_input.subagent_type // "unknown"')
36
66
  DESCRIPTION=$(echo "$INPUT" | jq -r '.tool_input.description // ""')
37
- echo "{\"timestamp\":\"$TIMESTAMP\",\"type\":\"agent\",\"name\":\"$AGENT_TYPE\",\"description\":\"$DESCRIPTION\"}" >> "$TELEMETRY_FILE"
67
+ echo "{\"timestamp\":\"$TIMESTAMP\",\"type\":\"agent\",\"name\":\"$AGENT_TYPE\",\"description\":\"$DESCRIPTION\"$WORK_FIELD}" >> "$TELEMETRY_FILE"
38
68
  ;;
39
69
  esac
40
70
 
@@ -19,12 +19,13 @@ project:
19
19
 
20
20
  New to this project? Describe your goal in plain English — forge auto-routes via skills, OR invoke a command directly:
21
21
 
22
- - `/forge` — one-screen orientation: what's installed, what's in flight, what to run next
22
+ - `/discover` — one-screen orientation: what's installed, what's in flight, what to run next
23
23
  - `/setup` — detect your stack and install matching language rules (run this first)
24
24
  - `/feature <name>` — develop a feature end-to-end with quality gates
25
25
  - `/bugfix <name>` — systematic debugging with root-cause analysis
26
26
  - `/refactor <name>` — restructure code without new functionality
27
- - `/task-force <list>` — parallel agents for a punch list of ad-hoc tasks
27
+ - `/note <text>` — capture an ad-hoc research note or brainstorm to `aiwiki/raw/`
28
+ - `/parallel <list>` — parallel agents for a punch list of ad-hoc tasks
28
29
  - `/validate` — check skill/rule/command consistency
29
30
 
30
31
  Operational state lives in `.forge/state/`; project knowledge in `aiwiki/`.
@@ -36,7 +37,9 @@ Claude Code's auto-memory (v2.1.59+) lives in `~/.claude/projects/<project>/memo
36
37
 
37
38
  This project uses **forge** as its development workflow. Every session should follow it: route via skills, use the `/feature`, `/bugfix`, `/refactor` etc. commands, and keep work artifacts in `.forge/`.
38
39
 
39
- System structureskills (prefix-grouped), commands, `.forge/` layout, context recovery lives in **`.claude/rules/common/forge-system.md`** (always-on rule, auto-loaded every session).
40
+ Knowledge accumulates in **`aiwiki/`** typed pages (`decisions/`, `gotchas/`, `conventions/`, `architecture/`, `sessions/`) read by subagents during their work, plus `raw/` for free-form research and brainstorm capture (use `/note <text>`). The `wiki-lint` hook validates every `aiwiki/**` write against its schema, and `support-dream` consolidates raw → typed at phase-close and PreCompact (~85% context). Operational state (manifests, telemetry) stays separate in **`.forge/`**.
41
+
42
+ System structure — skills (prefix-grouped), commands, `.forge/` layout, `aiwiki/` integration, context recovery — lives in **`.claude/rules/common/forge-system.md`** (always-on rule, auto-loaded every session).
40
43
 
41
44
  <!-- FORGE:END -->
42
45
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jamie-tam/forge",
3
- "version": "6.0.0",
3
+ "version": "6.2.0",
4
4
  "description": "AI Development Life Cycle — structured AI-assisted development with quality gates, feature manifests, and agent coordination",
5
5
  "type": "module",
6
6
  "bin": {
@@ -24,15 +24,17 @@ Phases are **defaults, not requirements**. The work-item manifest at `.forge/wor
24
24
 
25
25
  Commands (`/feature`, `/bugfix`, `/greenfield`, `/refactor`) ask the AI to propose phase skips at preflight; the user confirms. Forcing all seven on every work item is wrong shape with current model capability.
26
26
 
27
- ## Phase-conditional rules
27
+ ## Which rules apply when
28
28
 
29
- The following rules apply from Phase 5 (codify) onward, per their own phase headers:
29
+ All eight common rules auto-load every session except `testing.md`, which is paths-conditional (loads only on test files and `src/` code).
30
30
 
31
- - `rules/common/testing.md`TDD becomes mandatory
32
- - `references/common/quality-gates.md` — full gate set (the rule-tier stub at `rules/common/quality-gates.md` fans out to this reference)
33
- - `rules/common/git-workflow.md` — conventional commits + branch hygiene
31
+ The content of the following rules is **scoped to Phase 5+ work** even though they auto-load agents reading them should treat their guidance as applying from codify onward:
34
32
 
35
- Phases 1–4 operate under the safety-floor rules only (`rules/common/security.md`, `guardrails.md`, `verification.md`, `skill-selection.md`).
33
+ - `rules/common/testing.md` — TDD becomes mandatory at Phase 5; Phases 1–4 (prototype work) are exempt because mock-heavy tests under-catch wiring bugs (see `skills/build-tdd` and `skills/iterate-prototype`)
34
+ - `references/common/quality-gates.md` — full gate set (the rule stub at `rules/common/quality-gates.md` fans out to this reference)
35
+ - `rules/common/git-workflow.md` — conventional commits + branch hygiene; relevant once Phase 5 codify produces code-shaped artifacts
36
+
37
+ The other five rules (`security`, `guardrails`, `verification`, `skill-selection`, `forge-system`) apply across all phases.
36
38
 
37
39
  ## How to reference this in agent/skill files
38
40
 
@@ -1,6 +1,6 @@
1
1
  # Skill Authoring Guidelines
2
2
 
3
- Principles for creating and modifying skills. Reference this when using the skill-creator or `/evolve`.
3
+ Principles for creating and modifying skills. Reference this when using the skill-creator or `/forge-evolve`.
4
4
 
5
5
  ## Atomic Single-Responsibility
6
6
 
@@ -1,5 +1,5 @@
1
1
  ---
2
- description: Forge system structure — skills (prefix-grouped), commands (orchestrate skills), .forge/ directory layout, context recovery. Auto-loaded every session so agents know the system they're operating in.
2
+ description: Forge system structure — skills (prefix-grouped), commands (orchestrate skills), .forge/ directory layout, aiwiki/ knowledge layer, context recovery. Auto-loaded every session so agents know the system they're operating in.
3
3
  ---
4
4
 
5
5
  # Forge System
@@ -23,14 +23,15 @@ v6 also adds phase skills: concept-slides, build-wireframe, build-prototype, ite
23
23
 
24
24
  | Command | When to use |
25
25
  |---------|------------|
26
- | `/forge` | One-screen discovery — installed capabilities, active work, suggested next |
26
+ | `/discover` | One-screen discovery — installed capabilities, active work, suggested next |
27
27
  | `/setup` | Detect stack, install matching language rules, and fill the project profile |
28
28
  | `/feature` | Full feature development |
29
29
  | `/greenfield` | New project from zero |
30
30
  | `/bugfix` | Fix a bug |
31
31
  | `/refactor` | Improve existing code |
32
32
  | `/hotfix` | Emergency production fix |
33
- | `/evolve` | Improve the forge system itself |
33
+ | `/note <text>` | Capture an ad-hoc research note or brainstorm to `aiwiki/raw/{date}.md` |
34
+ | `/forge-evolve` | Improve the forge system itself |
34
35
  | `/validate` | Check skill consistency |
35
36
 
36
37
  ## .forge/ Directory
@@ -43,16 +44,73 @@ v6 also adds phase skills: concept-slides, build-wireframe, build-prototype, ite
43
44
  refactor/{name}/ # manifest, codebase analysis, tasks, test results
44
45
  hotfix/{name}/ # manifest, minimal debug, smoke tests
45
46
  greenfield/{name}/ # manifest + full project scaffold artifacts
46
- state/ # Runtime state (notepad.md, telemetry, dream history)
47
+ state/ # Runtime state (telemetry, dream history). Per-session handoff lives in aiwiki/sessions/ — see below.
47
48
  ```
48
49
 
49
- Project knowledge (ADRs, gotchas) lives under `aiwiki/` — see `aiwiki/decisions/` and `aiwiki/gotchas/`. The `.forge/` directory retains operational state only (manifests, telemetry, dream history).
50
+ The `.forge/` directory retains operational state only (manifests, telemetry, dream history). Project knowledge lives in `aiwiki/` (next section).
50
51
 
51
52
  Work items are identified by `{type}/{name}` — names may collide across types.
52
53
 
54
+ ## aiwiki/ (knowledge layer)
55
+
56
+ `aiwiki/` accumulates lasting project knowledge — separate from `.forge/` which is operational state. Subagents read these pages to inform their work, so the typed pages have schemas enforced by `wiki-lint`.
57
+
58
+ | Page type | Purpose | Written by |
59
+ |---|---|---|
60
+ | `decisions/` | ADRs — architecture decisions + rationale | `plan-brainstorm`, `harden`, manual |
61
+ | `gotchas/` | Recurring failure modes with reproducible fixes | `iterate-prototype`, `quality-code-review`, manual |
62
+ | `conventions/` | Established patterns in this codebase | `iterate-prototype`, `harden`, manual |
63
+ | `architecture/` | Component maps, sequence diagrams | `harden`, manual |
64
+ | `sessions/` | Per-session handoff: `## Checkpoints` event log (pre-compact, /dream) + index sections (Files touched, Decisions, Gotchas, Open questions, Next steps) filled by `/wrap`. Filename `{date}-{session_id_short}.md`. Lazy-created by first writer in the session. | `hooks/scripts/pre-compact.sh`, `/wrap`, `/dream`, `harden` |
65
+ | `oracles/` | Prototype behavior snapshots that Phase 6 production code must reproduce (setup → trigger → assertions) | `harden` (Step 2.5) |
66
+ | `raw/` | Append-only research/brainstorm capture (no schema) | `/note <text>`, manual |
67
+
68
+ **Auto-capture during phases.** `iterate-prototype` (Phase 4) writes gotchas and conventions surfaced during prototype iteration. Phases 1 (concept) and 2 (wireframe) have **no auto-capture** — use `/note <text>` to land research/brainstorm in `aiwiki/raw/{date}.md`.
69
+
70
+ **Lint** (`wiki-lint` PostToolUse hook). Fires on every `aiwiki/**.md` write (Edit/Write/MultiEdit). Validates frontmatter, required H2 sections, line caps, citation hash drift, and possible-secret patterns in cited content against the page's schema. Skips `aiwiki/raw/` (no schema) and `aiwiki/proposed/` (lint runs there separately at dream-complete). Findings surface on stderr — non-blocking, but the next edit should address them.
71
+
72
+ **Dream** (`support-dream` skill). Async consolidation:
73
+ - **PreCompact** (~85% context): consolidates `aiwiki/raw/` + recently-touched typed pages before lossy compaction. Also refines the active session file's `## Checkpoints` event log (if it exceeds ~10 entries) and pre-populates index sections from git diff. The pre-compact hook itself writes an unconsumed dream directive to the session file's checkpoints; the post-compact agent reads it and dispatches this skill.
74
+ - **Phase-close** (Phase 4/5/6/7 lock): promotes phase outputs into curated wiki state. The next phase **blocks** until the user reviews the proposed dream.
75
+ - **Manual `/dream`**: user-driven cleanup.
76
+
77
+ Dream outputs to `aiwiki/proposed/{dream_id}/` — input store is never modified. User atomically accepts (swap) or rejects (discard) via `forge wiki accept` / `reject`.
78
+
79
+ ### When the AI should write to aiwiki
80
+
81
+ The discipline is **selectivity, not abstention.** AI writes happen routinely — `support-gotcha`, `iterate-prototype` (via `prototype-builder`), and `harden` all write to typed pages directly during their normal operation, and the pre-compact hook + `/wrap` write to `aiwiki/sessions/`. Wiki-lint validates schema on every write; the user can edit or delete any page after the fact. The rule is what content qualifies — not whether AI can write.
82
+
83
+ Per-folder discipline:
84
+
85
+ | Folder | Who writes | Gate |
86
+ |---|---|---|
87
+ | `raw/` | **User only**, via `/note <text>` | The user is the gate. AI does NOT decide to write conversational asides to raw on its own. |
88
+ | `decisions/` `gotchas/` `conventions/` `architecture/` `oracles/` | AI writes directly via `support-gotcha`, `iterate-prototype`, `harden`, code-review subagents | Schema (enforced by wiki-lint) + durability test (below). User can edit/delete after-the-fact. |
89
+ | `sessions/` | `pre-compact.sh` (Checkpoints) + `/wrap` (index sections) + `harden` (codify-time session entry) | Schema. `/wrap` confirms with user before setting `status: done`. |
90
+ | `proposed/` | `dreamer` subagent only (via `support-dream`) | User reviews each proposal via `forge wiki ui` / `forge wiki review` and atomically accepts or rejects. |
91
+
92
+ Three durability rules that override any temptation to over-capture:
93
+
94
+ 1. **Never write speculation, conversation history, or "we might want to revisit this" notes.** This is the strongest rule. Wiki pages answer recurring questions; conversational asides do not. Speculation goes to raw via `/note` (user-gated), not to typed pages.
95
+ 2. **Typed pages need durable, reusable knowledge.** ADRs go to `decisions/` only when the choice is finalized AND hard-to-reverse (architectural, public-surface, security, schema). Gotchas to `gotchas/` only when the failure mode is reproducible with a concrete fix. Conventions to `conventions/` only when the pattern is established across multiple sites. If the knowledge isn't yet durable, it doesn't belong in a typed page.
96
+ 3. **Raw is `/note`-only.** Ad-hoc research, half-formed thoughts, deferred decisions, comparison notes all go to `aiwiki/raw/` — and ONLY when the user explicitly invokes `/note <text>`. The AI does not autonomously decide what becomes raw content.
97
+
98
+ When a typed-page-worthy insight emerges mid-conversation (e.g., "this is a real gotcha"), write it to the correct typed page if it meets that page's durability test. When the durability is uncertain, ask the user instead of speculating.
99
+
100
+ **Session-end handoff.** Forge provides `/wrap` for explicit session-end capture. Run it at a natural session boundary: it fills the active session file's index sections (Files touched / Decisions made / Gotchas surfaced / Open questions / Next steps) and sets `status: done`. The next `SessionStart` hook surfaces the latest session's focus and any unconsumed `## Checkpoints` directives. If `/wrap` isn't invoked, the session file (if pre-compact created one) stays `status: active` — `SessionStart` will surface it as unfinalized so the next session can pick up. The AI should OFFER to run `/wrap` before a long break or context shift; never silently fabricate a session summary.
101
+
53
102
  ## Context Recovery
54
103
 
55
- If `.forge/state/notepad.md` exists, read it FIRST before doing anything else.
104
+ On session start or after compaction, recovery state lives in **two places**, in priority order:
105
+
106
+ 1. **`aiwiki/sessions/{date}-{session_id_short}.md`** — the per-session handoff file. Read this FIRST.
107
+ - The `## Checkpoints` section is an append-only event log. Any entry with header `**Dream directive (unconsumed):**` is an action item for the current agent (typically: invoke `support-dream`). After acting, change the header from `(unconsumed)` to `(consumed at {ISO-timestamp})`. The `session-start.sh` hook counts active directives by matching the bold header literally — flipping the header is what makes the count accurate (dogfood-validated 2026-05-18).
108
+ - The index sections (`## Files touched` / `## Decisions made` / `## Gotchas surfaced` / `## Open questions` / `## Next steps`) describe the prior session's work. If `status: done`, the file was `/wrap`'d. If `status: active`, the prior session didn't run `/wrap` — surface the file as in-progress context.
109
+ 2. **The active manifest** (`.forge/work/*/*/manifest.yaml` with `status: in-progress`). Read after the session file to anchor on the work item's current phase and gate state.
110
+
111
+ `SessionStart` hook (`hooks/scripts/session-start.sh`) automatically surfaces the latest session file's focus + any unconsumed checkpoints on stderr. The agent should still re-read the file's full content when acting on a directive.
112
+
113
+ **Notepad deprecated.** Earlier versions wrote recovery state to `.forge/state/notepad.md`. v6.2 consolidated session recovery into `aiwiki/sessions/{date}-{session_id_short}.md`. If a legacy `.forge/state/notepad.md` exists from an older install, it's safe to delete — nothing reads or writes it anymore.
56
114
 
57
115
  ## Rules
58
116
 
@@ -6,6 +6,8 @@ description: Gate-state names and pass criteria summary — auto-loaded every se
6
6
 
7
7
  Gates block phase transitions until criteria are met. See [references/common/quality-gates.md](../../references/common/quality-gates.md) for the full gate-set tables, pass criteria, and fail actions.
8
8
 
9
+ **Enforcement.** `gate-enforcer.sh` (PreToolUse hook) blocks manifest writes that set `gate-passed: true` unless the gate's required skill/agent (per `hooks/config/gate-requirements.json`) was invoked **for this work item**. The check is `work_id`-scoped: the enforcer extracts `work_id` from the edited manifest's path (`.forge/work/{type}/{name}/manifest.yaml`) and filters `.forge/state/telemetry.jsonl` to records matching that work_id. Stale invocations from another work item — or from before the work_id field was added (legacy records) — do not satisfy fresh gates. After upgrade from a pre-work_id version, re-invoke any required skill once to write a tagged telemetry record.
10
+
9
11
  Gate names (per `hooks/config/gate-requirements.json`):
10
12
  - code-review-final
11
13
  - code-review (per-slice)
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: build-prototype
3
- description: "Use to scaffold a working POC from a locked wireframe. Produces a runnable Vite + React + TS app at pocs/{name}-prototype/ with seed data, in-memory state, and screens that mirror the wireframe states. The prototype is the verification surface for concept + UX before any production code is written."
3
+ description: "Use to scaffold a working POC from a locked wireframe — triggered by phrases like 'build the prototype', 'scaffold the POC', 'wireframe is locked, start the prototype', 'turn the wireframe into something I can run', 'make it interactive', or by the wireframe-lock event in /feature and /greenfield (Phase 2 → Phase 3 transition). Produces a runnable Vite + React + TS + Tailwind + Zustand app at pocs/{name}-prototype/ with seed data, in-memory state, and screens mirroring the wireframe's locked states. The prototype is the verification surface for concept + UX before any production code is written. Skip if the wireframe is not locked (run build-wireframe first), if a prototype already exists at the target path (use iterate-prototype for changes), or if the work is production code under TDD (use build-tdd at Phase 6)."
4
4
  ---
5
5
 
6
6
  # Build Prototype
@@ -15,7 +15,7 @@ Once a wireframe is locked, the prototype turns it into something the user can r
15
15
 
16
16
  ## When to Use
17
17
 
18
- - Phase 4 of a prototype-driven flow (after wireframe is locked, before Phase 5 codification)
18
+ - Phase 3 of a prototype-driven flow (after wireframe is locked, before Phase 4 iteration and Phase 5 codification)
19
19
  - For `/feature` on existing apps: scaffold a `pocs/{feature-name}-prototype/` mini-prototype branch of the existing app's tech stack — same skill, smaller scope
20
20
  - Ad-hoc when a wireframe is mature enough to validate via running code
21
21
 
@@ -176,7 +176,7 @@ Capture findings in `pocs/{name}-prototype/.forge/feedback.md` if there's any dr
176
176
 
177
177
  ### Step 5: side-effect capture during iteration
178
178
 
179
- Phase 4 is also when real gotchas + conventions emerge. During iteration:
179
+ Phase 3 (prototype build) and Phase 4 (iteration) are when real gotchas + conventions emerge. During the build and iteration cycles:
180
180
 
181
181
  - **Gotchas**: every time prototype-builder hits a state-management surprise, library quirk, framework mounting issue, or type-system pothole, write to `aiwiki/gotchas/{date}-{slug}.md` per the gotcha schema. The wiki-lint hook validates on save.
182
182
  - **Conventions**: when patterns settle (file naming, import order, state-shape conventions, design-token usage), write to `aiwiki/conventions/{slug}.md`. The `prototype-reviewer` flags new conventions emerging across iteration cycles.
@@ -249,7 +249,7 @@ Document the choice in `pocs/{name}-prototype/README.md` so Phase 5 codification
249
249
 
250
250
  | Caller | When |
251
251
  |---|---|
252
- | Wireframe-lock event in `/feature` and `/greenfield` | Phase 3 → Phase 4 transition |
252
+ | Wireframe-lock event in `/feature` and `/greenfield` | Phase 2 → Phase 3 transition |
253
253
  | Manual invocation | When a wireframe is mature enough to verify via running code |
254
254
 
255
255
  | Dispatches | For |
@@ -67,6 +67,20 @@ Do not ask the user. The decision was persisted at task decompose handoff.
67
67
 
68
68
  When architecture artifacts exist (from `plan-architecture` or `harden`), use them to set unit-test expectations for shapes, constraints, and error behavior. Treat those contracts as the source of truth for assertions at the unit boundary. Integration tests at boundaries identified by `harden`'s slice graph are required per the Wiring Coverage subsection above — they are not optional even when the task description omits them.
69
69
 
70
+ ## Oracle Satisfaction
71
+
72
+ When `harden` (Phase 5) ran, it captured prototype behavior as integration-test oracles at `aiwiki/oracles/{slug}.md` — one per slice or subsystem. These are the load-bearing contract: production code must reproduce the oracle's `Setup → Trigger → Assertions`. They close the wiring gap that mock-heavy unit tests miss (the Flux/REACH dogfood signal that drove v6).
73
+
74
+ **Before writing the first RED test for a slice:**
75
+
76
+ 1. Read every oracle whose `slug` or `prototype_path` matches the slice being built (the slice graph entry produced by harden references its oracles).
77
+ 2. For each oracle, design at least one test that exercises its `Setup → Trigger → Assertions`. That test counts as the boundary integration test for Wiring Coverage above — so the oracle test and the wiring test are usually the same test.
78
+ 3. If the slice crosses a wiring boundary (CLI ↔ filesystem, process exec, manifest I/O, external services) and **no oracle exists for that boundary**, halt and surface to the user. Do NOT invent oracles inline; do NOT proceed against an empty oracle directory. Missing oracles mean harden has not closed — re-run harden to capture them, or surface to the user that the slice is being built without a verified prototype contract.
79
+
80
+ When this skill dispatches the **builder** subagent (manifest's `execution.mode: subagent`), the agent enforces the same discipline (see [agents/builder.md](../../agents/builder.md) "Oracles Are Load-Bearing"). When running inline, the orchestrator (this skill) is responsible — load the oracles before the first RED.
81
+
82
+ If `phase_plan.codify: skipped` for this work item (typical for trivial bugfixes that bypass harden), no oracles are expected — note the skip in the work-item notes and proceed.
83
+
70
84
  ## Codex Integration
71
85
 
72
86
  **Mode:** Delegate | **Protocol:** `protocols/codex.md`
@@ -15,7 +15,7 @@ A concept deck is the cheapest artifact in the pipeline. It exists to verify the
15
15
 
16
16
  ## When to Use
17
17
 
18
- - Phase 2 of a prototype-driven flow (after discovery, before wireframing)
18
+ - Phase 1 of a prototype-driven flow (after discovery, before wireframing)
19
19
  - For `/feature` on existing apps: a 1-3 slide mini-deck — what the feature is, where it sits, the visual sketch. Often a single slide.
20
20
  - Ad-hoc when a user wants to put a concept on paper before building anything
21
21
 
@@ -46,8 +46,8 @@ The deck is rendered with `marp` and previewed in HTML so the user can click thr
46
46
 
47
47
  ## What concept-slides does NOT produce
48
48
 
49
- - A wireframe (Phase 3 deliverable; uses `build-wireframe` skill)
50
- - A prototype (Phase 4 deliverable; uses `build-prototype` skill)
49
+ - A wireframe (Phase 2 deliverable; uses `build-wireframe` skill)
50
+ - A prototype (Phase 3 deliverable; uses `build-prototype` skill)
51
51
  - An architecture doc (Phase 5 deliverable; uses `harden`)
52
52
  - A finalized pitch deck (use `marp-slides` directly for finalized presentations)
53
53
 
@@ -58,7 +58,7 @@ If the user asks for "a real deck for the leadership pitch," use `marp-slides` w
58
58
  | Source | Required | Purpose |
59
59
  |---|---|---|
60
60
  | Rough concept brief from the user | yes | One-sentence to one-paragraph description of what's being built |
61
- | Discovery output (if existing repo) | if Phase 1 ran | Codebase conventions, existing UX patterns to align with |
61
+ | Discovery output (if existing repo) | if discovery ran | Codebase conventions, existing UX patterns to align with |
62
62
  | Reference decks the user likes | optional | Style/composition reference (links or paths) |
63
63
 
64
64
  ## Process
@@ -119,13 +119,13 @@ Re-dispatch the subagent with the feedback as part of the prompt; rewrite the de
119
119
 
120
120
  ### Step 5: lock
121
121
 
122
- When the user emits "concept locked" (or equivalent), the phase closes. The locked deck is the input to Phase 3 (`build-wireframe`).
122
+ When the user emits "concept locked" (or equivalent), the phase closes. The locked deck is the input to Phase 2 (`build-wireframe`).
123
123
 
124
124
  Update the manifest at `.forge/work/{type}/{name}/manifest.yaml`:
125
125
  - `artifacts.concept.deck_path: decks/{name}/slides.md`
126
126
  - `artifacts.concept.locked_at: <ISO-8601 timestamp>`
127
127
 
128
- Presence of `artifacts.concept.locked_at` is the lock signal that Phase 3 (`build-wireframe`) reads to confirm the concept is locked before proceeding.
128
+ Presence of `artifacts.concept.locked_at` is the lock signal that Phase 2 (`build-wireframe`) reads to confirm the concept is locked before proceeding.
129
129
 
130
130
  ## Visual sketch guidance
131
131
 
@@ -146,7 +146,7 @@ Avoid:
146
146
  | Mistake | Fix |
147
147
  |---|---|
148
148
  | Treating the deck as a finalized pitch | It's a draft; lower the polish bar to "sketch-grade" |
149
- | Embedding real UI mockups | Move that to Phase 3 wireframe; sketches in the deck are boxes-and-arrows |
149
+ | Embedding real UI mockups | Move that to Phase 2 wireframe; sketches in the deck are boxes-and-arrows |
150
150
  | Producing a 30-slide deck | Cap at 15 for full products, 3 for features. Cut or split. |
151
151
  | Skipping the "out of scope" slide | The deferral list IS the spec — what NOT to build is as important as what to build |
152
152
  | Iterating with the user before the first render | Render first, get feedback against something concrete; don't iterate against imagined slides |
@@ -158,7 +158,7 @@ Avoid:
158
158
  - Build a polished marketing deck under this skill (different intent — use `marp-slides` directly)
159
159
  - Skip the "out of scope" slide — defining what's NOT built is half the value
160
160
  - Iterate without rendering — text-only edits invite imaginary feedback
161
- - Carry a draft to Phase 3 without an explicit user lock
161
+ - Carry a draft to Phase 2 without an explicit user lock
162
162
 
163
163
  **Always:**
164
164
  - Render to HTML and let the user click through — that's the iteration surface
@@ -172,13 +172,13 @@ Avoid:
172
172
  | **Requires** | User brief, target output path, optional discovery output |
173
173
  | **Produces** | `decks/{name}/slides.md` (marp source) + `decks/{name}/slides.html` (rendered preview) |
174
174
  | **Updates manifest** | `artifacts.concept.{deck_path, locked_at}` |
175
- | **Feeds into** | `build-wireframe` (Phase 3 — wireframe extends the visual sketches into clickable HTML) |
175
+ | **Feeds into** | `build-wireframe` (Phase 2 — wireframe extends the visual sketches into clickable HTML) |
176
176
 
177
177
  ## Integration
178
178
 
179
179
  | Caller | When |
180
180
  |---|---|
181
- | Phase 2 of `/feature` and `/greenfield` | Default flow entry point for prototype-driven work |
181
+ | Phase 1 of `/feature` and `/greenfield` | Default flow entry point for prototype-driven work |
182
182
  | Manual invocation | When a concept needs sketching outside a workflow |
183
183
 
184
184
  | Dispatches | For |
@@ -188,5 +188,5 @@ Avoid:
188
188
  | Pairs with | For |
189
189
  |---|---|
190
190
  | `marp-slides` (user-level skill) | Underlying rendering engine — concept-slides specializes the format |
191
- | `build-wireframe` | Phase 3 successor — wireframer reads the locked deck as input |
191
+ | `build-wireframe` | Phase 2 successor — wireframer reads the locked deck as input |
192
192
  | `discover-codebase-analysis` | If existing repo, supplies UX/convention context |
@@ -298,7 +298,16 @@ VERDICT: Ready to deploy
298
298
  3. **Trigger Post-Deploy Skills**
299
299
  - If documentation needs updating, flag for `deliver-onboarding`
300
300
  - If any issues were encountered during deploy, invoke `support-gotcha`
301
- - If deployment revealed process improvements, note for `/evolve`
301
+ - If deployment revealed process improvements, note for `/forge-evolve`
302
+
303
+ 4. **Retrospective dream (Phase 7 auto-fire on lock).** After writing `artifacts.deliver.locked_at`, invoke the **support-dream** skill to consolidate the full feature's wiki accumulation. This is the last consolidation pass for the feature — gotchas, conventions, and any deploy-time learnings get merged into the durable wiki state before the manifest closes.
304
+ - **scope:** `aiwiki/raw/`, `aiwiki/gotchas/`, `aiwiki/conventions/`, `aiwiki/sessions/` (any subfolder touched during this feature's lifetime)
305
+ - **trigger:** `phase-close`
306
+ - **trigger_detail:** `"Phase 7 (deliver) retrospective — {feature/name}"`
307
+
308
+ Surface the dream id + review path to the user. The feature manifest's `status: completed` transition should wait until the retrospective dream is reviewed — this is the consolidation pass the next feature's `discover-codebase-analysis` will read from.
309
+
310
+ **Skip when:** no `aiwiki/` writes occurred during this feature (rare — most non-trivial features produce at least one gotcha or convention).
302
311
 
303
312
  ## Rollback Procedures
304
313
 
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: harden
3
- description: "Use after a working prototype is locked and the user says 'codify', 'harden', 'ready to productionize', 'extract decisions', 'time to build for real', or runs /feature past the prototype phase. Extracts architecture, ADRs, design system, slice graph, and convention/gotcha promotions FROM the working prototype — does not invent them. Skip if prototype is still iterating or has been abandoned — re-iterate or restart instead."
3
+ description: "Use after a working prototype is locked and the user says 'codify', 'harden', 'ready to productionize', 'extract decisions', 'time to build for real', or runs /feature past the prototype phase. Extracts architecture, ADRs, design system, slice graph, and convention/gotcha promotions FROM the working prototype — does not invent them. Skip if prototype is still iterating — re-iterate or restart instead."
4
4
  ---
5
5
 
6
6
  # Harden
@@ -48,7 +48,7 @@ The expected total is short: ~200-400 lines across all architecture files combin
48
48
  - Does NOT run gates (LINT runs on the wiki output; reachability runs on production code later)
49
49
  - Does NOT modify the prototype (it's the source of truth — leave it alone)
50
50
  - Does NOT pre-promote raw entries from `aiwiki/raw/` to typed pages (dream's job at phase close)
51
- - Does NOT skip the adversarial-review step on ADRs — every production ADR is reviewed inline at Step 2 (the dedicated `/second-opinion` slash command + `support-second-opinion` skill are *planned, not yet implemented*; until they ship, harden inlines the review pass and records reviewer, objections, resolutions, verdict in the ADR `review:` block before promoting to `accepted`)
51
+ - Does NOT skip the adversarial-review step on ADRs — every production ADR is reviewed inline at Step 2: harden runs the review pass and records reviewer, objections, resolutions, and verdict in the ADR `review:` block before promoting to `accepted`. If Codex is configured (`protocols/codex.md`), the review pass may dispatch Codex in verify mode; otherwise Claude performs the pass directly.
52
52
 
53
53
  ## Inputs
54
54
 
@@ -102,7 +102,7 @@ The subagent does NOT write the files itself — it returns the proposals. The m
102
102
 
103
103
  Each proposed ADR represents a decision that's hard to reverse — by definition, ADR-worthy. The `prototype-codifier` agent only proposes ADRs that match the adversarial-review trigger list (the canonical list lives in `agents/prototype-codifier.md` Phase 4); every proposal therefore arrives flagged for review.
104
104
 
105
- For each proposed ADR, run an adversarial review pass and write a structured `review:` block (reviewers, objections, resolutions, verdict) into the draft. The dedicated `/second-opinion` slash command + `support-second-opinion` skill that would package this work are *planned, not yet implemented* — until they ship, perform the review inline within harden (interrogate the decision against the trigger list's failure modes, surface objections explicitly, and either record resolutions or escalate to the user).
105
+ For each proposed ADR, run an adversarial review pass and write a structured `review:` block (reviewers, objections, resolutions, verdict) into the draft. The review is performed inline within harden: interrogate the decision against the trigger list's failure modes, surface objections explicitly, and either record resolutions or escalate to the user. If Codex is configured (`protocols/codex.md`), dispatch it in verify mode to perform the review pass and merge its findings; otherwise Claude runs the pass directly.
106
106
 
107
107
  Only ADRs with `verdict: approved` get written as `status: accepted`. ADRs with `verdict: escalate` are surfaced to the user for resolution before the phase closes. ADRs with `verdict: reject` are dropped from the proposal set.
108
108
 
@@ -135,9 +135,23 @@ Each write triggers wiki-lint synchronously; lint failures must be resolved befo
135
135
 
136
136
  ### Step 4: trigger a focused dream
137
137
 
138
- After the writes land, fire a phase-close dream over the touched subfolders. The dream is the consolidation pass that may merge new ADRs with existing ones, promote raw entries that became relevant during codification, and prune stale entries the new architecture supersedes.
138
+ After the Step 3 writes land, fire a phase-close dream. Invoke the `support-dream` skill with:
139
139
 
140
- Dream output goes to `aiwiki/proposed/{dream_id}/` for user review. The phase does NOT close until the user accepts or rejects the dream output.
140
+ - **scope:** the subfolders Step 3 touched typically `aiwiki/architecture/`, `aiwiki/decisions/`, `aiwiki/conventions/`, `aiwiki/gotchas/`, `aiwiki/oracles/`, `aiwiki/sessions/`
141
+ - **trigger:** `phase-close`
142
+ - **trigger_detail:** `"Phase 5 (codify) — {feature/name}"`
143
+
144
+ The dream is the consolidation pass: it may merge new ADRs with existing ones, promote raw entries that became relevant during codification, and prune stale entries the new architecture supersedes.
145
+
146
+ Dream output goes to `aiwiki/proposed/{dream_id}/` for user review. Surface the dream id and review path:
147
+
148
+ ```
149
+ Phase 5 writes complete. Dream queued: 2026-05-18-HHMM-codify-{name}
150
+ Review: `forge wiki review {dream_id}` or open `forge wiki ui`
151
+ The codify gate (Step 5) does not pass until this dream is reviewed.
152
+ ```
153
+
154
+ The phase does NOT close until the user accepts or rejects the dream output.
141
155
 
142
156
  ### Step 5: gate
143
157
 
@@ -153,7 +167,7 @@ The user reviews ALL outputs as a unit, not piecemeal. The codified plan is shor
153
167
 
154
168
  ## Adversarial review integration
155
169
 
156
- Every production-only decision is an ADR-worthy decision; the prototype-codifier subagent flags them all. Adversarial review runs on each proposed ADR before it's written as `accepted`. This is non-optional — production code that ships against an ADR with no recorded review is silent debt. The dedicated `/second-opinion` skill that will eventually own this work is *planned, not yet implemented* (see docs/V6-PLAN.md §11); today the review pass runs inline within harden Step 2 and writes the verdict directly into the ADR.
170
+ Every production-only decision is an ADR-worthy decision; the prototype-codifier subagent flags them all. Adversarial review runs on each proposed ADR before it's written as `accepted`. This is non-optional — production code that ships against an ADR with no recorded review is silent debt. The review pass runs inline within harden Step 2 and writes the verdict directly into the ADR. When Codex is configured (`protocols/codex.md`), the pass may be dispatched to Codex in verify mode; otherwise Claude performs it directly.
157
171
 
158
172
  Decisions that don't make the trigger list (variable naming, inline-vs-extract, choosing between known-good libraries with no real tradeoff) don't need ADRs at all and are NOT proposed by the subagent.
159
173
 
@@ -164,7 +178,7 @@ Decisions that don't make the trigger list (variable naming, inline-vs-extract,
164
178
  | Generating architecture from imagination instead of citing the prototype | Every claim about a component cites `prototype-dir/path/to/file.ts:line@<sha7>` — if you can't cite, the claim is premature |
165
179
  | One giant `aiwiki/architecture.md` file | Split by subsystem: `data-layer.md`, `auth-flow.md`, `event-bus.md`. Each <400 lines. |
166
180
  | Writing ADRs for non-trigger-list decisions | Variable naming and inline-vs-extract are NOT ADRs. Use the trigger list strictly. |
167
- | Skipping adversarial review because "the decision is obvious" | If the decision is obvious it doesn't need an ADR; if it needs an ADR it needs review (today inline; `/second-opinion` dedicated surface planned) |
181
+ | Skipping adversarial review because "the decision is obvious" | If the decision is obvious it doesn't need an ADR; if it needs an ADR it needs review (performed inline at Step 2, optionally via Codex verify mode) |
168
182
  | Pre-promoting raw entries during codification | Raw entries are dream's territory; harden writes to typed pages directly, raw stays raw until dream consolidates |
169
183
  | Modifying the prototype during codification | The prototype is the source of truth — leave it alone. Annotation goes in the architecture file, not in prototype source |
170
184
  | Treating the gate as advisory | Phase 6 reads these outputs; if codification is incomplete, the production build is improvising. Block until the user accepts. |
@@ -203,7 +217,7 @@ Decisions that don't make the trigger list (variable naming, inline-vs-extract,
203
217
  | Dispatches | For |
204
218
  |---|---|
205
219
  | `prototype-codifier` subagent | Bulk codification work in own context window |
206
- | `support-second-opinion` (`/second-opinion`) *(planned, not yet implemented)* | Adversarial review on each proposed ADR — until shipped, harden inlines this pass at Step 2 |
220
+ | Codex (verify mode, via `protocols/codex.md`) | Optional adversarial review on each proposed ADR — if Codex is not configured, harden runs the review pass inline at Step 2 |
207
221
  | `support-dream` | Focused dream over touched subfolders after writes |
208
222
  | `support-wiki-lint` | Synchronous validation on every wiki write |
209
223
 
@@ -181,6 +181,28 @@ Two convergence signals:
181
181
 
182
182
  In autopilot mode, the loop hook reads the LOCKED signal from the manifest and exits cleanly.
183
183
 
184
+ ### Step 9: phase-close dream (auto-fire on lock)
185
+
186
+ **Trigger:** Step 8 just wrote `artifacts.prototype.locked_at`. The prototype phase is closing, and Phase 4's accumulated `aiwiki/` writes (gotchas, conventions, raw notes from `/note`) should be consolidated before the next phase (codify) reads from it.
187
+
188
+ **Action:** invoke the `support-dream` skill with:
189
+
190
+ - **scope:** `aiwiki/raw/`, `aiwiki/gotchas/`, `aiwiki/conventions/` (the subfolders Phase 4 wrote to)
191
+ - **trigger:** `phase-close`
192
+ - **trigger_detail:** `"Phase 4 (iterate) lock — {feature/name}"`
193
+
194
+ `support-dream` dispatches the `dreamer` subagent and writes a consolidation proposal to `aiwiki/proposed/{dream_id}/`. Surface the dream id and review path to the user:
195
+
196
+ ```
197
+ Phase 4 closed. Dream queued: 2026-05-18-HHMM-iterate-{name}
198
+ Review: `forge wiki review {dream_id}` or open `forge wiki ui`
199
+ The codify (Phase 5) gate blocks until this dream is reviewed.
200
+ ```
201
+
202
+ **Gate coupling:** the codify gate (`harden` Step 0 readiness check) must verify any phase-4 dream is reviewed before proceeding. The next phase reads consolidated wiki state, so it cannot proceed against pending unreviewed proposals.
203
+
204
+ **Skip when:** no aiwiki writes occurred during Phase 4 (gotchas/conventions/raw all unchanged since prototype scaffold). No-op dreams add noise.
205
+
184
206
  ## Anti-fatigue
185
207
 
186
208
  If pending feedback grows past 10 items without any being resolved, the loop is not iterating — it's accumulating. Surface this to the user explicitly: "Pending list has grown to N items without resolution; consider whether the wireframe needs an update before continuing prototype iteration." This is the prototype-equivalent of the wiki accept-fatigue safeguard.