cfsa-antigravity 2.13.3 → 2.14.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 (30) hide show
  1. package/package.json +1 -1
  2. package/template/.agent/kit-sync.md +3 -3
  3. package/template/.agent/skills/prd-templates/references/be-spec-template.md +6 -0
  4. package/template/.agent/skills/prd-templates/references/deep-ideation-loading-protocol.md +114 -0
  5. package/template/.agent/skills/prd-templates/references/fe-spec-template.md +6 -0
  6. package/template/.agent/skills/prd-templates/references/feature-ledger-protocol.md +149 -0
  7. package/template/.agent/skills/prd-templates/references/shard-boundary-analysis.md +27 -0
  8. package/template/.agent/workflows/create-prd-architecture.md +12 -0
  9. package/template/.agent/workflows/create-prd-compile.md +4 -1
  10. package/template/.agent/workflows/create-prd-design-system.md +10 -0
  11. package/template/.agent/workflows/create-prd-security.md +10 -0
  12. package/template/.agent/workflows/create-prd-stack.md +10 -0
  13. package/template/.agent/workflows/create-prd.md +23 -0
  14. package/template/.agent/workflows/decompose-architecture-structure.md +17 -0
  15. package/template/.agent/workflows/decompose-architecture-validate.md +18 -0
  16. package/template/.agent/workflows/ideate-discover.md +20 -0
  17. package/template/.agent/workflows/ideate-validate.md +10 -0
  18. package/template/.agent/workflows/implement-slice-setup.md +10 -0
  19. package/template/.agent/workflows/plan-phase-preflight.md +10 -0
  20. package/template/.agent/workflows/plan-phase-write.md +15 -0
  21. package/template/.agent/workflows/setup-workspace-scaffold.md +21 -0
  22. package/template/.agent/workflows/setup-workspace.md +15 -2
  23. package/template/.agent/workflows/validate-phase-readiness.md +33 -0
  24. package/template/.agent/workflows/verify-infrastructure.md +22 -0
  25. package/template/.agent/workflows/write-architecture-spec-deepen.md +33 -0
  26. package/template/.agent/workflows/write-architecture-spec-design.md +9 -3
  27. package/template/.agent/workflows/write-be-spec-classify.md +16 -0
  28. package/template/.agent/workflows/write-be-spec-write.md +30 -0
  29. package/template/.agent/workflows/write-fe-spec-classify.md +10 -0
  30. package/template/.agent/workflows/write-fe-spec-write.md +30 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfsa-antigravity",
3
- "version": "2.13.3",
3
+ "version": "2.14.0",
4
4
  "description": "CFSA Pipeline — Constraint-First Specification Architecture for AI agents. Production-grade from line one.",
