cfsa-antigravity 2.0.0 → 2.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 (116) hide show
  1. package/README.md +14 -0
  2. package/package.json +1 -1
  3. package/template/.agent/instructions/commands.md +8 -32
  4. package/template/.agent/instructions/example.md +21 -0
  5. package/template/.agent/instructions/patterns.md +3 -3
  6. package/template/.agent/instructions/tech-stack.md +71 -23
  7. package/template/.agent/instructions/workflow.md +12 -1
  8. package/template/.agent/rules/completion-checklist.md +6 -0
  9. package/template/.agent/rules/security-first.md +3 -3
  10. package/template/.agent/rules/vertical-slices.md +1 -1
  11. package/template/.agent/skill-library/MANIFEST.md +6 -0
  12. package/template/.agent/skill-library/stack/devops/git-advanced/SKILL.md +972 -0
  13. package/template/.agent/skill-library/stack/devops/git-workflow/SKILL.md +420 -0
  14. package/template/.agent/skills/api-versioning/SKILL.md +44 -298
  15. package/template/.agent/skills/api-versioning/references/typescript.md +157 -0
  16. package/template/.agent/skills/architecture-mapping/SKILL.md +13 -13
  17. package/template/.agent/skills/bootstrap-agents/SKILL.md +151 -152
  18. package/template/.agent/skills/clean-code/SKILL.md +64 -118
  19. package/template/.agent/skills/clean-code/references/typescript.md +126 -0
  20. package/template/.agent/skills/database-schema-design/SKILL.md +93 -317
  21. package/template/.agent/skills/database-schema-design/references/relational.md +228 -0
  22. package/template/.agent/skills/error-handling-patterns/SKILL.md +62 -557
  23. package/template/.agent/skills/error-handling-patterns/references/go.md +162 -0
  24. package/template/.agent/skills/error-handling-patterns/references/python.md +262 -0
  25. package/template/.agent/skills/error-handling-patterns/references/rust.md +112 -0
  26. package/template/.agent/skills/error-handling-patterns/references/typescript.md +178 -0
  27. package/template/.agent/skills/idea-extraction/SKILL.md +322 -224
  28. package/template/.agent/skills/logging-best-practices/SKILL.md +108 -767
  29. package/template/.agent/skills/logging-best-practices/references/go.md +49 -0
  30. package/template/.agent/skills/logging-best-practices/references/python.md +52 -0
  31. package/template/.agent/skills/logging-best-practices/references/typescript.md +215 -0
  32. package/template/.agent/skills/migration-management/SKILL.md +127 -311
  33. package/template/.agent/skills/migration-management/references/relational.md +214 -0
  34. package/template/.agent/skills/parallel-feature-development/SKILL.md +34 -43
  35. package/template/.agent/skills/pipeline-rubrics/references/be-rubric.md +1 -1
  36. package/template/.agent/skills/pipeline-rubrics/references/ia-rubric.md +2 -2
  37. package/template/.agent/skills/pipeline-rubrics/references/scoring.md +1 -1
  38. package/template/.agent/skills/pipeline-rubrics/references/vision-rubric.md +2 -1
  39. package/template/.agent/skills/prd-templates/SKILL.md +23 -6
  40. package/template/.agent/skills/prd-templates/references/be-spec-template.md +2 -2
  41. package/template/.agent/skills/prd-templates/references/decomposition-templates.md +2 -2
  42. package/template/.agent/skills/prd-templates/references/engineering-standards-template.md +2 -0
  43. package/template/.agent/skills/prd-templates/references/fe-spec-template.md +1 -1
  44. package/template/.agent/skills/prd-templates/references/fractal-cx-template.md +58 -0
  45. package/template/.agent/skills/prd-templates/references/fractal-feature-template.md +93 -0
  46. package/template/.agent/skills/prd-templates/references/fractal-node-index-template.md +55 -0
  47. package/template/.agent/skills/prd-templates/references/ideation-crosscut-template.md +26 -47
  48. package/template/.agent/skills/prd-templates/references/ideation-index-template.md +47 -31
  49. package/template/.agent/skills/prd-templates/references/operational-templates.md +1 -1
  50. package/template/.agent/skills/prd-templates/references/placeholder-workflow-mapping.md +50 -21
  51. package/template/.agent/skills/prd-templates/references/skill-loading-protocol.md +32 -0
  52. package/template/.agent/skills/prd-templates/references/slice-completion-gates.md +29 -0
  53. package/template/.agent/skills/prd-templates/references/spec-coverage-sweep.md +3 -3
  54. package/template/.agent/skills/prd-templates/references/tdd-testing-policy.md +39 -0
  55. package/template/.agent/skills/prd-templates/references/vision-template.md +8 -8
  56. package/template/.agent/skills/regex-patterns/SKILL.md +122 -540
  57. package/template/.agent/skills/regex-patterns/references/go.md +44 -0
  58. package/template/.agent/skills/regex-patterns/references/javascript.md +63 -0
  59. package/template/.agent/skills/regex-patterns/references/python.md +77 -0
  60. package/template/.agent/skills/regex-patterns/references/rust.md +43 -0
  61. package/template/.agent/skills/resolve-ambiguity/SKILL.md +1 -1
  62. package/template/.agent/skills/session-continuity/SKILL.md +11 -9
  63. package/template/.agent/skills/session-continuity/protocols/02-progress-generation.md +2 -2
  64. package/template/.agent/skills/session-continuity/protocols/04-pattern-extraction.md +1 -1
  65. package/template/.agent/skills/session-continuity/protocols/05-session-close.md +1 -1
  66. package/template/.agent/skills/session-continuity/protocols/09-parallel-claim.md +1 -1
  67. package/template/.agent/skills/session-continuity/protocols/10-placeholder-verification-gate.md +57 -78
  68. package/template/.agent/skills/session-continuity/protocols/11-parallel-synthesis.md +1 -1
  69. package/template/.agent/skills/spec-writing/SKILL.md +1 -1
  70. package/template/.agent/skills/tdd-workflow/SKILL.md +94 -317
  71. package/template/.agent/skills/tdd-workflow/references/typescript.md +231 -0
  72. package/template/.agent/skills/testing-strategist/SKILL.md +74 -687
  73. package/template/.agent/skills/testing-strategist/references/typescript.md +328 -0
  74. package/template/.agent/skills/workflow-automation/SKILL.md +62 -154
  75. package/template/.agent/skills/workflow-automation/references/inngest.md +88 -0
  76. package/template/.agent/skills/workflow-automation/references/temporal.md +64 -0
  77. package/template/.agent/workflows/bootstrap-agents-fill.md +85 -143
  78. package/template/.agent/workflows/bootstrap-agents-provision.md +90 -107
  79. package/template/.agent/workflows/create-prd-architecture.md +23 -16
  80. package/template/.agent/workflows/create-prd-compile.md +11 -12
  81. package/template/.agent/workflows/create-prd-design-system.md +1 -1
  82. package/template/.agent/workflows/create-prd-security.md +9 -11
  83. package/template/.agent/workflows/create-prd-stack.md +10 -4
  84. package/template/.agent/workflows/create-prd.md +9 -9
  85. package/template/.agent/workflows/decompose-architecture-structure.md +4 -6
  86. package/template/.agent/workflows/decompose-architecture-validate.md +18 -1
  87. package/template/.agent/workflows/decompose-architecture.md +18 -3
  88. package/template/.agent/workflows/evolve-contract.md +11 -11
  89. package/template/.agent/workflows/evolve-feature-classify.md +14 -6
  90. package/template/.agent/workflows/ideate-discover.md +72 -107
  91. package/template/.agent/workflows/ideate-extract.md +84 -63
  92. package/template/.agent/workflows/ideate-validate.md +26 -22
  93. package/template/.agent/workflows/ideate.md +9 -9
  94. package/template/.agent/workflows/implement-slice-setup.md +25 -23
  95. package/template/.agent/workflows/implement-slice-tdd.md +73 -89
  96. package/template/.agent/workflows/implement-slice.md +4 -4
  97. package/template/.agent/workflows/plan-phase-preflight.md +6 -2
  98. package/template/.agent/workflows/plan-phase-write.md +6 -8
  99. package/template/.agent/workflows/remediate-pipeline-assess.md +2 -1
  100. package/template/.agent/workflows/resolve-ambiguity.md +2 -2
  101. package/template/.agent/workflows/update-architecture-map.md +22 -5
  102. package/template/.agent/workflows/validate-phase-quality.md +155 -0
  103. package/template/.agent/workflows/validate-phase-readiness.md +167 -0
  104. package/template/.agent/workflows/validate-phase.md +19 -157
  105. package/template/.agent/workflows/verify-infrastructure.md +10 -10
  106. package/template/.agent/workflows/write-architecture-spec-design.md +23 -14
  107. package/template/.agent/workflows/write-be-spec-classify.md +25 -21
  108. package/template/.agent/workflows/write-be-spec.md +1 -1
  109. package/template/.agent/workflows/write-fe-spec-classify.md +6 -12
  110. package/template/.agent/workflows/write-fe-spec-write.md +1 -1
  111. package/template/AGENTS.md +6 -2
  112. package/template/GEMINI.md +5 -3
  113. package/template/docs/README.md +10 -10
  114. package/template/docs/kit-architecture.md +126 -33
  115. package/template/docs/plans/ideation/README.md +8 -3
  116. package/template/.agent/skills/prd-templates/references/ideation-domain-template.md +0 -55
@@ -17,7 +17,7 @@ pipeline:
17
17
 
18
18
  Execute the TDD cycle (Red → Green → Refactor), run validation, handle synthesis, and update all progress tracking files.
19
19
 
20
- **Prerequisite**: Contract (Zod schema) must be written (from `/implement-slice-setup` or equivalent). If in parallel mode, QA-RED and BE/FE/QA-GREEN dispatch should be completed during setup.
20
+ **Prerequisite**: Contract ({{CONTRACT_LIBRARY}} schema) must be written (from `/implement-slice-setup` or equivalent). If in parallel mode, QA-RED and BE/FE/QA-GREEN dispatch should be completed during setup.
21
21
 
22
22
  ---
23
23
 
@@ -26,153 +26,137 @@ Execute the TDD cycle (Red → Green → Refactor), run validation, handle synth
26
26
  Read .agent/skills/tdd-workflow/SKILL.md and follow its methodology.
27
27
  Read .agent/skills/clean-code/SKILL.md and follow its methodology.
28
28
  Read .agent/skills/systematic-debugging/SKILL.md and follow its methodology.
29
- Read .agent/skills/{{LANGUAGE_SKILL}}/SKILL.md and follow its language conventions.
30
- Read .agent/skills/{{UNIT_TESTING_SKILL}}/SKILL.md and follow its test writing conventions.
31
- Read .agent/skills/{{E2E_TESTING_SKILL}}/SKILL.md and follow its E2E test conventions.
29
+ Determine which surface this slice belongs to from the phase plan or slice path. Read the surface stack map from `.agent/instructions/tech-stack.md`.
32
30
 
33
- Cross-reference **all three** sources — acceptance criteria from the phase plan, the Zod contract from step 2, AND IA edge cases traced through the BE Source Map:
31
+ Load the Languages, Unit Tests, and E2E Tests skill(s) from this slice's surface row per the skill loading protocol (`.agent/skills/prd-templates/references/skill-loading-protocol.md`).
32
+
33
+ Cross-reference **all three** sources — acceptance criteria from the phase plan, the {{CONTRACT_LIBRARY}} contract from step 2, AND IA edge cases traced through the BE Source Map:
34
34
  1. Write a test for each acceptance criterion
35
35
  2. Write a test for each contract field, error type, and validation rule not already covered by criteria
36
- 3. For each endpoint in this slice, read the IA shard section(s) cited in that endpoint's BE spec `## Source Map`. Extract every item from the IA shard's `## Edge Cases` section that is relevant to the endpoint(s) under test. Write a failing test for each uncovered edge case. Tag these tests with `// IA-EDGE: [IA §X.Y — description]` so QA-GREEN can audit traceability.
36
+ 3. For each endpoint, read the IA shard section(s) cited in the BE spec `## Source Map`. Extract every relevant `## Edge Cases` item. Write a failing test for each, tagged `// IA-EDGE: [IA §X.Y — description]`
37
37
  4. Run all tests — they MUST fail
38
38
  5. Commit the failing tests
39
39
 
40
- **Test order**: Unit Integration E2E (if applicable)
40
+ Read `.agent/skills/prd-templates/references/tdd-testing-policy.md` and apply its **Assertion Depth Rule** and **Anti-Mock-Abuse Rules** to all tests written above.
41
41
 