5
5
  "scripts": {
6
6
  "changeset": "changeset",
@@ -1,6 +1,6 @@
1
1
  # Kit Sync State
2
2
 
3
3
  upstream: https://github.com/RepairYourTech/cfsa-antigravity
4
- last_synced_commit: 474ea4346ac09791e0f6bc7a5ed771de79ee93f2
5
- last_synced_at: 2026-03-20T14:04:21Z
6
- kit_version: 2.13.3
4
+ last_synced_commit: 89e129286cdbd5e33d6617d81cde4450f2dac77e
5
+ last_synced_at: 2026-03-20T17:29:41Z
6
+ kit_version: 2.14.0
@@ -9,6 +9,12 @@ Use this template when writing BE specs to `docs/plans/be/[NN-feature-name].md`.
9
9
  > **Deep Dives**: [links to consumed deep dives, if any]
10
10
  > **Status**: Draft | Review | Complete
11
11
 
12
+ ## Split Group _(include only if this spec resulted from a split)_
13
+
14
+ > **Split origin**: [IA shard that was split, e.g., `09-messaging`]
15
+ > **Companion specs**: [sibling BE spec files, e.g., `09b-agent-flow-api.md`]
16
+ > **Shared entities**: [data models shared across companions, e.g., `Message`, `Thread`]
17
+
12
18
  ## IA Source Map
13
19
 
14
20
  [Which IA shard sections, deep dives, and cross-shard references
@@ -0,0 +1,114 @@
1
+ # Deep Ideation Loading Protocol
2
+
3
+ > **Purpose**: When ideation output is large (many domains, many features), the single `ideation-index.md` summary is insufficient for downstream architecture decisions. This protocol reads domain-level index files to build a structured **Domain Digest Table** that captures every feature, role assignment, and decision without requiring the agent to hold hundreds of leaf-level files in context.
4
+
5
+ ## When to Invoke
6
+
7
+ **Always invoke** this protocol when ANY of these thresholds are met (read from the `## Progress Summary` table in `ideation-index.md`):
8
+
9
+ | Metric | Threshold |
10
+ |--------|-----------|
11
+ | Total domains | ≥ 6 |
12
+ | Total leaf features | ≥ 50 |
13
+ | Total surfaces | ≥ 2 (multi-product projects) |
14
+
15
+ If none of these thresholds are met, the standard `ideation-index.md` read is sufficient — skip this protocol.
16
+
17
+ ## Procedure
18
+
19
+ ### Step 1 — Enumerate domain folders
20
+
21
+ Read the `## Structure Map` in `ideation-index.md`. For each row in the domain tables, record:
22
+ - Domain number and name
23
+ - Path to the domain folder
24
+ - Status (`[SURFACE]`, `[BREADTH]`, `[DEEP]`, `[EXHAUSTED]`)
25
+ - Child count (from the "Children" column)
26
+ - Surface (for multi-product projects)
27
+
28
+ This produces a **domain enumeration list** — typically 6-20 entries.
29
+
30
+ ### Step 2 — Read each domain index
31
+
32
+ For each domain in the enumeration list, read `{domain-folder}/{domain}-index.md`. Extract:
33
+
34
+ 1. **Children table** — every sub-domain and feature with: number, name, type, status, depth
35
+ 2. **Role Matrix** — which personas have access to which children, and at what level (Full / Config / Read-only / Reports / None)
36
+ 3. **Decision Log** — any product decisions made during ideation for this domain
37
+ 4. **Open Questions** — deferred questions tagged for downstream stages
38
+
39
+ > **Context management**: Read domain indexes one at a time. Extract the structured data, then move to the next. Do not attempt to hold all domain indexes simultaneously.
40
+
41
+ ### Step 3 — Read CX files for cross-domain dependencies
42
+
43
+ Read `ideation-cx.md` (global cross-cuts) and each domain-level `{domain}-cx.md`. Extract:
44
+ - Cross-domain data dependencies (which entities are shared)
45
+ - Trigger chains (domain A event → domain B action)
46
+ - Shared entity ownership
47
+
48
+ ### Step 4 — Build the Domain Digest Table
49
+
50
+ Compile the extracted data into a structured table:
51
+
52
+ ```markdown
53
+ ## Ideation Digest
54
+
55
+ > Auto-generated by the Deep Ideation Loading Protocol. Source: domain-level index files.
56
+ > This section is the primary source for entity identification, data strategy, and phasing decisions.
57
+
58
+ ### Domain Summary
59
+
60
+ | # | Domain | Surface | Features | Sub-domains | Depth | Must Have | Roles | Key Entities |
61
+ |---|--------|---------|----------|-------------|-------|----------|-------|-------------|
62
+ | 01 | {name} | {surface} | {N} | {N} | {status} | {N} | {list} | {entity hints} |
63
+
64
+ ### Cross-Domain Dependencies
65
+
66
+ | Source Domain | Target Domain | Type | Shared Entities |
67
+ |--------------|--------------|------|----------------|
68
+ | {source} | {target} | data / trigger / permission | {entities} |
69
+
70
+ ### Ideation Decisions (from domain logs)
71
+
72
+ | # | Domain | Decision | Impact |
73
+ |---|--------|----------|--------|
74
+ | D-{NN} | {domain} | {decision} | {what this affects downstream} |
75
+
76
+ ### Deferred Questions (tagged for /create-prd)
77
+
78
+ | # | Domain | Question | Owner |
79
+ |---|--------|----------|-------|
80
+ | Q-{NN} | {domain} | {question} | /create-prd |
81
+ ```
82
+
83
+ ### Step 5 — Derive Key Entities column
84
+
85
+ For each domain, scan the Children table for entity hints:
86
+ - Feature names that imply data objects (e.g., "Device History" → `Device`, `RepairRecord`)
87
+ - Role Matrix intersections that imply access-controlled resources
88
+ - Cross-cut shared entities from CX files
89
+
90
+ List the implied entities in the "Key Entities" column. These are **hints**, not schema — they inform data strategy without prescribing it.
91
+
92
+ ### Step 6 — Write to architecture-draft.md
93
+
94
+ Write the completed Domain Digest Table to `docs/plans/architecture-draft.md` as the first section (`## Ideation Digest`). If the file doesn't exist yet, create it with this section.
95
+
96
+ > **Write immediately.** Do not hold the digest in memory — write it to disk as soon as it's compiled. All subsequent create-prd shards read from `architecture-draft.md`.
97
+
98
+ ## Downstream Consumption
99
+
100
+ | Consumer | What It Uses |
101
+ |----------|-------------|
102
+ | `create-prd-architecture` (Step 5: Data strategy) | Key Entities column → entity identification; Cross-Domain Dependencies → data ownership and sync |
103
+ | `create-prd-compile` (Step 9: Phasing) | Features + Must Have counts → phase complexity sizing; Sub-domain counts → dependency ordering |
104
+ | `create-prd-security` | Roles column → access control scope; Cross-Domain Dependencies → trust boundaries |
105
+
106
+ ## Anti-Patterns
107
+
108
+ | ❌ Wrong | ✅ Right |
109
+ |---------|---------|
110
+ | Reading all 295 leaf-level feature files | Reading 8-20 domain index files |
111
+ | Skipping this protocol because "ideation-index.md has a summary" | Invoking when thresholds are met — summaries lose detail |
112
+ | Deriving entities from the MoSCoW bullet list | Deriving entities from the Children tables + CX dependencies |
113
+ | Holding all domain indexes in context simultaneously | Reading one at a time, extracting structured data, moving on |
114
+ | Writing the digest at the end of create-prd | Writing it to architecture-draft.md immediately in Step 1.5 |
@@ -9,6 +9,12 @@ Use this template when writing FE specs to `docs/plans/fe/[NN-feature-name].md`.
9
9
  > **IA Source**: [link to IA shard, or N/A for cross-cutting]
10
10
  > **Status**: Draft | Review | Complete
11
11
 
12
+ ## Split Group _(include only if this spec resulted from a split)_
13
+
14
+ > **Split origin**: [IA shard that was split, e.g., `09-messaging`]
15
+ > **Companion specs**: [sibling FE spec files, e.g., `09b-agent-flow-ui.md`]
16
+ > **Shared entities**: [data models shared across companions, e.g., `Message`, `Thread`]
17
+
12
18
  ## Source Map
13
19
 
14
20
  | FE Spec Section | Source | Section/Lines |
@@ -0,0 +1,149 @@
1
+ # Feature Tracking Ledger Protocol
2
+
3
+ > **Purpose**: Track every ideation feature through the entire pipeline — from birth in ideation to final slice assignment. Catches dropped features that per-stage reconciliation tables miss.
4
+
5
+ ## Ledger Location
6
+
7
+ `docs/plans/feature-ledger.md`
8
+
9
+ ## Ledger Format
10
+
11
+ ```markdown
12
+ # Feature Tracking Ledger
13
+
14
+ > Auto-generated by `/ideate-validate`. Updated by each pipeline stage.
15
+ > Each column is populated by the stage that owns it (see Column Ownership below).
16
+
17
+ | Feature ID | Feature Name | Domain | MoSCoW | IA Shard | IA Status | BE Spec | BE Status | FE Spec | FE Status | Phase | Slice |
18
+ |-----------|-------------|--------|--------|----------|-----------|---------|-----------|---------|-----------|-------|-------|
19
+ ```
20
+
21
+ ## Column Ownership
22
+
23
+ | Column(s) | Populated By | Stage |
24
+ |-----------|-------------|-------|
25
+ | Feature ID, Feature Name, Domain, MoSCoW | `/ideate-validate` Step 11.5 | Discovery |
26
+ | IA Shard, IA Status | `/decompose-architecture-validate` | Design |
27
+ | BE Spec, BE Status | `/write-be-spec-write` | Specification |
28
+ | FE Spec, FE Status | `/write-fe-spec-write` | Specification |
29
+ | Phase, Slice | `/plan-phase-write` Step 2.5 | Planning |
30
+
31
+ ## Status Values
32
+
33
+ | Status | Meaning |
34
+ |--------|---------|
35
+ | ✅ | Covered — spec exists and includes this feature |
36
+ | ⚠️ deferred | Explicitly deferred with documented reason |
37
+ | ❌ missing | Not covered — no spec addresses this feature |
38
+ | — | Column not yet populated (upstream stage hasn't run) |
39
+
40
+ ## Step 1 — Ledger Creation (`/ideate-validate`)
41
+
42
+ **When**: After Step 11 (compile vision), before Step 12 (request review).
43
+
44
+ **Procedure**:
45
+
46
+ 1. Read `ideation-index.md` → Structure Map → get all domain paths
47
+ 2. For each domain, read `{domain}-index.md` → Children table
48
+ 3. For each leaf-level child (type = `feature`), create one ledger row:
49
+ - **Feature ID**: `{domain-name}/{feature-file-basename}` (e.g., `inventory/01-categories`)
50
+ - **Feature Name**: from the Children table Name column
51
+ - **Domain**: domain name
52
+ - **MoSCoW**: from `ideation-index.md` MoSCoW Summary (match by feature name), or from the feature's own priority field if available
53
+ 4. All other columns → `—` (not yet populated)
54
+ 5. Write to `docs/plans/feature-ledger.md`
55
+
56
+ > **Context management**: Read domain indexes one at a time, extract features, move on. Same pattern as the deep-ideation-loading protocol.
57
+
58
+ ## Step 2 — IA Assignment (`/decompose-architecture-validate`)
59
+
60
+ **When**: After shard boundaries are approved and shard skeletons exist.
61
+
62
+ **Procedure**:
63
+
64
+ 1. Read `docs/plans/feature-ledger.md`
65
+ 2. For each IA shard skeleton in `docs/plans/ia/`:
66
+ - Read the shard's `## Sub-features` or features list
67
+ - For each feature, find the matching row in the ledger (match by Feature ID or Feature Name)
68
+ - Set **IA Shard** = shard name (e.g., `02-inventory`)
69
+ - Set **IA Status** = `✅`
70
+ 3. **Orphan check**: Any row where IA Shard is still `—` after processing all shards → set IA Status = `❌ missing`
71
+ 4. Write updated ledger
72
+
73
+ **If orphans are found**:
74
+ > ⚠️ **Feature ledger orphan check**: [N] features from ideation have no IA shard assignment:
75
+ > - `{Feature ID}`: {Feature Name}
76
+ >
77
+ > Options:
78
+ > 1. Add to an existing shard
79
+ > 2. Create a new shard
80
+ > 3. Mark as explicitly deferred (with reason)
81
+
82
+ **STOP** — wait for user decision on each orphan.
83
+
84
+ ## Step 3 — BE Coverage (`/write-be-spec-write`)
85
+
86
+ **When**: After each BE spec is written.
87
+
88
+ **Procedure**:
89
+
90
+ 1. Read `docs/plans/feature-ledger.md`
91
+ 2. Read the newly written BE spec's endpoint list
92
+ 3. For each endpoint, identify which Feature ID(s) it serves (from the IA shard → feature mapping)
93
+ 4. For each matched Feature ID, set **BE Spec** = spec file name, **BE Status** = `✅`
94
+ 5. Write updated ledger
95
+
96
+ > **Note**: Not all features produce BE endpoints (e.g., purely client-side UI features). These should have BE Status = `⚠️ deferred` with reason "client-only".
97
+
98
+ ## Step 4 — FE Coverage (`/write-fe-spec-write`)
99
+
100
+ **When**: After each FE spec is written.
101
+
102
+ **Procedure**:
103
+
104
+ 1. Read `docs/plans/feature-ledger.md`
105
+ 2. Read the newly written FE spec's component list
106
+ 3. For each component, identify which Feature ID(s) it serves
107
+ 4. For each matched Feature ID, set **FE Spec** = spec file name, **FE Status** = `✅`
108
+ 5. Write updated ledger
109
+
110
+ ## Step 5 — Slice Assignment (`/plan-phase-write`)
111
+
112
+ **When**: After Step 2.5 (spec coverage verification).
113
+
114
+ **Procedure**:
115
+
116
+ 1. Read `docs/plans/feature-ledger.md`
117
+ 2. For each slice, identify which Feature ID(s) it covers (from its spec source map)
118
+ 3. For each matched Feature ID, set **Phase** = phase number, **Slice** = slice ID
119
+ 4. Write updated ledger
120
+
121
+ ## Verification Gate (`/plan-phase-preflight`)
122
+
123
+ **When**: During the cross-layer consistency check.
124
+
125
+ **Procedure**:
126
+
127
+ 1. Read `docs/plans/feature-ledger.md`
128
+ 2. Count features by completeness:
129
+ - **✅ Complete**: All columns through FE Status are ✅ or ⚠️ deferred
130
+ - **⚠️ Partial**: Some columns filled, some still `—`
131
+ - **❌ Orphaned**: IA Status or BE Status or FE Status = `❌ missing`
132
+ 3. Report:
133
+
134
+ > **Feature Ledger Verification**:
135
+ > - ✅ Complete: [N] features
136
+ > - ⚠️ Partial: [N] features (columns not yet populated by upstream stages)
137
+ > - ❌ Orphaned: [N] features (dropped between stages)
138
+
139
+ 4. **If any ❌ orphans** → **BLOCKING GATE**: "Feature ledger shows [N] orphaned features. Resolve before planning."
140
+ 5. **If any ⚠️ partial** → **WARNING**: "Feature ledger shows [N] features with incomplete coverage. These may be from stages not yet run."
141
+
142
+ ## Anti-Patterns
143
+
144
+ | ❌ Wrong | ✅ Right |
145
+ |---------|---------|
146
+ | Skipping ledger updates "because it's just bookkeeping" | Every stage updates its columns — it's the only global tracking |
147
+ | Marking orphaned features as ⚠️ deferred without a reason | Orphans are ❌ missing until explicitly deferred with documented reasoning |
148
+ | Regenerating the ledger from scratch at each stage | Updating existing rows — the ledger is cumulative |
149
+ | Ignoring the orphan check at plan-phase-preflight | Blocking on orphans — they represent dropped features |
@@ -74,3 +74,30 @@ Split rationale: [why these groups are independent]
74
74
  ```
75
75
 
76
76
  **After any split**: Update `docs/plans/ia/decomposition-plan.md` with the revised table and re-run the Must Have coverage gate.
77
+
78
+ **Companion spec tracking**: When writing BE or FE specs for split shards, populate the `## Split Group` section in each spec file (see `be-spec-template.md` / `fe-spec-template.md`). This enables downstream discovery of sibling specs during implementation.
79
+
80
+ ## Total Shard Count Guidance
81
+
82
+ The decomposition should produce a shard count proportional to the ideation depth. Too few shards compress complex domains and lose detail. Too many create coordination overhead that exceeds agent context capacity.
83
+
84
+ ### Expected Range by Ideation Scale
85
+
86
+ | Ideation Scale | Domains | Expected Shards (incl. `00-infrastructure`) | Notes |
87
+ |----------------|---------|---------------------------------------------|-------|
88
+ | **Small** | 3–5 | 4–8 | Most domains map 1:1 to shards |
89
+ | **Medium** | 6–8 | 7–14 | Some multi-domain splits expected |
90
+ | **Large** | 9–12 | 12–20 | Cross-cutting shards multiply; enforce sub-feature limits aggressively |
91
+ | **Deep** | 13+ | 16–25 | Maximum recommended. Beyond 25 → consider surface-level decomposition or domain grouping |
92
+
93
+ ### Total Count Thresholds (Post-Skeleton Check)
94
+
95
+ After all shard skeletons are created in Step 5, count the total:
96
+
97
+ | Total Shards | Action |
98
+ |--------------|--------|
99
+ | **≤ 20** | ✅ Proceed |
100
+ | **21–25** | ⚠️ Warning — "Decomposition produced [N] shards. This will require [N × 3] spec documents (IA + BE + FE) and proportional phase planning. Confirm this is the intended scope or consider grouping related domains." |
101
+ | **> 25** | 🛑 **Hard stop** — "Decomposition produced [N] shards. This exceeds the recommended maximum for sequential agent processing. Present a domain grouping proposal that reduces shard count to ≤ 25." |
102
+
103
+ > **Why 25 max**: Each shard produces ~3 spec documents (IA + BE + FE). At 25 shards, that's 75 spec documents. Beyond this, cross-layer consistency checks become unreliable and phase planning produces impractical slice counts.
@@ -88,6 +88,8 @@ Write the completed decisions to `docs/plans/architecture-draft.md` under a new
88
88
 
89
89
  Read .agent/skills/database-schema-design/SKILL.md and follow its schema design methodology.
90
90
 
91
+ **Digest-aware entity identification**: If `## Ideation Digest` exists in `docs/plans/architecture-draft.md`, use its Key Entities column and Cross-Domain Dependencies table as the primary source for entity identification in sub-steps below. Cross-reference the digest's per-domain feature lists to ensure no entity is missed. If the digest does not exist, derive entities from the architecture sections written above.
92
+
91
93
  Load the Databases skill(s) from the `shared` surface row per the skill loading protocol. Each sub-item must be explored to field-level depth:
92
94
 
93
95
  1. **Data placement** — What lives in the database vs cache vs object storage vs external service vs local device storage? For each entity: which service owns it and why
@@ -119,6 +121,16 @@ Write the completed cross-store consistency table to `docs/plans/architecture-dr
119
121
 
120
122
  Read `.agent/skills/prd-templates/references/data-placement-template.md` for the template structure. Create `docs/plans/data-placement-strategy.md` using the template, filling each section with the data decisions confirmed above.
121
123
 
124
+ ## Completion Gate (MANDATORY)
125
+
126
+ Before reporting completion or proceeding to next shard:
127
+
128
+ 1. **Memory check** — Apply rule `memory-capture`. Write any patterns, decisions, or blockers from this shard to `.agent/progress/memory/`. Architecture decisions have the highest downstream impact — every confirmed decision should have a `DEC-NNN` entry. If nothing to write, confirm: "No new patterns/decisions/blockers."
129
+ 2. **Progress update** — Update `.agent/progress/` tracking files if they exist.
130
+ 3. **Session log** — Write session entry to `.agent/progress/sessions/`.
131
+
132
+ ---
133
+
122
134
  ### Next step
123
135
 
124
136
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/create-prd-security`.
@@ -61,7 +61,10 @@ Write the completed `## Development Methodology` section to `docs/plans/architec
61
61
 
62
62
  Load the CI/CD skill(s) from the cross-cutting section per the skill loading protocol.
63
63
 
64
- Break the feature inventory from `docs/plans/ideation/ideation-index.md` (MoSCoW Summary) into dependency-ordered phases.
64
+ Break the feature inventory into dependency-ordered phases. Use **two sources**:
65
+
66
+ 1. **MoSCoW priorities** from `docs/plans/ideation/ideation-index.md` (MoSCoW Summary) — determines Must/Should/Could classification
67
+ 2. **Domain Digest** from `docs/plans/architecture-draft.md` (`## Ideation Digest`) — if it exists, use its per-domain feature counts, sub-domain counts, and cross-domain dependencies to inform phase complexity sizing and dependency ordering. A domain with 15 features and 3 sub-domains requires more phase capacity than one with 4 features.
65
68
 
66
69
  > **This kit does not build MVPs.** Every phase ships production-grade code —
67
70
  > fully tested, fully specified, fully accessible. Phases exist to manage
@@ -134,6 +134,16 @@ If any section is incomplete, loop back to the relevant decision step and resolv
134
134
 
135
135
  ---
136
136
 
137
+ ## Completion Gate (MANDATORY)
138
+
139
+ Before reporting completion or proceeding to next shard:
140
+
141
+ 1. **Memory check** — Apply rule `memory-capture`. Write any patterns, decisions, or blockers from this shard to `.agent/progress/memory/`. All 7 design system decisions should be reviewed for `DEC-NNN` entries. If nothing to write, confirm: "No new patterns/decisions/blockers."
142
+ 2. **Progress update** — Update `.agent/progress/` tracking files if they exist.
143
+ 3. **Session log** — Write session entry to `.agent/progress/sessions/`.
144
+
145
+ ---
146
+
137
147
  ### Next step
138
148
 
139
149
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/create-prd-architecture`.
@@ -114,6 +114,16 @@ Read .agent/skills/logging-best-practices/SKILL.md and follow its Observability
114
114
 
115
115
  Write the completed `## Observability Architecture` section to `docs/plans/architecture-draft.md` immediately after user confirmation. Follow the write verification protocol (`.agent/skills/prd-templates/references/write-verification-protocol.md`).
116
116
 
117
+ ## Completion Gate (MANDATORY)
118
+
119
+ Before reporting completion or proceeding to next shard:
120
+
121
+ 1. **Memory check** — Apply rule `memory-capture`. Write any patterns, decisions, or blockers from this shard to `.agent/progress/memory/`. Security model decisions are high-impact — every confirmed decision should have a `DEC-NNN` entry. If nothing to write, confirm: "No new patterns/decisions/blockers."
122
+ 2. **Progress update** — Update `.agent/progress/` tracking files if they exist.
123
+ 3. **Session log** — Write session entry to `.agent/progress/sessions/`.
124
+
125
+ ---
126
+
117
127
  ### Next step
118
128
 
119
129
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/create-prd-compile`.
@@ -103,6 +103,16 @@ Read each installed skill's SKILL.md before proceeding. Append the confirmed dec
103
103
 
104
104
  Read `.agent/workflows/bootstrap-agents.md` and call it with `PIPELINE_STAGE=create-prd` plus only the keys just decided. Bootstrap runs after **each confirmed decision**, not in a batch at the end. At the end of all tech decisions, call bootstrap once more with `ARCHITECTURE_DOC` set to the dated filename.
105
105
 
106
+ ## Completion Gate (MANDATORY)
107
+
108
+ Before reporting completion or proceeding to next shard:
109
+
110
+ 1. **Memory check** — Apply rule `memory-capture`. Write any patterns, decisions, or blockers from this shard to `.agent/progress/memory/`. Tech stack decisions are high-impact — every confirmed decision should have a `DEC-NNN` entry. If nothing to write, confirm: "No new patterns/decisions/blockers."
111
+ 2. **Progress update** — Update `.agent/progress/` tracking files if they exist.
112
+ 3. **Session log** — Write session entry to `.agent/progress/sessions/`.
113
+
114
+ ---
115
+
106
116
  ### Next step
107
117
 
108
118
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/create-prd-architecture`.
@@ -46,6 +46,24 @@ Read `.agent/skills/prd-templates/references/engagement-tier-protocol.md` — ea
46
46
 
47
47
  ---
48
48
 
49
+ ## 1.5. Deep ideation loading (scale-aware)
50
+
51
+ Read the `## Progress Summary` table in `ideation-index.md`. Check these thresholds:
52
+
53
+ | Metric | Threshold |
54
+ |--------|-----------|
55
+ | Total domains | ≥ 6 |
56
+ | Total leaf features | ≥ 50 |
57
+ | Total surfaces | ≥ 2 (multi-product projects) |
58
+
59
+ **If ANY threshold is met** → read `.agent/skills/prd-templates/references/deep-ideation-loading-protocol.md` and follow its full procedure. This produces a **Domain Digest Table** written to `docs/plans/architecture-draft.md` as `## Ideation Digest`.
60
+
61
+ **If no threshold is met** → skip this step. The standard `ideation-index.md` read from Step 1 is sufficient.
62
+
63
+ > **Why**: For large ideation outputs (50+ features across 6+ domains), the Structure Map and MoSCoW Summary in `ideation-index.md` are insufficient for accurate architecture decisions. The digest reads every domain-level `*-index.md` to capture the full feature inventory, role coverage, and cross-domain dependencies without needing to load hundreds of leaf files.
64
+
65
+ ---
66
+
49
67
  ## 2. Load skills
50
68
 
51
69
  Read each skill SKILL.md listed in the frontmatter `skills` array.
@@ -76,6 +94,11 @@ Check `.agent/skills/` for stack-specific skills. Read `.agent/skills/find-skill
76
94
  ### Step C — Run `.agent/workflows/create-prd-security.md`
77
95
  ### Step D — Run `.agent/workflows/create-prd-compile.md`
78
96
 
97
+ **Shard failure recovery**: If any shard (A through D) fails mid-execution:
98
+ 1. Check `docs/plans/architecture-draft.md` for the last completed section
99
+ 2. Present the current state to the user: "Shard [N] failed at [step]. Draft contains sections [list]. Resume from failure point or restart the shard?"
100
+ 3. Do NOT proceed to the next shard until the current shard completes cleanly
101
+
79
102
  ---
80
103
 
81
104
  ## Step E — Quality gate
@@ -62,9 +62,16 @@ Fallback for domains not covered in the ideation domain folders is defined in th
62
62
  - Every shard in the decomposition plan has a corresponding `.md` file
63
63
  - `00-infrastructure.md` exists regardless of domain decomposition
64
64
  - No empty files (0 bytes)
65
+ - **Total shard count** is within acceptable range — read `.agent/skills/prd-templates/references/shard-boundary-analysis.md` → "Total Count Thresholds" and apply the ≤20/21-25/>25 gate
65
66
 
66
67
  If any skeleton is missing → create it now. Do not proceed to index creation with missing skeletons.
67
68
 
69
+ ### Domain coverage check
70
+
71
+ Read `docs/plans/ideation/ideation-index.md` → Domain Map. For each domain marked as having **Must Have** features:
72
+ - Verify at least one shard skeleton references this domain
73
+ - If a domain has no corresponding shard → **STOP**: "Ideation domain `[name]` with Must Have features has no IA shard. Add it to the decomposition plan or explain why it's excluded."
74
+
68
75
  ## 6. Create IA index
69
76
 
70
77
  Read `.agent/skills/prd-templates/references/decomposition-templates.md` for the **IA Index** template. Create `docs/plans/ia/index.md` using the template, populating the shards table with all shards created in Step 5.
@@ -83,6 +90,16 @@ Read `.agent/skills/prd-templates/references/decomposition-templates.md` for the
83
90
 
84
91
  For multi-surface projects, each surface's own `index.md` contains the standard three-layer table (IA/BE/FE) scoped to that surface, following the same format as the single-surface master index.
85
92
 
93
+ ## 9.5. Completion Gate (MANDATORY)
94
+
95
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
96
+ - Patterns observed → write to `memory/patterns.md`
97
+ - Non-trivial decisions made → write to `memory/decisions.md`
98
+ - Blockers hit → write to `memory/blockers.md`
99
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
100
+
101
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
102
+
86
103
  ### Next step
87
104
 
88
105
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/decompose-architecture-validate`.
@@ -70,10 +70,28 @@ Verify structural integrity:
70
70
  - [ ] BE/FE indexes exist with conventions templates
71
71
  - [ ] Multi-surface: shared shards have lower numbers; cross-surface deps point to shared/
72
72
 
73
+ ## 12.5. Update feature tracking ledger
74
+
75
+ If `docs/plans/feature-ledger.md` exists, read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow **Step 2 — IA Assignment**.
76
+
77
+ For each IA shard skeleton, match its features to ledger rows and populate the IA Shard and IA Status columns. Run the orphan check — any ideation feature with no IA shard assignment is flagged as `❌ missing`. Present orphans to the user for resolution before proceeding.
78
+
79
+ If the ledger does not exist, skip this step (ideation was run before the ledger protocol existed).
80
+
73
81
  ## 13. Generate spec pipeline tracker
74
82
 
75
83
  Read `.agent/skills/session-continuity/protocols/07-spec-pipeline-generation.md` and follow the Spec Pipeline Generation Protocol.
76
84
 
85
+ ## 13.5. Completion Gate (MANDATORY)
86
+
87
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
88
+ - Patterns observed → write to `memory/patterns.md`
89
+ - Non-trivial decisions made → write to `memory/decisions.md`
90
+ - Blockers hit → write to `memory/blockers.md`
91
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
92
+
93
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
94
+
77
95
  ## 14. Request review and propose next steps
78
96
 
79
97
  Use `notify_user` to present: IA directory, BE index, FE index, master index, spec pipeline tracker.
@@ -164,6 +164,26 @@ After all features are deepened, systematically identify emergent capabilities t
164
164
 
165
165
  ---
166
166
 
167
+ ## Post-Discovery Verification
168
+
169
+ Before completing discovery, count and verify the ideation output:
170
+ 1. List all files in `docs/plans/ideation/` recursively
171
+ 2. Verify each domain in the ideation-index has its corresponding folder with at minimum:
172
+ - `{slug}-index.md` (domain index)
173
+ - `{slug}-cx.md` (cross-cutting concerns file)
174
+ 3. Verify `ideation-index.md` exists and has a populated Domain Map
175
+ 4. If any domain folder is missing its required files → create them now before proceeding
176
+
177
+ ## Completion Gate (MANDATORY)
178
+
179
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
180
+ - Patterns observed → write to `memory/patterns.md`
181
+ - Non-trivial decisions made → write to `memory/decisions.md`
182
+ - Blockers hit → write to `memory/blockers.md`
183
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
184
+
185
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
186
+
167
187
  ### Next step
168
188
 
169
189
  **STOP** — do NOT proceed to any other workflow. The only valid next step is `/ideate-validate`.
@@ -116,6 +116,16 @@ Verify every domain in `ideation-index.md` appears in `vision.md`. Nothing dropp
116
116
 
117
117
  ---
118
118
 
119
+ ## 11.5. Create feature tracking ledger
120
+
121
+ Read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow **Step 1 — Ledger Creation**.
122
+
123
+ Enumerate every leaf feature from the ideation fractal tree and write `docs/plans/feature-ledger.md` with Feature ID, Feature Name, Domain, and MoSCoW columns populated. All downstream columns start as `—`.
124
+
125
+ > **This step is non-optional.** The ledger is the only global tracking mechanism that follows features from ideation through implementation. Without it, features can be silently dropped at stage boundaries.
126
+
127
+ ---
128
+
119
129
  ## 12. Request review
120
130
 
121
131
  ### Self-check against Ideation rubric
@@ -80,6 +80,16 @@ For each acceptance criterion, trace its spec citation (e.g., `[BE §3.2]`, `[FE
80
80
  2. Read the full §section from every cited FE spec — component props, states, interactions, responsive behavior, accessibility rules
81
81
  3. Read any IA shard sections cited by the BE spec's Source Map — especially `## Edge Cases` and `## Access Control`
82
82
 
83
+ ### Companion spec discovery (split-awareness)
84
+
85
+ After loading the cited specs, check each spec filename for a letter suffix (e.g., `09a-`, `09b-`). If found:
86
+
87
+ 1. Check the spec for a `## Split Group` section. If it lists **Companion specs**, read the `## Split Group` section from each companion to load shared entity definitions
88
+ 2. If no `## Split Group` section exists, fall back to directory scan: list all files in the same `docs/plans/be/` or `docs/plans/fe/` directory with the same number prefix (e.g., all `09*` files). Read the header block of each match to identify siblings
89
+ 3. Load any **Shared entities** into context — these data models are used across companions and may affect contracts, validation, or state management in the current slice
90
+
91
+ > **Why**: A split shard divides a domain for spec-writing manageability, but the underlying data models and access patterns remain shared. Without loading companion context, the implementation may miss cross-cutting validation rules or produce incompatible data shapes.
92
+
83
93
  This context persists throughout the TDD cycle. The acceptance criteria define WHAT to test; the spec context defines HOW DEEP to test it.
84
94
 
85
95
  ## 1.5. Check for parallel mode
@@ -120,6 +120,16 @@ Collect all mismatches into a consistency report. If any exist → **hard stop**
120
120
 
121
121
  ---
122
122
 
123
+ ## 0.7. Feature ledger verification
124
+
125
+ If `docs/plans/feature-ledger.md` exists, read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow the **Verification Gate** procedure.
126
+
127
+ Count features by completeness (✅ complete, ⚠️ partial, ❌ orphaned). If any features show `❌ missing` in the IA Status, BE Status, or FE Status columns → **BLOCKING GATE**: present the orphaned features and require resolution before proceeding to slice planning.
128
+
129
+ If the ledger does not exist, skip this step.
130
+
131
+ ---
132
+
123
133
  ## 0.8. Draft continuity check
124
134
 
125
135
  Check whether `docs/plans/phases/phase-N-draft.md` already exists (where N is the current phase number).
@@ -73,6 +73,21 @@ After all slices are identified, verify that the slices collectively cover ALL s
73
73
 
74
74
  **BLOCKING GATE**: Do NOT proceed to Step 3 until every BE endpoint and FE component is either assigned to a slice or explicitly deferred.
75
75
 
76
+ **Feature ledger update**: If `docs/plans/feature-ledger.md` exists, read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow **Step 5 — Slice Assignment**. Map each slice to its Feature IDs and populate the Phase and Slice columns.
77
+
78
+ ### 2.75. Split companion cross-reference
79
+
80
+ For each spec in the phase scope, check if its filename contains a letter suffix (e.g., `09a-`, `09b-`):
81
+
82
+ 1. If a letter suffix is found, read the spec's `## Split Group` section to identify companion specs
83
+ 2. If any companion spec is ALSO in the current phase scope, verify that slices which reference entities shared across the split are annotated with companion citations. Example:
84
+ - Slice "Create message thread" cites `[BE §3.2 09a-chat-api]` and uses the `Thread` entity
85
+ - `Thread` is listed as a shared entity with `09b-agent-flow-api`
86
+ - → Add companion context note: "**Companion context**: `Thread` entity shared with `09b-agent-flow-api.md` — load `§ Database Schema` from companion during implementation"
87
+ 3. If a companion spec is NOT in the current phase scope, add a note to the slice: "**Cross-phase dependency**: Companion `09b-agent-flow-api.md` is in Phase N+1 — shared entity `Thread` must remain backward-compatible"
88
+
89
+ This step prevents implementation from producing incompatible data shapes across split domain boundaries.
90
+
76
91
  ## 3. Order by dependency
77
92
 
78
93
  Read .agent/skills/concise-planning/SKILL.md and follow its methodology.
@@ -23,6 +23,15 @@ Initialize the project, create the directory structure, install dependencies, an
23
23
 
24
24
  ---
25
25
 
26
+ ## 0.5. Feature ledger pre-flight
27
+
28
+ If `docs/plans/feature-ledger.md` exists:
29
+ 1. Read the ledger and the current phase plan
30
+ 2. Verify every **Must Have** feature has a non-empty entry in the **Phase** column
31
+ 3. If any Must Have feature has no phase assignment → **STOP**: "Must Have feature `[ID: name]` has no phase assignment. Assign it via `/plan-phase` before scaffolding."
32
+
33
+ ---
34
+
26
35
  ## 1. Read architecture pattern
27
36
 
28
37
  Read `docs/plans/*-architecture-design.md` and determine:
@@ -154,4 +163,16 @@ Run the dev server command from `.agent/instructions/commands.md`:
154
163
 
155
164
  **Pass criteria**: Dev server starts, serves a response, and shuts down cleanly.
156
165
 
166
+ ## 9.5. Completion Gate (MANDATORY)
167
+
168
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
169
+ - Patterns observed → write to `memory/patterns.md`
170
+ - Non-trivial decisions made → write to `memory/decisions.md`
171
+ - Blockers hit → write to `memory/blockers.md`
172
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
173
+
174
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
175
+
157
176
  > Present result to user: "✅ Scaffold complete. Dev server starts cleanly. Proceeding to CI/CD setup." or "❌ Dev server failed: [error]. Fix required before continuing."
177
+
178
+ > ❌ **NEXT STEP RESTRICTION**: The next workflow is `/setup-workspace-cicd`. Do NOT proceed to `/implement-slice` or any implementation work until all four setup-workspace shards (scaffold → cicd → hosting → data) have completed. Skipping setup shards will cause infrastructure failures during implementation.
@@ -22,8 +22,9 @@ Operational setup of the project workspace, CI/CD pipeline, hosting platform, an
22
22
 
23
23
  ## 0. Pre-flight
24
24
 
25
- 1. Read the approved phase plan from `docs/plans/phases/phase-N.md`
26
- 2. Read `docs/plans/*-architecture-design.md` for the architecture pattern
25
+ 1. Read `.agent/skills/session-continuity/SKILL.md` and follow its session-open protocol. Check `.agent/progress/sessions/` for any previous session working on `setup-workspace`. If found → read the session close log to determine which shards completed and resume from the next incomplete shard.
26
+ 2. Read the approved phase plan from `docs/plans/phases/phase-N.md`
27
+ 3. Read `docs/plans/*-architecture-design.md` for the architecture pattern
27
28
 
28
29
  **Architecture pattern detection** — determines iteration strategy:
29
30
 
@@ -67,6 +68,18 @@ After all 4 shards complete, run `/verify-infrastructure` with trigger `workspac
67
68
 
68
69
  ---
69
70
 
71
+ ## 2.5. Completion Gate (MANDATORY)
72
+
73
+ 1. Update `.agent/progress/` — mark workspace setup as complete
74
+ 2. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
75
+ - Patterns observed → write to `memory/patterns.md`
76
+ - Non-trivial decisions made → write to `memory/decisions.md`
77
+ - Blockers hit → write to `memory/blockers.md`
78
+ 3. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
79
+ 4. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
80
+
81
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
82
+
70
83
  ## 3. Completion
71
84
 
72
85
  Use `notify_user` to present results:
@@ -136,8 +136,29 @@ If the `dependency-auditing` skill is installed (`.agent/skills/dependency-audit
136
136
 
137
137
  **Pass criteria**: Zero HIGH/CRITICAL vulnerabilities in production dependencies.
138
138
 
139
+ ## 8.7. Feature ledger reconciliation
140
+
141
+ If `docs/plans/feature-ledger.md` exists:
142
+ 1. Read the ledger and the current phase plan
143
+ 2. For each **Must Have** feature assigned to this phase:
144
+ - Verify the `Implemented` column is marked complete
145
+ - Verify the slice(s) that implement it are marked complete in `.agent/progress/phases/phase-N.md`
146
+ 3. If any Must Have feature assigned to this phase is not implemented → **STOP**: "Phase N has unimplemented Must Have features: [list]. Complete them via `/implement-slice` before marking the phase as validated."
147
+
148
+ ## 8.8. Boundary stub audit
149
+
150
+ Grep the codebase for `BOUNDARY:` comments:
151
+ 1. If **0 results** → ✅ Pass — no active boundary stubs
152
+ 2. If results found → for each:
153
+ - Verify a linked tracking issue exists and is open
154
+ - Verify a sentinel test exists
155
+ - Verify the boundary is for a spec that genuinely doesn't exist yet
156
+ - If any boundary stub lacks a tracking issue OR the referenced spec now exists → **STOP**: "Active boundary stub at `[file:line]` — the referenced spec now exists. Replace the stub with a full implementation before marking this phase as validated."
157
+
139
158
  ## 9. Document results
140
159
 
160
+ **Pre-append verification**: Before appending, verify `docs/audits/phase-N-validation.md` exists and contains a `## Spec Coverage` section from Step 5.8 (quality shard). If the file does not exist or the section is missing → **STOP**: "Spec coverage sweep did not complete. Re-run `/validate-phase-quality` Step 5.8 before appending readiness results."
161
+
141
162
  **Note on report file**: `docs/audits/phase-N-validation.md` is written progressively. Step 5.8 creates the file and appends the `## Spec Coverage` section. Step 9 appends all remaining sections. Do not recreate or overwrite the file in Step 9 — append only.
142
163
 
143
164
  - Test results and coverage
@@ -154,6 +175,18 @@ If the `dependency-auditing` skill is installed (`.agent/skills/dependency-audit
154
175
  - Migration verification status
155
176
  - Pass/fail verdict
156
177
 
178
+ ## 9.5. Completion Gate (MANDATORY)
179
+
180
+ 1. Update `.agent/progress/` — mark phase as validated
181
+ 2. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
182
+ - Patterns observed → write to `memory/patterns.md`
183
+ - Non-trivial decisions made → write to `memory/decisions.md`
184
+ - Blockers hit → write to `memory/blockers.md`
185
+ 3. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
186
+ 4. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
187
+
188
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
189
+
157
190
  ## 10. Present results and next steps
158
191
 
159
192
  Read .agent/skills/verification-before-completion/SKILL.md and follow its methodology.
@@ -194,6 +194,17 @@ Read `docs/plans/*-architecture-design.md` section `## Observability Architectur
194
194
 
195
195
  ---
196
196
 
197
+ ## 6.7. Spec pipeline integrity check
198
+
199
+ 1. Read `.agent/progress/spec-pipeline.md` — verify all IA/BE/FE columns show ✅ for all shards included in the current phase
200
+ 2. If `docs/plans/feature-ledger.md` exists:
201
+ - Read the ledger and verify no **Must Have** features have gaps in IA/BE/FE coverage
202
+ - If any Must Have feature has an empty column → **STOP**: "Feature `[ID: name]` is missing `[column]` coverage. Complete the spec before proceeding to implementation."
203
+
204
+ > This is a lightweight check — it does not re-audit specs, just confirms the tracking is intact.
205
+
206
+ ---
207
+
197
208
  ## 7-8. Finalize report
198
209
 
199
210
  Finalize the report using the **Final Report** template from `.agent/skills/prd-templates/references/infrastructure-report-template.md`. Update the Verdict field to `✅ PASS` or `❌ FAIL` and fill in Failures and Next Steps sections.
@@ -202,6 +213,17 @@ The final report must include all eight gate checks: 0 (placeholder audit), 1 (C
202
213
 
203
214
  ---
204
215
 
216
+ ## 8.5. Completion Gate (MANDATORY)
217
+
218
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
219
+ - Patterns observed → write to `memory/patterns.md`
220
+ - Non-trivial decisions made → write to `memory/decisions.md`
221
+ - Blockers hit → write to `memory/blockers.md`
222
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
223
+ 3. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
224
+
225
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
226
+
205
227
  ## 9. Present results
206
228
 
207
229
  Use `notify_user` to present the verification verdict:
@@ -43,6 +43,7 @@ Re-read the complete draft (interactions + contracts + data model + access contr
43
43
  - Access rules that don't cover all interaction types
44
44
  - Edge cases that imply missing error codes in contracts
45
45
  - Event schemas that carry fields not in the data model
46
+ - **Event consumer cross-references**: For each event's listed consumers, verify the consumer shard exists in `docs/plans/ia/index.md` and its `## Interactions` or `## Event Schemas` section references this event. If a consumer shard doesn't reference the event → add a cross-reference link in both directions. If a consumer shard doesn't exist → **STOP**.
46
47
 
47
48
  Fix every inconsistency found. Present findings to the user.
48
49
 
@@ -85,6 +86,26 @@ Read .agent/skills/technical-writer/SKILL.md for the spec writing step.
85
86
 
86
87
  Replace the skeleton sections in `docs/plans/ia/[shard-name].md` with the full content from all passes. Ensure all cross-shard dependencies are bidirectional.
87
88
 
89
+ ### 9.5. Spec complexity gate
90
+
91
+ Count the total lines in the written spec file.
92
+
93
+ | Lines | Action |
94
+ |-------|--------|
95
+ | **≤ 400** | ✅ Pass — proceed to Step 10 |
96
+ | **401–500** | ⚠️ Warning — present to user: "This IA spec is [N] lines. Downstream BE/FE specs will expand further. Consider splitting if sections are independently testable." Proceed after acknowledgment. |
97
+ | **> 500** | 🛑 **Hard stop** — "This IA spec is [N] lines and will likely exceed agent context capacity during BE/FE spec writing. Split this shard into two IA specs via `/decompose-architecture-validate` before proceeding." Present the largest sections with their line counts as split candidates. |
98
+
99
+ > **Why these thresholds**: A 500-line IA spec typically expands to 800-1200 lines per BE/FE spec (contracts, schemas, validation rules, component details). Agent context windows degrade at > 1000 lines of spec content plus the workflow instructions.
100
+
101
+ ### 9.1. Post-write verification
102
+
103
+ Re-read `docs/plans/ia/[shard-name].md` and verify:
104
+ 1. All required sections contain non-empty content (not just headers or `<!-- TODO -->` markers)
105
+ 2. File size is > 0 bytes
106
+ 3. No `<!-- TODO -->` markers remain (outside of intentional `[N/A]` sections)
107
+ 4. If any check fails → the write was incomplete. Retry the write operation.
108
+
88
109
  ## 10. Update IA index
89
110
 
90
111
  Change the shard's status from 🔲 to ✅ in `docs/plans/ia/index.md`.
@@ -126,6 +147,18 @@ Read `.agent/skills/session-continuity/protocols/ambiguity-gates.md` and run the
126
147
 
127
148
  **Hard gate**: Do NOT propose `/write-be-spec` until `/audit-ambiguity ia` scores 0% ambiguity.
128
149
 
150
+ ## 13.5. Completion Gate (MANDATORY)
151
+
152
+ 1. Update `.agent/progress/spec-pipeline.md` — mark IA column for this shard as complete
153
+ 2. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
154
+ - Patterns observed → write to `memory/patterns.md`
155
+ - Non-trivial decisions made → write to `memory/decisions.md`
156
+ - Blockers hit → write to `memory/blockers.md`
157
+ 3. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
158
+ 4. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
159
+
160
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
161
+
129
162
  ## 14. Request review and propose next steps
130
163
 
131
164
  > [!CAUTION]
@@ -121,7 +121,7 @@ Define for each entity: tables/collections, fields, types, relationships, indexe
121
121
 
122
122
  Write `## Data Models` to shard file immediately after confirmation. Follow write verification protocol.
123
123
 
124
- > **Decision recording**: For non-trivial data model decisions (schema approach, denormalization trade-offs, index strategy), read `.agent/skills/session-continuity/protocols/06-decision-analysis.md` and follow the **Decision Effect Analysis Protocol**.
124
+ > **Decision recording**: For non-trivial data model or access control decisions, follow `.agent/skills/session-continuity/protocols/06-decision-analysis.md`.
125
125
 
126
126
  ## 5. Design access control
127
127
 
@@ -137,8 +137,6 @@ Read .agent/skills/security-scanning-security-hardening/SKILL.md and apply its a
137
137
 
138
138
  Write `## Access Control` to shard file immediately after confirmation. Follow write verification protocol.
139
139
 
140
- > **Decision recording**: For access control architecture decisions (role hierarchy, ownership model, escalation paths), read `.agent/skills/session-continuity/protocols/06-decision-analysis.md` and follow the **Decision Effect Analysis Protocol**. Record to `memory/decisions.md`.
141
-
142
140
  ## 5.5. Accessibility specifications
143
141
 
144
142
  Read `{{SURFACES}}` to determine the project's target surfaces.
@@ -157,6 +155,10 @@ Write `## Accessibility` to shard file immediately after confirmation. Follow wr
157
155
 
158
156
  Write `## Event Schemas` to shard file immediately after confirmation (if applicable). Follow write verification protocol.
159
157
 
158
+ ### 6b. Event consumer cross-reference (if events defined)
159
+
160
+ For each event's listed consumers: verify consumer shard exists in `docs/plans/ia/index.md` and references this event. If consumer shard missing → **STOP**. Full cross-ref verification runs in the deepen shard.
161
+
160
162
  ## 7. Document edge cases
161
163
 
162
164
  Read .agent/skills/resolve-ambiguity/SKILL.md and follow its methodology.
@@ -183,6 +185,10 @@ For each referenced deep dive:
183
185
  2. If still a skeleton → write exhaustive subsystem detail: algorithms/state machines, technology choices with rationale, phasing strategy, data schemas, failure modes, integration contracts, performance, and security.
184
186
  3. Write immediately — do not wait until Step 8. The parent shard's summary + link is sufficient; the deep dive file IS the content.
185
187
 
188
+ ## 7.7. Completion Gate (MANDATORY)
189
+
190
+ Scan for memory-capture triggers (rule: `memory-capture`). Write patterns/decisions/blockers to `memory/`. If none → confirm "No new entries." **Not skippable** — complete before `notify_user`.
191
+
186
192
  ## 8. Present all sections and request approval
187
193
 
188
194
  **Section completeness gate**: Before requesting approval, verify the spec file at `docs/plans/ia/[shard-name].md` contains ALL of the following sections with non-empty content (not just headers or `<!-- TODO -->` markers):
@@ -75,6 +75,10 @@ Build a **Referenced Material Inventory**.
75
75
  ### 5c. Read deep dives
76
76
  List `docs/plans/ia/deep-dives/`. Read each referenced deep dive in full. Extract key decisions, architectural constraints, data schemas.
77
77
 
78
+ **Deep dive completeness check**: For each deep dive file referenced by the IA shard:
79
+ - If the file contains `<!-- TODO -->`, `[TBD]`, or sections with only headers and no content → **STOP**: "Deep dive `[filename]` is still a skeleton. Run `/write-architecture-spec-design` Step 7.5 to fill it before proceeding with BE spec writing."
80
+ - If the file does not exist → **STOP**: "Deep dive `[filename]` is referenced but missing. Create it via `/write-architecture-spec-design` Step 7.5."
81
+
78
82
  ### 5d. Read testability section
79
83
  If the shard has testability/acceptance criteria → read for performance targets and test requirements.
80
84
 
@@ -82,6 +86,16 @@ If the shard has testability/acceptance criteria → read for performance target
82
86
 
83
87
  Read any completed cross-cutting specs at `docs/plans/be/00-*.md`.
84
88
 
89
+ ## 6.5. Completion Gate (MANDATORY)
90
+
91
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
92
+ - Patterns observed → write to `memory/patterns.md`
93
+ - Non-trivial decisions made → write to `memory/decisions.md`
94
+ - Blockers hit → write to `memory/blockers.md`
95
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
96
+
97
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
98
+
85
99
  ## 7. Present classification and request approval
86
100
 
87
101
  Use `notify_user` presenting: classification, expected spec count, Referenced Material Inventory, split boundaries (if applicable).
@@ -91,3 +105,5 @@ Use `notify_user` presenting: classification, expected spec count, Referenced Ma
91
105
  After approval: read `.agent/skills/prd-templates/references/be-spec-template.md` → create spec file stub at `docs/plans/be/[NN-feature-name].md`.
92
106
 
93
107
  For structural reference (0 BE specs): confirm no write shard needed, propose next IA shard.
108
+
109
+ > ❌ **NEXT STEP RESTRICTION**: Do NOT begin writing the BE spec (`/write-be-spec-write`) until the user has explicitly approved the classification and material inventory. If deep dive completeness issues were flagged in Step 5c, they must be resolved before proceeding.
@@ -47,8 +47,22 @@ Read .agent/skills/testing-strategist/SKILL.md and follow its methodology.
47
47
 
48
48
  **Naming convention**: Use the same number prefix as the IA shard that sources it, followed by a kebab-case feature name. For multi-domain splits from the same shard, append a letter suffix (e.g., `09a-chat-api.md`, `09b-agent-flow-api.md`). For cross-cutting specs, use the `00-` prefix (e.g., `00-api-conventions.md`).
49
49
 
50
+ **Split group tracking**: If this spec results from a split shard (letter suffix in filename), populate the `## Split Group` section in the spec with the split origin shard, companion spec filenames, and shared entity names. This is mandatory for split specs — it enables downstream implementation to discover sibling context.
51
+
50
52
  Read `.agent/skills/prd-templates/references/be-spec-template.md` for the document structure and quality gates checklist. Follow the conventions template from `be/index.md`.
51
53
 
54
+ Write decision to disk. Continue below.
55
+
56
+ ### 7.5. Spec complexity gate
57
+
58
+ Count the total lines in the written BE spec file.
59
+
60
+ | Lines | Action |
61
+ |-------|--------|
62
+ | **≤ 600** | ✅ Pass |
63
+ | **601–800** | ⚠️ Warning — "This BE spec is [N] lines. Consider splitting if endpoint groups are independently testable." Proceed after acknowledgment. |
64
+ | **> 800** | 🛑 **Hard stop** — "This BE spec is [N] lines and will degrade implementation quality. Split the parent IA shard or separate endpoint groups into distinct BE specs." Present the largest sections with line counts. |
65
+
52
66
  ## 8. Update the BE index
53
67
 
54
68
  Add or update the spec entry in `docs/plans/be/index.md`. For multi-domain splits, add one row per BE spec with the shared IA source.
@@ -134,6 +148,22 @@ If this BE spec introduces a technology not already in the project's tech stack:
134
148
  - **2nd failure** → **STOP**: tell the user which dependency failed and ask: "Install manually, skip, or abort?"
135
149
  4. Confirm the matching skill is installed before proceeding.
136
150
 
151
+ ## 13.5. Update feature tracking ledger
152
+
153
+ If `docs/plans/feature-ledger.md` exists, read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow **Step 3 — BE Coverage**. Match the endpoints in this spec to Feature IDs and populate the BE Spec and BE Status columns.
154
+
155
+ ## 13.7. Completion Gate (MANDATORY)
156
+
157
+ 1. Update `.agent/progress/spec-pipeline.md` — mark BE column for this shard as complete
158
+ 2. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
159
+ - Patterns observed → write to `memory/patterns.md`
160
+ - Non-trivial decisions made → write to `memory/decisions.md`
161
+ - Blockers hit → write to `memory/blockers.md`
162
+ 3. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
163
+ 4. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
164
+
165
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
166
+
137
167
  ## 14. Request review and propose next steps
138
168
 
139
169
  > [!CAUTION]
@@ -138,6 +138,16 @@ any that contain FE-relevant decisions.
138
138
 
139
139
  Read any completed cross-cutting FE specs — feature specs must follow their patterns. List the files matching `docs/plans/fe/00-*.md` (cross-cutting specs).
140
140
 
141
+ ## 5.5. Completion Gate (MANDATORY)
142
+
143
+ 1. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
144
+ - Patterns observed → write to `memory/patterns.md`
145
+ - Non-trivial decisions made → write to `memory/decisions.md`
146
+ - Blockers hit → write to `memory/blockers.md`
147
+ 2. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
148
+
149
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
150
+
141
151
  ## 6. Present classification and request approval
142
152
 
143
153
  Call `notify_user` presenting:
@@ -36,8 +36,22 @@ Read .agent/skills/testing-strategist/SKILL.md and follow its methodology.
36
36
 
37
37
  **Naming convention**: Numbered prefix matching feature position + kebab-case name (e.g., `01-auth-ui.md`). Cross-cutting: `00-` prefix.
38
38
 
39
+ **Split group tracking**: If this spec results from a split shard (letter suffix in filename), populate the `## Split Group` section in the spec with the split origin shard, companion spec filenames, and shared entity names. This is mandatory for split specs — it enables downstream implementation to discover sibling context.
40
+
39
41
  Read `.agent/skills/prd-templates/references/fe-spec-template.md` for the document structure and quality gates checklist. Follow the conventions from `fe/index.md`.
40
42
 
43
+ Write decision to disk. Continue below.
44
+
45
+ ### 6.5. Spec complexity gate
46
+
47
+ Count the total lines in the written FE spec file.
48
+
49
+ | Lines | Action |
50
+ |-------|--------|
51
+ | **≤ 600** | ✅ Pass |
52
+ | **601–800** | ⚠️ Warning — "This FE spec is [N] lines. Consider splitting if component groups are independently testable." Proceed after acknowledgment. |
53
+ | **> 800** | 🛑 **Hard stop** — "This FE spec is [N] lines and will degrade implementation quality. Split into separate FE specs per component group or page." Present the largest sections with line counts. |
54
+
41
55
  ## 7. Update the FE index
42
56
 
43
57
  Change the spec's status from 🔲 to ✅ in `docs/plans/fe/index.md`.
@@ -128,6 +142,22 @@ If this FE spec introduces a new technology:
128
142
  2. Read `.agent/workflows/bootstrap-agents.md` and invoke `/bootstrap-agents PIPELINE_STAGE=write-fe-spec` + the new dependency key
129
143
  3. **HARD GATE**: Follow the bootstrap verification protocol (`.agent/skills/prd-templates/references/bootstrap-verification-protocol.md`). Confirm the matching skill is installed before proceeding.
130
144
 
145
+ ## 12.5. Update feature tracking ledger
146
+
147
+ If `docs/plans/feature-ledger.md` exists, read `.agent/skills/prd-templates/references/feature-ledger-protocol.md` and follow **Step 4 — FE Coverage**. Match the components in this spec to Feature IDs and populate the FE Spec and FE Status columns.
148
+
149
+ ## 12.7. Completion Gate (MANDATORY)
150
+
151
+ 1. Update `.agent/progress/spec-pipeline.md` — mark FE column for this shard as complete
152
+ 2. Scan this conversation for memory-capture triggers (see rule: `memory-capture`):
153
+ - Patterns observed → write to `memory/patterns.md`
154
+ - Non-trivial decisions made → write to `memory/decisions.md`
155
+ - Blockers hit → write to `memory/blockers.md`
156
+ 3. If no triggers found → confirm: "No new patterns, decisions, or blockers to log"
157
+ 4. Read `.agent/skills/session-continuity/protocols/05-session-close.md` and write a session close log
158
+
159
+ > **This step is not skippable.** Do not call `notify_user` until all items above are complete.
160
+
131
161
  ## 13. Request review and propose next steps
132
162
 
133
163
  Read .agent/skills/verification-before-completion/SKILL.md and follow its methodology.