42
42
  > **In parallel mode**, this step is handled by the `QA` agent dispatch in step 1.5.
43
- > In sequential mode, the orchestrator handles it directly.
44
43
 
45
- Run `{{TEST_COMMAND}}` to verify tests fail.
44
+ Run the Test Cmd from this slice's surface row in the surface stack map to verify tests fail.
46
45
 
47
46
  ## 4. Implement (GREEN)
48
47
 
49
- Read .agent/skills/{{LANGUAGE_SKILL}}/SKILL.md and follow its language conventions.
48
+ Load the Languages skill(s) from this slice's surface row per the skill loading protocol.
50
49
 
51
- Write the minimum code to make all tests pass:
50
+ Write the simplest *correct* implementation to make all tests pass. "Minimal" means no unnecessary abstractions — it does **NOT** mean skipping error handling, input validation, logging, or edge cases that the spec defines:
52
51
  1. Database schema/migration
53
52
  2. API endpoint handler
54
53
  3. Business logic
55
54
  4. UI component
56
55
 
57
- **If in parallel mode**: Each agent claims its task via the **Parallel Claim Protocol** (`.agent/skills/session-continuity/protocols/09-parallel-claim.md`) — marking `[!]`, writing `files:` list, and working through subtasks. Agents release claims on completion.
58
-
59
- **Before using any stub or placeholder**, apply the three-part test from the
60
- `boundary-not-placeholder` rule:
61
- - Does the spec exist? → Implement it. No stub.
62
- - Could you write the spec now? → Write the spec first, then implement.
63
- - Information genuinely doesn't exist? → `BOUNDARY:` stub with typed interface, tracking issue, and sentinel test.
56
+ **If in parallel mode**: Each agent claims its task via the **Parallel Claim Protocol** (`.agent/skills/session-continuity/protocols/09-parallel-claim.md`).
64
57
 
65
- > **"This is a lot of work" is not a valid boundary.** Amount of work, task
66
- > scope, and complexity are never reasons to stub. Only missing information is.
58
+ **Before using any stub or placeholder**, apply the three-part test from the `boundary-not-placeholder` rule. Only missing information is a valid boundary amount of work, scope, and complexity are never reasons to stub.
67
59
 
68
- **Spec traceability**: if you make any implementation decision not explicitly covered by the spec or contract (e.g., choosing enum values, default behaviors, retry counts, timeout durations, error messages), annotate it with `// DECISION: [what was decided and why]`. QA will audit these.
60
+ **Spec traceability**: Annotate any implementation decision not covered by the spec with `// DECISION: [what was decided and why]`. QA will audit these.
69
61
 
70
- Run `{{TEST_COMMAND}}` to verify tests pass.
62
+ > **Decision recording**: For decisions with ripple effects (touching other components, changing contracts, setting precedent), read `.agent/skills/session-continuity/protocols/06-decision-analysis.md` and follow the **Decision Effect Analysis Protocol**. Isolated decisions don't need this — only decisions where changing it later requires editing more than the current file.
71
63
 
72
- ## 4.1. Debug cycle (if tests fail after initial implementation)
64
+ Run the Test Cmd to verify tests pass.
73
65
 
74
- If `{{TEST_COMMAND}}` shows failures after completing Step 4:
66
+ ## 4.1. Debug cycle (if tests fail)
75
67
 
76
- Read .agent/skills/systematic-debugging/SKILL.md and follow its ACH methodology.
77
- Read .agent/skills/parallel-debugging/SKILL.md if failures span multiple subsystems.
68
+ Read `.agent/skills/systematic-debugging/SKILL.md` and follow its ACH methodology. Read `.agent/skills/parallel-debugging/SKILL.md` if failures span multiple subsystems.
78
69
 
79
- 1. Classify failures: contract mismatch vs logic error vs integration issue
80
- 2. For contract mismatches: re-read the BE spec — is the contract wrong or the implementation?
81
- 3. For logic errors: apply ACH (Analysis of Competing Hypotheses) per the debugging skill
82
- 4. For integration issues: check cross-surface wiring, env vars, service connectivity
83
- 5. Maximum 3 debug iterations before escalating to user with findings
70
+ 1. Classify: contract mismatch vs logic error vs integration issue
71
+ 2. Contract mismatch re-read BE spec — contract wrong or implementation?
72
+ 3. Logic error ACH per debugging skill
73
+ 4. Integration issue check cross-surface wiring, env vars, service connectivity
74
+ 5. Maximum 3 iterations before escalating to user
84
75
 
85
- Run `{{TEST_COMMAND}}` after each debug iteration to verify progress.
76
+ Run the Test Cmd after each iteration.
86
77
 
87
78
  ## 4.5. New dependency check
88
79
 
89
- After making all tests pass (GREEN), scan the new imports introduced in the implementation files.
80
+ After GREEN, scan new imports. If any package lacks a corresponding skill directory in `.agent/skills/`:
81
+ 1. Identify the stack category (e.g., `QUEUE`, `CACHE`, `SEARCH`)
82
+ 2. Read `.agent/workflows/bootstrap-agents.md` and fire bootstrap with `PIPELINE_STAGE=implement-slice` + the key-value pair
83
+ 3. Confirm skill installed before proceeding to REFACTOR
90
84
 
91
- If any package or module was introduced that does **not** have a corresponding skill directory in `.agent/skills/`:
92
- 1. Identify the stack category (e.g., `QUEUE`, `CACHE`, `SEARCH`, `STORAGE`, `REALTIME`)
93
- 2. Read `.agent/workflows/bootstrap-agents.md` and fire bootstrap with `PIPELINE_STAGE=implement-slice` + the key-value pair (e.g., `NEW_DEPENDENCY=[package-name]`)
94
- 3. Confirm the matching skill is installed before proceeding to REFACTOR
95
-
96
- If no new unregistered dependencies were introduced, skip and proceed to Step 5.
85
+ No new unregistered dependencies skip to Step 5.
97
86
 
98
87
  ## 5. Refactor
99
88
 
100
- With tests green, improve code quality:
101
- - Extract shared logic
102
- - Improve naming
103
- - Remove duplication
104
- - Add documentation
89
+ With tests green, improve code quality: extract shared logic, improve naming, remove duplication, add documentation.
105
90
 
106
- Read `.agent/skills/code-review-pro/SKILL.md` and apply its adversarial review: "How would a senior engineer reject this in a PR review?" Fix issues before running tests.
91
+ Read `.agent/skills/code-review-pro/SKILL.md` and apply its adversarial review: "How would a senior engineer reject this in a PR review?"
107
92
 
108
- **Spec traceability check**: Re-read the BE spec and IA shard sections for this slice. Verify every Zod contract field maps to a BE spec field. Verify every `// IA-EDGE:` tagged test's edge case is covered by the implementation, not just tested. Fix any spec drift before proceeding.
93
+ **Spec traceability check**: Re-read the BE spec and IA shard for this slice. Verify every contract field maps to a BE spec field and every `// IA-EDGE:` test's edge case is covered by the implementation. Fix spec drift before proceeding.
109
94
 
110
- Run `{{TEST_COMMAND}}` to verify tests still pass after refactor.
95
+ Run the Test Cmd to verify tests still pass.
111
96
 
112
- ## 6. Validate
97
+ ### 5.5. Query optimization check
113
98
 
114
- Read .agent/skills/verification-before-completion/SKILL.md and apply its evidence-before-claims discipline.
99
+ For each database query introduced or modified in this slice:
115
100
 
116
- Run the full validation suite: `{{VALIDATION_COMMAND}}`.
101
+ 1. **N+1 detection**: Review all data-fetching code for loop-based queries. If a query inside a loop fetches related data that could be eagerly loaded or batched, flag as an N+1 pattern and fix using the installed ORM/DB skill's recommended approach (e.g., `include` for Prisma, `with` for Drizzle, JOIN for raw SQL, graph traversal for SurrealDB)
102
+ 2. **Index coverage**: For each new WHERE clause, ORDER BY, or JOIN condition, verify a supporting index exists in the migration/schema. If no index exists and the table is expected to exceed 10,000 rows, add one
103
+ 3. **Query plan verification** (if test DB is available): Run EXPLAIN ANALYZE (or equivalent) on queries targeting tables with >1,000 rows in seed data. Flag any sequential scan on a table expected to grow beyond 10,000 rows
117
104
 
118
- All must pass before the slice is complete.
105
+ If `docs/plans/ENGINEERING-STANDARDS.md` defines `### DB Query Time` budgets, annotate each new query with its expected tier in a code comment: `// DB-TIER-2: uncached read, p95 target < 50ms`
119
106
 
120
- ## 6.5. Synthesis (parallel mode only)
107
+ ### 5.6. Resource cleanup verification
121
108
 
122
- **Skip this step if not in parallel mode.**
109
+ Review all new code in this slice for resource acquisition patterns. For each resource acquired, verify matching cleanup exists:
123
110
 
124
- Read `.agent/skills/session-continuity/protocols/11-parallel-synthesis.md` and follow its full procedure write synthesis plan, resolve stubs, wire integrations, run `{{VALIDATION_COMMAND}}`.
111
+ | Resource Type | Required Cleanup | Example |
112
+ |--------------|-----------------|---------|
113
+ | DB connection/client | `disconnect()`/`close()` in `finally` | Prisma `$disconnect()`, pg `pool.end()` |
114
+ | Event listener | `removeEventListener()` or equivalent on unmount/destroy | React `useEffect` cleanup return |
115
+ | Subscription | `unsubscribe()`/`kill()` on unmount/destroy | RxJS, SurrealDB live queries, WebSocket |
116
+ | Timer (interval/timeout) | `clearInterval()`/`clearTimeout()` | Polling loops, debounce timers |
117
+ | File handle/stream | `close()`/`destroy()` | fs reads, HTTP response streams |
118
+ | Worker thread | `terminate()` | Web Workers, Node Worker Threads |
125
119
 
126
- ## 7. Update progress (Mandatory)
120
+ If any cleanup is missing, add it before proceeding. Run the Test Cmd after adding cleanup to verify tests still pass.
127
121
 
128
- **CRITICAL ANTI-HALLUCINATION RULE**: You MUST NOT skip the progress update. Agents routinely skip this step after validation passes.
122
+ ## 6. Validate
129
123
 
130
- Read `.agent/skills/session-continuity/protocols/03-progress-update.md` and follow **every step** in the protocol. You must physically open and edit each of the four file targets (slice file, phase file, index, memory) using your file editing tools.
124
+ Read `.agent/skills/verification-before-completion/SKILL.md` and apply its evidence-before-claims discipline.
131
125
 
132
- The protocol covers:
133
- - **7a**: Slice file — status, criteria, implementation notes, files changed
134
- - **7b**: Phase file — slice entry, sub-tasks, progress fraction, claim releases
135
- - **7c**: Index — overall percentage, phase row
136
- - **7d**: Memory — patterns and blockers
126
+ Run the Validation Cmd from this slice's surface row. At least one integration test per BE endpoint must hit a real test server + real test database and assert the full response body.
137
127
 
138
- ## 8. Completion Gate
128
+ All must pass before the slice is complete.
139
129
 
140
- Read .agent/skills/verification-before-completion/SKILL.md and apply its evidence-before-claims discipline.
130
+ ## 6.5. Synthesis (parallel mode only)
141
131
 
142
- ### UI Completeness Check (FE slices only)
132
+ **Skip if not in parallel mode.**
143
133
 
144
- - [ ] (FE slices only) Every acceptance criterion mentioning "user sees", "user can", "displays", or "shows" has a rendered implementation — not just a passing test
145
- - [ ] (FE slices only) Every new route in this slice is wired into the app's navigation (not just exported as a component)
146
- - [ ] (FE slices only) Loading, error, and empty states are rendered in the UI — not just covered by tests
147
- - [ ] (FE slices only) The feature is reachable from the app's entry point via normal user navigation
134
+ Read `.agent/skills/session-continuity/protocols/11-parallel-synthesis.md` and follow its full procedure.
148
135
 
149
- These items apply only when the slice is tagged `FE`. Non-FE slices skip this block.
136
+ ## 7. Update progress (Mandatory)
150
137
 
151
- ### Spec Traceability Gate (all slices)
138
+ **CRITICAL**: You MUST NOT skip progress updates. Read `.agent/skills/session-continuity/protocols/03-progress-update.md` and follow **every step** — physically edit all four file targets (slice, phase, index, memory).
152
139
 
153
- Before calling `notify_user`, verify:
140
+ ## 8. Completion Gate
154
141
 
155
- - [ ] Re-read the BE spec section(s) for every endpoint in this slice — every response field, error code, and validation rule has a corresponding test tagged with the spec reference
156
- - [ ] Re-read the IA shard's `## Edge Cases` section for this slice's domain — every edge case relevant to this slice has a `// IA-EDGE:` tagged test
157
- - [ ] No `// DECISION:` annotations exist for behaviors that are actually specified in the BE spec or IA shard (i.e., no spec-defined behavior was treated as an undocumented implementation decision)
158
- - [ ] The Zod contract written in Step 2 matches the delivered implementation field-for-field — no fields added, removed, or renamed during implementation without a corresponding contract update
142
+ Read `.agent/skills/verification-before-completion/SKILL.md` and apply its discipline.
159
143
 
160
- > ❌ STOP — Do not call `notify_user` if any of the above are unchecked. Fix the gap and re-run `{{TEST_COMMAND}}`.
144
+ Read `.agent/skills/prd-templates/references/slice-completion-gates.md` and verify every applicable checklist passes:
145
+ - **UI Completeness Check** — FE slices only
146
+ - **Spec Traceability Gate** — all slices
161
147
 
162
- You may not call `notify_user` until you have edited all four file targets above (7a–7d).
148
+ Read `.agent/skills/prd-templates/references/tdd-testing-policy.md` and run the **QA Anti-Cheat Audit** checklist.
163
149
 
164
- Verify your edits by reading each of the following files:
165
- - Read `.agent/progress/slices/phase-NN-slice-NN.md` — must show Status: complete and [x] criteria
166
- - Read `.agent/progress/phases/phase-NN.md` — search for "Progress" and verify it shows the incremented fraction
167
- - Read `.agent/progress/index.md` — search for "Overall" and verify it shows the new overall percentage
150
+ You may not call `notify_user` until you have edited all four progress file targets (7a–7d).
168
151
 
169
- Replace `NN` with the actual phase and slice numbers you just completed.
152
+ Verify your edits by reading:
153
+ - `.agent/progress/slices/phase-NN-slice-NN.md` — Status: complete, [x] criteria
154
+ - `.agent/progress/phases/phase-NN.md` — incremented progress fraction
155
+ - `.agent/progress/index.md` — updated overall percentage
170
156
 
171
157
  Your `notify_user` payload **MUST** include:
172
- 1. The raw output from the three commands above.
173
- 2. The updated overall progress (e.g., "Overall progress is now 75% (24/32 slices)").
174
- 3. The explicit next command: Run `/implement-slice` for [next slice name].
175
-
176
- If any command output shows unchecked criteria, a stale fraction, or a missing file, you have failed the workflow.
158
+ 1. Raw output from the three reads above
159
+ 2. Updated overall progress (e.g., "Overall progress is now 75% (24/32 slices)")
160
+ 3. Explicit next command: Run `/implement-slice` for [next slice name]
177
161
 
178
- **Infrastructure/Auth slice gate**: After completing progress tracking, check the slice name against the phase plan. If this was the `00-infrastructure` slice or the auth slice, the next command to run is `/verify-infrastructure`, not `/implement-slice`. Do not propose the next feature slice until `/verify-infrastructure` passes and produces a green report in `docs/audits/`.
162
+ **Infrastructure/Auth slice gate**: If this was the `00-infrastructure` or auth slice, the next command is `/verify-infrastructure`, not `/implement-slice`.
@@ -6,7 +6,7 @@ pipeline:
6
6
  predecessors: [plan-phase]
7
7
  successors: [validate-phase]
8
8
  loop: true # repeats per slice within a phase
9
- skills: [clean-code, code-review-pro, parallel-agents, parallel-debugging, parallel-feature-development, session-continuity, systematic-debugging, tdd-workflow, verification-before-completion]
9
+ skills: [clean-code, code-review-pro, minimalist-surgical-development, parallel-agents, parallel-debugging, parallel-feature-development, session-continuity, systematic-debugging, tdd-workflow, verification-before-completion]
10
10
  calls-bootstrap: true # may discover new dependencies during implementation
11
11
  shards: [implement-slice-setup, implement-slice-tdd]
12
12
  ---
@@ -35,7 +35,7 @@ Implement a single vertical slice using strict TDD: Red → Green → Refactor.
35
35
 
36
36
  ### Step A — Run `.agent/workflows/implement-slice-setup.md`
37
37
 
38
- Checks progress state and session continuity, loads all bundled skills, reads the slice acceptance criteria, determines if parallel mode applies, and writes the contract (Zod schema). If parallel mode is detected, dispatches agents for the TDD cycle.
38
+ Checks progress state and session continuity, loads all bundled skills, reads the slice acceptance criteria, determines if parallel mode applies, and writes the contract ({{CONTRACT_LIBRARY}} schema). If parallel mode is detected, dispatches agents for the TDD cycle.
39
39
 
40
40
  ### Step B — Run `.agent/workflows/implement-slice-tdd.md`
41
41
 
@@ -46,7 +46,7 @@ Executes the TDD cycle (RED: write failing tests → GREEN: implement → REFACT
46
46
  ## Quality Gate
47
47
 
48
48
  You may not call `notify_user` until:
49
- - [ ] All tests pass (`{{TEST_COMMAND}}`)
50
- - [ ] Full validation passes (`{{VALIDATION_COMMAND}}`)
49
+ - [ ] All tests pass (Test Cmd from surface stack map)
50
+ - [ ] Full validation passes (Validation Cmd from surface stack map)
51
51
  - [ ] All 4 progress tracking files updated (slice, phase, index, memory)
52
52
  - [ ] Each tracking file verified by re-reading after edit
@@ -50,7 +50,7 @@ Read these skills for slice planning guidance:
50
50
 
51
51
  ## 0.5. Application Completeness Audit
52
52
 
53
- Read `{{SURFACES}}` from `.agent/instructions/tech-stack.md`. For each row below, only run the check if "Applies To" matches the project's confirmed surfaces. Skip inapplicable rows.
53
+ Read the **Surfaces** list from the Global Settings section of `.agent/instructions/tech-stack.md`. For each row below, only run the check if "Applies To" matches the project's confirmed surfaces. Skip inapplicable rows.
54
54
 
55
55
  Read all FE specs in `docs/plans/fe/` and check the following table.
56
56
 
@@ -106,14 +106,18 @@ Do not proceed until the user confirms all uncovered specs are resolved.
106
106
 
107
107
  ### 0.6b. Cross-Layer Field and Contract Consistency
108
108
 
109
- Using the `cross-layer-consistency` skill's methodology, verify:
109
+ Using the `cross-layer-consistency` skill's methodology as a guide, verify the following **minimum checks** regardless of skill depth:
110
110
 
111
111
  1. **Field mapping**: For every BE response field consumed by an FE component, verify the field name, type, and nullability match exactly between the BE spec and FE spec.
112
112
  2. **Error code propagation**: For every error code defined in a BE spec, verify the corresponding FE spec documents how that error is displayed to the user.
113
113
  3. **Access control consistency**: For every RBAC role referenced in a BE spec's access control, verify the FE spec's conditional rendering matrix includes that role.
114
+ 4. **Data contract drift**: For every IA shard entity, verify that the BE spec's request/response schemas contain all fields defined in the IA shard's data model — no fields silently dropped or renamed.
115
+ 5. **State management consistency**: For every FE component that manages optimistic updates, verify the corresponding BE endpoint's error response is specified well enough for the FE to roll back.
114
116
 
115
117
  Collect all mismatches into a consistency report. If any exist → **hard stop** and present them to the user for resolution before proceeding.
116
118
 
119
+ > These 5 checks are **non-negotiable minimums**. The `cross-layer-consistency` skill may define additional checks — run those too, but never skip these 5 even if the skill doesn't mention them.
120
+
117
121
  ---
118
122
 
119
123
  ## 0.8. Draft continuity check
@@ -53,9 +53,9 @@ Read .agent/skills/concise-planning/SKILL.md and follow its methodology.
53
53
  Sort slices so each builds on the last:
54
54
  - Infrastructure slices first (DB schema, auth middleware)
55
55
 
56
- **Phase 1 special rule**: Before applying this rule, verify that `{{CI_CD_SKILL}}` and `{{HOSTING_SKILL}}` contain filled values (no literal `{{` characters). If unfilled, emit a **HARD STOP**: these placeholders are filled by `/create-prd-stack` — run it first.
56
+ **Phase 1 special rule**: Before applying this rule, read the surface stack map from `.agent/instructions/tech-stack.md` and verify that the **CI/CD** and **Hosting** cross-cutting categories have filled values. If empty, emit a **HARD STOP**: these are filled by `/create-prd-stack` — run it first.
57
57
 
58
- The `00-infrastructure` shard is always the first slice. Verify it covers: (1) CI/CD pipeline setup — read `.agent/skills/{{CI_CD_SKILL}}/SKILL.md`, (2) environment configuration (`.env.example`), (3) deployment pipeline — read `.agent/skills/{{HOSTING_SKILL}}/SKILL.md`, (4) project scaffolding from `.agent/instructions/structure.md` (directories, `README.md` files, base configs), (5) database initialization. Add missing items before proceeding.
58
+ The `00-infrastructure` shard is always the first slice. Verify it covers: (1) CI/CD pipeline setup — read the CI/CD skill(s) from the cross-cutting section of the surface stack map, (2) environment configuration (`.env.example`), (3) deployment pipeline — read the Hosting skill(s) from the cross-cutting section of the surface stack map, (4) project scaffolding from `.agent/instructions/structure.md` (directories, `README.md` files, base configs), (5) database initialization. Add missing items before proceeding.
59
59
 
60
60
  **Verification gates** (hard gates — add explicitly to the phase plan):
61
61
  - `/verify-infrastructure` MUST pass after the infrastructure slice, before any feature slice.
@@ -96,14 +96,12 @@ Read `.agent/skills/session-continuity/protocols/02-progress-generation.md` and
96
96
  ## 6.5. Bootstrap Completeness Gate
97
97
 
98
98
  Scan these four files for literal `{{` occurrences of `LANGUAGE_SKILL`, `HOSTING_SKILL`, `CI_CD_SKILL`, `ORM_SKILL`, `UNIT_TESTING_SKILL`, `E2E_TESTING_SKILL`:
99
- - `.agent/workflows/implement-slice-setup.md`
100
- - `.agent/workflows/implement-slice-tdd.md`
101
- - `.agent/workflows/verify-infrastructure.md`
102
- - `.agent/workflows/validate-phase.md`
103
99
 
104
- For each unfilled placeholder, read `docs/plans/*-architecture-design.md` to extract the confirmed value, then run `/bootstrap-agents` (see `.agent/workflows/bootstrap-agents.md`) with the corresponding key.
100
+ > **Note**: As of v3, these files no longer contain literal `{{` placeholders they reference the surface stack map. This gate now verifies that the surface stack map itself is fully populated for all surfaces involved in this phase.
105
101
 
106
- > STOP Re-scan the four files. Only proceed to Step 7 when zero `{{` patterns remain. If any remain unfilled after bootstrap, tell the user which placeholders could not be provisioned.
102
+ Read the surface stack map from `.agent/instructions/tech-stack.md`. Verify all per-surface and cross-cutting cells are filled. Verify `.agent/instructions/commands.md` has non-template values.
103
+
104
+ > ❌ STOP — Only proceed to Step 7 when the map is fully populated. If any cells are empty after bootstrap, tell the user which cells could not be provisioned.
107
105
 
108
106
  ## 7. Request review and next steps
109
107
 
@@ -71,7 +71,7 @@ Check which layers have content by verifying the presence of key files:
71
71
 
72
72
  | Layer | Key Files to Check | Has Content If… |
73
73
  |-------|-------------------|-------------------|
74
- | Ideation | `docs/plans/ideation/ideation-index.md` | File exists and domains at `[DEEP]`+ |
74
+ | Ideation | `docs/plans/ideation/ideation-index.md` | File exists, ≥1 domain folder under `domains/` (or `surfaces/`) with `*-index.md` + `*-cx.md`, and domains at `[DEEP]`+ in Structure Map |
75
75
  | Architecture | `docs/plans/*-architecture-design.md` | At least one dated file exists |
76
76
  | IA | `docs/plans/ia/index.md` | File exists with ≥1 shard listed |
77
77
  | BE | `docs/plans/be/index.md` | File exists with ≥1 spec listed |
@@ -80,6 +80,7 @@ Check which layers have content by verifying the presence of key files:
80
80
  For each layer with content, also note:
81
81
  - How many documents it contains (shards/specs count)
82
82
  - Whether any deep dive files exist (IA layer only)
83
+ - For ideation: count of domain folders, total feature files, and CX files across the fractal tree
83
84
 
84
85
  ---
85
86
 
@@ -18,7 +18,7 @@ Targeted ambiguity resolution for any pipeline document or layer. Uses the `reso
18
18
  | Invocation | Behavior |
19
19
  |---|---|
20
20
  | `/resolve-ambiguity` | Interactive — asks which document or layer to resolve |
21
- | `/resolve-ambiguity ideation` | Targets `docs/plans/ideation/ideation-index.md` + domain files |
21
+ | `/resolve-ambiguity ideation` | Targets `ideation-index.md` + `ideation-cx.md` + all fractal tree files |
22
22
  | `/resolve-ambiguity architecture` | Targets the architecture design documents |
23
23
  | `/resolve-ambiguity @path/to/spec.md` | Targets a specific file |
24
24
 
@@ -29,7 +29,7 @@ Targeted ambiguity resolution for any pipeline document or layer. Uses the `reso
29
29
  If no argument was provided, ask the user which document or layer to resolve. Accept a layer name (`vision`, `architecture`, `ia`, `be`, `fe`) or a direct `@file` path.
30
30
 
31
31
  For layer names, resolve to the canonical document(s):
32
- - `ideation` → `docs/plans/ideation/ideation-index.md` + all domain files in `docs/plans/ideation/domains/`
32
+ - `ideation` → `docs/plans/ideation/ideation-index.md` + `ideation-cx.md` + all `*-index.md`, `*-cx.md`, and feature `.md` files recursively under `domains/` (and `surfaces/` for multi-product projects)
33
33
  - `architecture` → `docs/plans/YYYY-MM-DD-architecture-design.md` + `docs/plans/ENGINEERING-STANDARDS.md` + `docs/plans/data-placement-strategy.md`
34
34
  - `ia` → all files in `docs/plans/ia/` (excluding `index.md`)
35
35
  - `be` → all files in `docs/plans/be/` (excluding `index.md`)
@@ -39,7 +39,7 @@ Analyze the project structure using file exploration tools. Do not just stop at
39
39
  Read .agent/skills/architecture-mapping/SKILL.md and follow its component analysis methodology.
40
40
 
41
41
  Group files logically into components, but extract their exact contracts:
42
- - Use `grep_search` to find `z.object` or `interface` definitions.
42
+ - Use `grep_search` to find contract/validation schema definitions. Search for patterns appropriate to the project's contract library (e.g., `z.object` for Zod, `BaseModel` for Pydantic, `Joi.object` for Joi, `schema(` for Yup, `struct` for Rust/Go, or `interface`/`type` definitions for TypeScript). Check `.agent/instructions/tech-stack.md` for the project's confirmed contract library if unsure.
43
43
  - Document exact schema names, required environment variables, and binding names (e.g., KV namespaces, R2 buckets).
44
44
 
45
45
  ## 3. Map Explicit Data Flow and Relationships
@@ -65,10 +65,27 @@ Create or update `docs/ARCHITECTURE.md`.
65
65
 
66
66
  Ensure the document is human-readable, well-structured, and focuses on high-level system interactions rather than low-level functional documentation.
67
67
 
68
- ## 6. Present Results and Next Steps
68
+ ## 6. Phase completion gate
69
69
 
70
- Use `notify_user` to present a summary of the architecture map updates.
70
+ Read `docs/plans/*-architecture-design.md` **Phasing** section to determine the total number of planned phases.
71
+ Read `.agent/progress/index.md` to determine the current phase number N and how many phases have `status: complete`.
71
72
 
72
- ### Proposed next steps
73
+ ### If completed phases < total phases
73
74
 
74
- "Architecture map updated. Next: Run `/plan-phase` for the next phase, or if all phases are complete, the project is ready for deployment — refer to your CI/CD pipeline configuration and the deployment procedures documented in `docs/plans/ENGINEERING-STANDARDS.md`."
75
+ The pipeline has more phases to implement. Present:
76
+
77
+ > "Architecture map updated for Phase N. **Next**: Run `/plan-phase` for Phase [N+1]."
78
+
79
+ ### If completed phases = total phases
80
+
81
+ All phases are complete. The pipeline has reached its terminal state. Present:
82
+
83
+ > "✅ **All phases complete.** Architecture map updated. The project is ready for deployment.
84
+ >
85
+ > - Refer to `docs/plans/ENGINEERING-STANDARDS.md` for deployment procedures
86
+ > - Refer to your CI/CD pipeline configuration for automated deployment
87
+ > - Run `/validate-phase` for the final phase if not already done
88
+ >
89
+ > No further `/plan-phase` iterations are needed."
90
+
91
+ **Do NOT propose `/plan-phase` after the final phase.** The loop terminates here.
@@ -0,0 +1,155 @@
1
+ ---
2
+ description: Code quality gates — tests, coverage, lint, type-check, build, CI/CD, staging deploy, migrations, spec coverage for the validate-phase workflow
3
+ parent: validate-phase
4
+ shard: quality
5
+ standalone: true
6
+ position: 1
7
+ pipeline:
8
+ position: 8.1
9
+ stage: verification
10
+ predecessors: [implement-slice]
11
+ successors: [validate-phase-readiness]
12
+ skills: [code-review-pro, deployment-procedures, testing-strategist, verification-before-completion]
13
+ calls-bootstrap: false
14
+ ---
15
+
16
+ // turbo-all
17
+
18
+ # Validate Phase — Code Quality Gates
19
+
20
+ Run all code quality checks for a completed implementation phase.
21
+
22
+ ---
23
+
24
+ ## 0. Load validation skills
25
+
26
+ Read these skills before running checks:
27
+ 1. `.agent/skills/testing-strategist/SKILL.md` — Coverage strategy and test quality
28
+ 2. `.agent/skills/code-review-pro/SKILL.md` — Review checklist for self-audit
29
+ 3. `.agent/skills/deployment-procedures/SKILL.md` — Build and release readiness
30
+
31
+ ---
32
+
33
+ ## 0.5. Parallel dispatch option
34
+
35
+ If the phase contains independent slices that don't share files, validation can run in parallel:
36
+
37
+ 1. **Identify independent slices** — slices that don't import from or export to each other
38
+ 2. **Dispatch parallel validation** — run Steps 1–5 concurrently for independent slices using the `parallel-agents` skill
39
+ 3. **Sequential for shared** — slices that share contracts or utilities must validate sequentially
40
+
41
+ This is an optimization, not a requirement. Sequential validation is always correct.
42
+
43
+ ## 1. Run test suite
44
+
45
+ Run the Test Cmd from `.agent/instructions/commands.md`. All tests must pass. Zero tolerance.
46
+
47
+ ## 2. Check coverage
48
+
49
+ Run the Test Coverage Cmd from `.agent/instructions/commands.md`.
50
+
51
+ Read `docs/plans/ENGINEERING-STANDARDS.md` and use the coverage thresholds defined in the "Test Coverage" section. If the file doesn't exist or thresholds aren't defined, fall back to these defaults:
52
+ - Statements: 80%
53
+ - Branches: 90% (critical paths: auth, payments, data mutations, permission checks), 75% (non-critical paths)
54
+ - Functions: 80%
55
+ - Lines: 80%
56
+
57
+ Critical paths are defined as: auth flows, payment processing, data mutations, and permission/authorization checks.
58
+
59
+ ## 2.5. Mutation testing (critical paths)
60
+
61
+ **Optional but recommended.** If the project's test tooling supports mutation testing (e.g., Stryker for JS/TS, mutmut for Python, cargo-mutants for Rust):
62
+
63
+ 1. Run the mutation testing tool against critical path modules only (auth, payments, data mutations, permission checks)
64
+ 2. **Required**: Mutation score ≥ 70% on critical paths — if below, the tests are passing but not actually catching bugs
65
+ 3. **Recommended**: Mutation score ≥ 50% on non-critical paths — log as a finding but don't block
66
+
67
+ If mutation testing is not available in the project's tooling, skip and note in the validation report that mutation testing was not run.
68
+
69
+ ## 3. Lint
70
+
71
+ Run the Lint Cmd from the surface stack map.
72
+
73
+ Zero lint errors. Warnings should be reviewed and addressed.
74
+
75
+ ## 4. Type check
76
+
77
+ Run the Type Check Cmd from the surface stack map.
78
+
79
+ Zero type errors. Strict mode must be enabled.
80
+
81
+ ## 5. Build
82
+
83
+ Run the Build Cmd from the surface stack map.
84
+
85
+ Build must succeed with no errors.
86
+
87
+ ---
88
+
89
+ ## 5.5. CI/CD pipeline verification
90
+
91
+ Verify the CI/CD pipeline is green for this phase's changes:
92
+
93
+ 1. Check that a CI/CD configuration file exists (e.g., `.github/workflows/`, `.gitlab-ci.yml`)
94
+ 2. Verify the pipeline has run for the latest commit in this phase
95
+ 3. Verify ALL CI/CD jobs are passing (not just the test job — include lint, type-check, build, and any deployment jobs)
96
+
97
+ **If CI/CD is red** → red path: **STOP immediately.** Do not mark this phase as complete. List the failing jobs and their error output. Fix them and re-run `/validate-phase` after fixes.
98
+
99
+ **Pass criteria**: CI/CD pipeline is green for the latest commit in this phase.
100
+
101
+ ---
102
+
103
+ ## 5.6. Staging deployment gate
104
+
105
+ 1. Deploy to staging using `.agent/skills/deployment-procedures/SKILL.md`
106
+ 2. Verify deployment succeeded (no rollback triggered, no error logs in the deployment output)
107
+ 3. Run smoke tests against the staging environment:
108
+ - Health check endpoint returns 200
109
+ - At least one authenticated route works with a valid token
110
+ - At least one protected route returns 401/403 for unauthenticated requests
111
+ 4. **If smoke tests fail** → red path: Capture the failing test output, rollback the staging deployment, and fix the issue before re-running `/validate-phase`
112
+ 5. **If deployment fails** → red path: Do not mark this phase as complete — diagnose the deployment failure, fix it, and re-run `/validate-phase`
113
+
114
+ **Pass criteria**: Staging deployment succeeds and all smoke tests pass.
115
+
116
+ ---
117
+
118
+ ## 5.6.5. Deployment strategy verification
119
+
120
+ Read the project's architecture design document (`docs/plans/*-architecture-design.md`) and look for a `## Deployment Strategy` section.
121
+
122
+ **If no deployment strategy is defined** → Log: "No deployment strategy in architecture doc. Using direct deploy." Proceed.
123
+
124
+ **If a deployment strategy is defined**:
125
+ 1. Verify the deployment in Step 5.6 followed the documented strategy (e.g., canary → verify traffic was gradually shifted; blue-green → verify old environment is still available for rollback; rolling → verify instances were replaced sequentially)
126
+ 2. If the architecture documents feature flags as the rollout mechanism → verify the new features in this phase are behind flags
127
+ 3. Verify the documented rollback trigger mechanism is configured (error rate monitoring, latency threshold alert, or manual switch — whatever the architecture specifies)
128
+
129
+ **Pass criteria**: Deployment follows the architecture-documented strategy, or no strategy is documented.
130
+
131
+ ---
132
+
133
+ ## 5.7. Migration verification
134
+
135
+ 1. Run the migration status command (e.g., `prisma migrate status`, `drizzle-kit status`, or equivalent)
136
+ 2. Verify there are no pending migrations and no failed migrations
137
+ 3. Verify the CI/CD pipeline ran migrations successfully as part of this phase's deployment
138
+ 4. Check that rollback scripts exist for each migration in this phase
139
+ 5. If migrations are pending or failed → red path: do not mark this phase as complete — run the pending migrations, verify they succeed, and re-run `/validate-phase`
140
+
141
+ **Pass criteria**: Migration status is clean. All migrations from this phase ran successfully in the CI/CD environment. Rollback scripts are present.
142
+
143
+ ---
144
+
145
+ ## 5.8. Spec coverage sweep
146
+
147
+ Read `.agent/skills/prd-templates/references/spec-coverage-sweep.md` and follow its full procedure for FE spec, BE spec, and IA shard coverage. Apply its hard-stop rule for any uncovered items.
148
+
149
+ ---
150
+
151
+ ### Propose next step
152
+
153
+ Code quality gates complete. Next: Run `.agent/workflows/validate-phase-readiness.md` for production readiness checks.
154
+
155
+ > If this shard was invoked standalone (not from `/validate-phase`), surface this via `notify_user`.