1---
2name: integration-test-verify
3description: '[Testing] Use when you need to verify integration tests pass after writing and reviewing them.'
4metadata:
5 source: https://skillmd.com/skills/duc01226/integration-test-verify
6---
7
8> Codex compatibility note:
9>
10> - Invoke repository skills with `$skill-name` in Codex; this mirrored copy rewrites legacy Claude `/skill-name` references.
11> - Task tracker mandate: BEFORE executing any workflow or skill step, create/update task tracking for all steps and keep it synchronized as progress changes.
12> - User-question prompts mean to ask the user directly in Codex.
13> - Ignore Claude-specific mode-switch instructions when they appear.
14> - Strict execution contract: when a user explicitly invokes a skill, execute that skill protocol as written.
15> - Subagent authorization: when a skill is user-invoked or AI-detected and its protocol requires subagents, that skill activation authorizes use of the required `spawn_agent` subagent(s) for that task.
16> - Do not skip, reorder, or merge protocol steps unless the user explicitly approves the deviation first.
17> - For workflow skills, execute each listed child-skill step explicitly and report step-by-step evidence.
18> - If a required step/tool cannot run in this environment, stop and ask the user before adapting.
19
20<!-- CODEX:PROJECT-REFERENCE-LOADING:START -->
21
22## Codex Project-Reference Loading (No Hooks)
23
24Codex uses static project-reference loading instead of runtime-injected project docs.
25When coding, planning, debugging, testing, or reviewing, open project docs explicitly using this routing.
26
27**Always read:**
28
29- `docs/project-config.json` (project-specific paths, commands, modules, and workflow/test settings)
30- `docs/project-reference/docs-index-reference.md` (routes to the full `docs/project-reference/*` catalog)
31- `docs/project-reference/lessons.md` (always-on guardrails and anti-patterns)
32
33**Missing/stale context route:** If `docs/project-config.json`, the docs index, `lessons.md`, `CLAUDE.md`, `AGENTS.md`, or any task-required reference doc is missing or stale, auto-run `$project-init` or the narrow setup route (`$project-config`, `$docs-init`, `$scan-all`, `$scan --target=<key>`, `$claude-md-init`) before ordinary project-specific work. If Codex mirrors or `AGENTS.md` are missing/stale, ask the user to run `$sync-codex`; do not auto-run it.
34
35**Situation-based docs:**
36
37- Project structure/architecture/tech-stack/deployment/setup (any layer — backend, frontend, or infra): `project-structure-reference.md`
38- Backend/CQRS/API/domain/entity changes: `backend-patterns-reference.md`, `domain-entities-reference.md`
39- Frontend/UI/styling/design-system: `frontend-patterns-reference.md`, `scss-styling-guide.md`, `design-system/README.md`
40- Spec authoring, `docs/specs/` pathing, or TC format: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`
41- Behavior/public-contract changes or spec-test-code sync: `workflow-spec-test-code-cycle-reference.md` plus the spec docs above
42- Derived spec indexes/ERDs/reimplementation guides: `spec-system-reference.md` and source Feature Specs under `docs/specs/`
43- Integration test implementation/review: `integration-test-reference.md`
44- E2E test implementation/review: `e2e-test-reference.md`
45- Code review/audit work: `code-review-rules.md` plus domain docs above based on changed files
46
47Do not read all docs blindly. Start from `docs-index-reference.md`, then open only relevant files for the task.
48
49<!-- CODEX:PROJECT-REFERENCE-LOADING:END -->
50
51<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:START -->
52
53> **[BLOCKING]** Execute skill steps in declared order. NEVER skip, reorder, or merge steps without explicit user approval.
54> **[BLOCKING]** Before each step or sub-skill call, update task tracking: set `in_progress` when step starts, set `completed` when step ends.
55> **[BLOCKING]** Every completed/skipped step MUST include brief evidence or explicit skip reason.
56> **[BLOCKING]** If Task tools are unavailable, create and maintain an equivalent step-by-step plan tracker with the same status transitions.
57
58<!-- PROMPT-ENHANCE:STEP-TASK-ANCHOR:END -->
59
60## Quick Summary
61
62**Goal:** Prove the reviewed integration tests (written by `$integration-test`, reviewed by `$integration-test-review`) pass repeatably — 2 consecutive green runs without DB reset, using project-configured run commands, against an environment whose doc-declared preconditions were harvested and verified BEFORE the first test command — with every pass/fail claim backed by actual test-runner output, never assumption.
63
64**Summary:** read-this-if-nothing-else digest of the 5 main steps —
65
66- **Step 1 — Read config + reference docs FIRST, then HARVEST preconditions:** load `docs/project-config.json` → `integrationTestVerify` and obey its `quickRunCommand`; READ every `referenceDocs` file (else the project's integration-test reference doc) and harvest from it an explicit **Environment Precondition Checklist** — whatever that doc actually declares (services/containers, DB + migration/seed state, env vars, ports, credentials, startup script, isolation rules). Language-agnostic, so NEVER hardcode `dotnet test`; missing section → Fallback Mode. — why: reading the doc without extracting its preconditions changes nothing — the run still starts blind.
67- **Step 2 — Gate on a healthy system AND every harvested precondition:** run `systemCheckCommand` AND verify each checklist item against real evidence; any unmet → STOP, mark ENVIRONMENT-BLOCKED, name the precondition + the doc line declaring it, point user at `startupScript`. — why: `systemCheckCommand` covers only what the config author thought to encode, so a doc-declared precondition it misses becomes a red suite blamed on the tests.
68- **Step 3 — Determine test projects:** discover via `testProjectPattern` glob > `testProjects` list > git auto-detect; run only projects the change touches.
69- **Step 4 — Run the 2-run gate, fan out when many isolated projects:** each relevant suite passes 2 consecutive green runs WITHOUT DB reset; any failure restarts from run 1. When several independent, per-DB-isolated projects exist, fan out one `integration-tester` sub-agent per project/group in parallel → barrier on ALL returns → aggregate; suites sharing a DB run sequentially. — why: parallel runs over a shared DB cross-contaminate and silently break the no-reset guarantee.
70- **Step 5 — Report from real output, fix at root, hand failures to the loop:** report Passed/Failed/Skipped counts + failing names (only actual runner output proves a result); on failure diagnose test-bug vs service-bug and fix at the owning layer — NEVER weaken assertions, add skips, or mutate domain data to force green. ANY failure → recommend `$workflow-integration-test-green`, which owns the converge-to-green loop this skill does not (skip that recommendation when this run IS a round of that loop). — why: a snapshot that reports red and stops leaves the user hand-carrying every failure.
71
72**Workflow:**
73
741. **Read Config + Reference Docs** — Load `docs/project-config.json` → `integrationTestVerify`, read the project's integration-test reference docs, harvest the Environment Precondition Checklist
752. **System Check + Precondition Gate** — Verify the system is healthy AND every harvested precondition is met before running
763. **Determine Test Projects** — Discover via `testProjectPattern` glob, `testProjects` list, or git auto-detect
774. **Run Tests** — Execute `quickRunCommand` on determined test projects for 2 consecutive runs; fan out parallel `integration-tester` sub-agents when many isolated projects must run
785. **Report** — Pass/fail counts, failed test names, next steps on failure
79
80**Key Rules:**
81
82- MUST read project config `integrationTestVerify` section before doing anything else
83- MUST read project-specific reference docs named by `integrationTestVerify.referenceDocs` or the project's integration-test doc path before running tests
84- MUST harvest an explicit Environment Precondition Checklist from those docs — derive each item from what the doc declares, NEVER from a fixed list in this skill — and verify every item before the first test command
85- Use `quickRunCommand` from config — NEVER hardcode `dotnet test` or any language-specific command
86- If system check fails → instruct user how to start system (reference `startupScript` from config)
87- Any harvested precondition unmet → STOP, mark ENVIRONMENT-BLOCKED, cite the precondition + its doc line, and point the user at the setup step — NEVER run the suite anyway and NEVER report an environment failure as a failing test
88- If config says local infrastructure, databases, services, or full system startup is required, treat that as a blocking prerequisite
89- On test failure → diagnose root cause: test bug or service bug. NEVER weaken assertions.
90- ANY failing test at the end of the run → recommend `$workflow-integration-test-green` as the next step (it owns the converge-to-green loop); omit that recommendation when this run is itself a round of that loop
91- On an INTERMITTENT failure (red in one run, green in another) → adjudicate the cause first — (a) unrealistic scenario / compressed pacing, (b) harness topology amplification, or (c) genuine product race — and record the verdict with evidence BEFORE any change. NEVER resolve a flake by widening a timeout, adding a retry, or skipping
92- Verification only passes after 2 consecutive successful runs of each relevant suite/project without DB reset
93- When many independent, isolated test projects must run, fan out one `integration-tester` sub-agent per project (or balanced group) in parallel to speed it up — barrier on all returns, then aggregate; fall back to sequential when suites share a DB or aren't isolated
94- Always report exact failure counts and names — "all passed" requires evidence
95
96**Be skeptical. Apply critical thinking. Every pass/fail claim needs actual test runner output.**
97
98---
99
100## First Principle — Easy to Change
101
102> **The success metric of every coding decision is _future change cost_.**
103> DRY, SRP, abstraction, design patterns, naming, layering, tests — every
104> technique exists to serve one goal: **making the next change cheaper**.
105
106When evaluating code, refactor, test, or abstraction, ask:
107**does this make next change cheaper or more expensive?**
108
109- Reject "best practices" raising change cost (premature abstraction,
110 speculative generality, leaky indirection, ceremony without payoff).
111- Name real enemies in findings: **coupling, hidden state, duplicated
112 knowledge, unclear intent, irreversible decisions exposed too early**.
113- Simpler design easy to change beats sophisticated design that isn't.
114
115Apply this lens **before** invoking any specific rule, pattern, or checklist
116below — if downstream rule would raise change cost, this principle wins.
117
118---
119
120## Step 1: Read Project Config + Reference Docs
121
122Read `docs/project-config.json` and extract the `integrationTestVerify` section.
123
124```
125Expected config shape:
126{
127 "integrationTestVerify": {
128 "guidance": string — instructions for the project's test run approach
129 "referenceDocs": string[] — project docs that explain integration-test setup/run prerequisites
130 "quickRunCommand": string — test runner command (e.g., "dotnet test --no-build", "npm test", "pytest")
131 "testProjectPattern": string — glob pattern to discover test projects (e.g., "**/*.IntegrationTests.csproj", "**/*.integration.spec.ts")
132 "testProjects": string[] — explicit list of test project paths (fallback if no pattern)
133 "systemCheckCommand": string — shell command to check system readiness
134 "runScript": string — path to CI-style full run script (reference only)
135 "startupScript": string — path to system startup script (reference only)
136 }
137}
138```
139
140**Config priority:** `testProjectPattern` (auto-discovers via glob) > `testProjects` (explicit list) > git auto-detect (fallback).
141
142**If `integrationTestVerify` section is missing:** proceed to [Fallback Mode](#fallback-mode-no-project-config).
143
144**If section exists:** display the `guidance` value to the user verbatim — it contains project-specific instructions the implementer wrote intentionally.
145
146Then read the project-specific setup guidance before any system check or test command:
147
1481. Read every file listed in `integrationTestVerify.referenceDocs`, if present.
1492. If no `referenceDocs` list exists, read the integration-test reference doc indicated elsewhere in `docs/project-config.json` (for example a framework/testing integration test doc path), if present.
1503. If config names `runScript` or `startupScript`, read those scripts when needed to understand startup, health checks, arguments, or labels. Use them as project-specific evidence, not generic assumptions.
1514. If no project-specific reference exists, proceed only with the explicit config values and call out that the project should add reference docs to `integrationTestVerify`.
152
153### Step 1b: Harvest the Environment Precondition Checklist (BLOCKING — before any command)
154
155Reading the reference doc is not the point; **extracting what it requires of the environment** is. From the docs and scripts just read, derive an explicit checklist of every precondition the test run depends on, then carry it into Step 2.
156
157**Derive, never enumerate.** Take the items from what THIS project's doc actually declares — no fixed list here would survive a different stack. Typical shapes the doc may state: required services/containers up and healthy · database reachable, migrated, and seeded to a known baseline · message broker / queue / cache running · env vars, connection strings, ports, credentials, certificates · a startup or bootstrap script that must run first · build/restore performed before the run · per-suite isolation (own DB/schema/namespace) · required test data or fixtures · external dependency stubs.
158
159Record it as a table before proceeding:
160
161```
162### Environment Precondition Checklist (harvested)
163
164| # | Precondition | Declared by (doc:line / script) | How to verify | Status |
165|---|--------------|---------------------------------|---------------|--------|
166| 1 | {what must be true} | {file:line} | {command / observable} | PENDING |
167```
168
169Rules:
170
171- MUST cite `file:line` (or script path) for every harvested item — an item with no source is an assumption, not a precondition.
172- No reference doc found, or the doc declares no environment prerequisites → record `No environment preconditions declared — proceeding on config values only` and say which doc was checked. NEVER invent preconditions to fill the table — why: a fabricated prerequisite blocks a healthy run and trains the user to ignore the gate.
173- A precondition you cannot verify by any command or observable is still recorded, marked `UNVERIFIABLE`, and surfaced to the user — why: an unverifiable prerequisite is a gap in the project's doc, not a reason to skip the gate.
174
175---
176
177## Step 2: System Check + Environment Precondition Gate
178
179**If `systemCheckCommand` exists in config:**
180
181Run the system check via Bash:
182
183```bash
184{systemCheckCommand}
185```
186
187Evaluate output:
188
189- **Healthy** → proceed to the precondition gate below
190- **Partially healthy / no containers** → display startup instructions to user: > "System not fully ready. To start: run `{startupScript}` (or follow the guidance above). Wait for all services to be healthy, then re-run `$integration-test-verify`."
191 > **STOP** — do not run tests against an unhealthy system. Results would be unreliable.
192
193**If no `systemCheckCommand`:**
194
195- If `guidance`, reference docs, `runScript`, or `startupScript` indicate required local infrastructure/services, STOP and tell the user the project config needs a concrete readiness check before AI verification can run.
196- Otherwise, proceed to the precondition gate and explicitly report that no system check was configured.
197
198### Precondition gate (BLOCKING — every harvested item, evidence-backed)
199
200A green `systemCheckCommand` does NOT discharge the Step 1b checklist: it verifies only what the config author thought to encode, while the reference doc is where the project wrote down what the runner silently assumes. Walk the checklist and settle every row.
201
2021. **Verify each item against real evidence** — a command's actual output, a port/process/container check, a config or env read, a query. NEVER mark an item met by reasoning that it "should" be up.
2032. **Mark each row** `MET` (with the evidence) · `UNMET` (with what is missing) · `UNVERIFIABLE` (no observable exists — surface it).
2043. **Any `UNMET` → STOP before the first test command.** Report `ENVIRONMENT-BLOCKED`, name the unmet precondition and the `file:line` that declares it, and give the user the concrete setup step (`startupScript`, the doc's setup section, the missing env var). NEVER run the suite anyway — why: a suite run against a half-ready environment reports infrastructure faults as failing tests, which then get "fixed" in the test code.
2054. **Never fix an environment gap by editing tests.** An unmet precondition is a setup action for the user or a project-config gap to report — never a reason to weaken a test, add a skip, or relax a timeout.
2065. **Emit the settled checklist** (rows + statuses + evidence) into the Step 5 report, so the pass/fail result proves the environment was ready when it ran.
207
208All rows `MET` (or the explicit `no preconditions declared` record) → proceed to Step 3.
209
210---
211
212## Step 3: Determine Test Projects
213
214**Priority order:** `testProjectPattern` (glob auto-discover) > `testProjects` (explicit list) > git auto-detect (fallback).
215
216**If `testProjectPattern` exists in config:**
217
218Discover test projects by running a glob search for the pattern:
219
220```bash
221# Example (testProjectPattern from project config, e.g. "**/*.IntegrationTests.csproj")
222find . -path "{testProjectPattern}" -type f
223# or use language-appropriate glob tool
224```
225
226Use all discovered `.csproj` files (or equivalent) as the test project list. Exclude any paths outside the pattern scope.
227
228**If no `testProjectPattern` but `testProjects` list exists:**
229
230Use the explicit list from config directly.
231
232**If neither exists — auto-detect from git:**
233
234```bash
235# Auto-detect changed test projects
236git diff --name-only HEAD | grep -i "IntegrationTest" | sed 's|/[^/]*$||' | sort -u
237```
238
239If auto-detect finds nothing (no uncommitted test changes), ask user: "No changed test files detected. Run all test projects or skip?"
240
241**Filter rule:** Only run projects relevant to the current change. If user explicitly asks to run all → run all discovered/configured projects.
242
243---
244
245## Step 4: Run Tests
246
247Run this step only after Step 2 passed — system healthy AND every harvested precondition settled `MET` — or the config/reference docs explicitly state no external system is required.
248
249Execute using `quickRunCommand` from config. Run each relevant suite/project 2 consecutive times without resetting data.
250
251**Two-run idempotency gate:** If any run fails, verification fails. Fix the root cause, then restart the 2-run sequence from run 1. If a test is red in one run and green in the other, it is INTERMITTENT — adjudicate the cause per [Intermittent (flaky) failure adjudication](#intermittent-flaky-failure-adjudication--verdict-before-any-change) and record the verdict BEFORE changing anything.
252
253Example for a configured integration-test suite:
254
255```bash
256# Run each test project individually for clear per-project results
257{quickRunCommand} {testProject1}
258{quickRunCommand} {testProject2}
259# ...
260```
261
262Or run all at once using the solution filter if supported:
263
264```bash
265{quickRunCommand} --filter "Category=integration"
266```
267
268**Capture output for every run**: count Passed, Failed, Skipped. Note: skipped tests marked with the configured framework's skip annotation are expected and not a failure.
269
270### Parallel execution across multiple test projects (sub-agent fan-out)
271
272> **AI agent note:** When the determined set (Step 3) has **many independent test projects**, do NOT run them one-by-one in the foreground — **fan out one `integration-tester` sub-agent per project (or per balanced group of projects)** in a single message so they run concurrently, then advance only after EVERY sub-agent returns (all-return barrier). This collapses wall-clock from sum-of-suites to slowest-single-suite.
273
274Apply this only when it is actually safe and worthwhile:
275
276- **Threshold.** Skip the fan-out for 1–2 small projects (orchestration overhead outweighs the gain); use it once there are several projects or any long-running suite.
277- **Isolation is mandatory.** Parallel suites MUST NOT share mutable state. Fan out only when each project targets its **own isolated DB/schema/container/namespace** (or the project config / reference docs confirm per-suite isolation). If suites share one database, concurrent runs cross-contaminate state and silently break the "2 consecutive green runs without DB reset" guarantee → run those **sequentially** instead. When unsure, ask the user or default to sequential.
278- **Each sub-agent owns the full gate for its assignment.** Every sub-agent runs its project(s) through the complete **2-consecutive-green-runs-without-DB-reset** sequence, captures real runner output (Passed/Failed/Skipped counts + failing names), and returns that evidence — partial or single-run results are not acceptable.
279- **Each sub-agent inherits this same discipline.** No weakened assertions, no skip annotations, no domain-data hacks; on failure it diagnoses test-bug vs service-bug at the root layer (per the On Test Failure Protocol).
280- **Barrier + aggregate.** Wait for all sub-agents, then merge their per-project tables into the single Step 5 report. Any one project failing its 2-run gate fails the overall verification.
281
282```
283# Conceptual fan-out (one sub-agent per project / balanced group), launched together:
284integration-tester → {testProject1} → 2-run gate → returns counts + failing names
285integration-tester → {testProject2} → 2-run gate → returns counts + failing names
286integration-tester → {testProject3} → 2-run gate → returns counts + failing names
287# ... barrier: aggregate all returns into Step 5 report
288```
289
290---
291
292## Step 5: Report Results
293
294After all tests complete, report:
295
296```
297### Integration Test Verify Results
298
299**Run command:** {quickRunCommand}
300**Projects tested:** {N}
301**Repeatability gate:** 2 consecutive runs without DB reset
302**Environment preconditions:** {M} harvested from {referenceDoc} — all MET (or: none declared)
303
304| Project | Run | Passed | Failed | Skipped |
305|---------|-----|--------|--------|---------|
306| {Project1} | 1 | X | 0 | Y |
307| {Project1} | 2 | X | 0 | Y |
308
309**Total:** {total_passed} passed, {total_failed} failed, {total_skipped} skipped (expected skip annotations)
310
311Status: ✅ ALL PASS | ❌ {N} FAILURES
312```
313
314**On failure:**
315
3161. List each failing test name + failure message
3172. Diagnose: test bug (wrong assertion setup) or service bug (handler actually broken)?
3183. If test bug → fix in the test file (do NOT weaken assertions — fix setup/data)
3194. If service bug → report as finding, do NOT silently fix without telling user
3205. After fixing → re-run the full 2-run verify sequence
3216. **RECOMMEND `$workflow-integration-test-green` to the user whenever this run ends with ANY failure.** This skill reports a snapshot; it does not own convergence. That workflow runs the loop that clears the suite — each round re-verifies, adjudicates the fault with `$debug-investigate` + `$integration-test-review`, fixes at the owning layer, code-reviews the round's fix diff, and re-verifies from a FRESH full run until the whole suite passes its 2-run gate. Surface it as the recommended next step (see [Next Steps](#next-steps)) rather than hand-carrying failures one by one.
322 - **EXCEPTION — do NOT recommend it when this run IS a round of that loop** (invoked by `integration-test-verify-loop` or inside `workflow-integration-test-green`). Return the counts + failing names to the caller instead. — why: the loop already owns convergence; recommending it from inside itself is circular and would restart the very loop that is running.
323
324**Goal Contract evidence (after verify run):** Resolve the active Goal Contract per the goal-contract-satisfaction-loop protocol (active plan `goal.md` → `plans/goals/{YYMMDD-HHmm}-{slug}/goal.md`). When one exists, append the verification evidence to the goal file's Iteration Log — run command, per-run pass/fail counts, report path — mapped to the saved success criteria these tests verify, and update the matching Goal Satisfaction matrix rows (PASS on 2/2 green, FAIL with the failing-test list, BLOCKED with a user-facing reason). Record `No active goal — results reported inline only.` when none exists. Never copy raw sensitive fixture data into the goal file.
325
326---
327
328## Fallback Mode (No Project Config)
329
330When `docs/project-config.json` has no `integrationTestVerify` section:
331
3321. Detect project type from root files:
333 - `*.sln` or `*.csproj` → `dotnet test`
334 - `package.json` → `npm test` or `npx jest`
335 - `pytest.ini` / `setup.py` / `pyproject.toml` → `pytest`
336 - `go.mod` → `go test ./...`
337
3382. Auto-detect changed test files from git:
339
340 ```bash
341 git diff --name-only HEAD
342 ```
343
3443. Run detected command on changed test projects.
345
3464. Report results and recommend: "Add `integrationTestVerify` to `docs/project-config.json` for project-specific run guidance."
347
348---
349
350## CI-Style Full Run (Reference)
351
352When `runScript` is configured, reference it for the full CI-style run (not run by AI directly — Windows.cmd scripts and CI runners require user/pipeline execution):
353
354> "For a full CI-style run including Docker orchestration and health polling, execute: `{runScript}`"
355
356This script typically: creates networks → removes stale containers → builds images → starts infrastructure (wait healthy) → starts APIs (wait healthy) → runs all tests.
357
358---
359
360## On Test Failure Protocol
361
362**NEVER** do these to make failures go away:
363
364- ❌ Remove or weaken assertions
365- ❌ Add skip annotations to hide failures
366- ❌ Create or mutate domain data through repositories to bypass real use-case paths
367- ❌ Mark passing by ignoring error output
368- ❌ Report "all passed" without showing actual runner output
369- ❌ Widen an assertion timeout, add a retry around a failing assertion, or mark a test flaky-and-skipped to make an intermittent failure go away
370
371**DO** this instead:
372
3731. Read the failing test method
3742. Read the handler/service the test targets
3753. Identify: is the assertion wrong, or is the code wrong?
3764. Fix at the root cause layer; use real use cases or valid seeded fixtures for data setup
3775. Re-run to confirm green
3786. **If step 3 found the CODE was wrong (SOURCE-WRONG) and your fix changed production/source code**, route that changed source into a fresh `$changes-review` (or emit a HIGH finding requiring it) BEFORE declaring the 2-run green PASS — a source fix that greens a test must not ship un-code-reviewed. (In `workflow-feature`/`workflow-bugfix` the downstream `workflow-review-changes` step already covers this; the route matters for standalone runs.)
379
380If a test fails because the system is unavailable → report as "system not ready" and reference `startupScript` / `runScript`. Never change the test.
381
382### Intermittent (flaky) failure adjudication — verdict BEFORE any change
383
384A test that is red in one run of the 2-run gate and green in another has NOT told you what is wrong. **Emit a written verdict, with evidence, BEFORE editing test code, production code, or any timeout.** An unadjudicated flake gets "fixed" by whatever is nearest — which is almost always the assertion.
385
386**Classify the cause into exactly one of three:**
387
388| Verdict | What it means | Evidence required to claim it | Resolution |
389| ------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
390| **(a) Unrealistic scenario / compressed pacing** | The test drives a sequence, timing, or data state production could never reach — most often distinct actor actions fired back-to-back that real usage separates by seconds, minutes, or hours, letting an in-flight async message land out of order | Read the ARRANGE block as a production trace; cite the chained actor actions (`file:line`) and state what separates them in real usage | Fix the SCENARIO — add an ARRANGE-phase settle barrier polling a real observable of the prior step. NEVER a widened assertion timeout |
391| **(b) Harness topology amplification** | The trigger is real but the LOCAL topology makes a rare production race routine — shared infrastructure, fan-out consumers over a shared parent, parallel suite execution, cold starts, or a resource-starved runner | Name the amplifying topology and cite it (config, fixture, suite settings, another test sharing the data); state whether the trigger exists in production and at what likelihood | Isolate the test's data/topology, or record the amplification explicitly. Report the production likelihood alongside — an amplified race may still be a real one |
392| **(c) Genuine product race** | The production code itself has an ordering, concurrency, or idempotency defect that a realistic scenario can hit | Trace the failure end-to-start to the defective production path (`file:line`); show the realistic sequence that reaches it | Report it as a product defect and fix at the owning layer per the fault-adjudication protocol; keep or strengthen the test that caught it |
393
394**Rules:**
395
3961. **Verdict first, change second.** Record `Flake verdict: (a) | (b) | (c) — {evidence}` in the Step 5 report before any edit. "Probably flaky" is not a verdict.
3972. **Reproduce before concluding.** Re-run the failing test repeatedly (it is a fast local test — see the 60s cap) so the intermittency is characterized, not assumed. State the observed ratio.
3983. **NEVER resolve a flake by widening a timeout, adding a retry, or skipping.** Those hide all three causes equally and destroy the signal.
3994. **Do not file (c) until (a) and (b) are ruled out with evidence.** Reporting a test-fidelity defect as a product defect burns hours and erodes trust in the suite.
4005. **Any resolution restarts the 2-run gate from run 1.** An intermittent test is not verified until it is green twice consecutively without a DB reset.
401
402---
403
404## Workflow Recommendation
405
406> **MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS:** If you are NOT already in a workflow, you MUST ATTENTION use ask the user directly to ask the user. Do NOT judge task complexity or decide this is "simple enough to skip" — the user decides whether to use a workflow, not you:
407>
408> 1. **Activate `workflow-write-integration-test` workflow** (Recommended) — scout → investigate → spec-tests → why-review → artifact-review --type=spec-tests → integration-test → integration-test-review → integration-test-verify → spec-tests [direction=sync] → docs-update → workflow-end → watzup
409> 2. **Execute `$integration-test-verify` directly** — run this skill standalone
410
411---
412
413## Next Steps
414
415**MANDATORY IMPORTANT MUST ATTENTION — NO EXCEPTIONS** after completing this skill, you MUST ATTENTION use ask the user directly to present these options. Do NOT skip because the task seems "simple" or "obvious" — the user decides:
416
417**Any failures in this run → `$workflow-integration-test-green` is the RECOMMENDED first option** (list it first), because it owns the converge-to-green loop this skill deliberately does not. All green → lead with `$workflow-review-changes` as before.
418
419- **"$workflow-integration-test-green (Recommended when ANY test failed)"** — Drive the whole suite to green: verify → adjudicate the fault → fix at the owning layer → review the fix diff → fresh re-verify, looping until the 2-run gate passes. Omit this option when this run was itself a round of that loop, or when the suite is fully green.
420- **"$workflow-review-changes (Recommended when all green)"** — Review all changes before committing
421- **"$integration-test-review"** — Review the failing tests only (report-only fault opinion), without entering the convergence loop
422- **"$docs-update"** — Update documentation if test counts changed
423- **"Skip, continue manually"** — user decides
424
425> **[IMPORTANT]** Use task tracking to break ALL work into small tasks BEFORE starting.
426> **A verify step that does not actually run tests 2 consecutive times is not repeatability verification. It is theater.**
427> Read project config FIRST to understand how to run tests for this specific project.
428
429<!-- SYNC:source-test-drift-check -->
430
431> **Source/test drift check.** For coding, fix, debug, investigation, test, or review work: when source behavior changes, inspect affected unit/integration/E2E tests and decide from evidence whether tests should change to match intended behavior or the source change is an unintended bug to fix. Do not write tests for migration code; schema/data migrations are one-time execution paths, not core application logic.
432
433<!-- /SYNC:source-test-drift-check -->
434
435<!-- SYNC:test-failure-fault-adjudication -->
436
437> **Test-Failure Fault Adjudication** — When a test fails (or you are debugging or fixing a failure), the job is to determine _who is at fault — the source code or the test code_. Getting that verdict right matters more than turning the suite green. Binds every debug / fix / test skill identically.
438>
439> 1. **Provisional verdict before touching either side.** Classify the observed evidence as SOURCE-WRONG, TEST-WRONG, TEST-NOT-OPTIMAL, ENVIRONMENT-BLOCKED, or AMBIGUOUS; then `$debug-investigate` and trace end-to-start before editing. A green-again suite is NOT the goal.
440> 2. **Triangulate against the spec AND the source.** If a governing Feature Spec covers the behavior (e.g. `docs/specs/**` — §3 ACs / §4 BRs / §5 invariants / §8 TCs), it is the tiebreaker for _intended_ behavior — compare BOTH the production source and the failing test against it. With no spec, the documented intent / acceptance criteria / caller contract is the reference. Decide from this evidence whether the SOURCE is wrong or the TEST is wrong.
441> 3. **Classify who is at fault, then fix the wrong side at its root:**
442> - **SOURCE-WRONG** — production code violates the spec's intended behavior or a clear invariant → fix the source at the owning layer; keep or strengthen the test that caught it.
443> - **TEST-WRONG** — the test encodes a stale or incorrect assertion, setup, or expectation that contradicts intended behavior → fix the test at its root. NEVER weaken an assertion, add a skip, or relax a timeout to force green.
444> - **TEST-NOT-OPTIMAL** — intended behavior is valid but the test seam, timing, or assertion signal is fragile → improve the test without weakening the invariant.
445> - **ENVIRONMENT-BLOCKED** — infrastructure or external state prevents a source/test verdict → preserve diagnostics and stop mutation until the environment is healthy.
446> - **AMBIGUOUS** — evidence or intended behavior does not safely select an owner → ask the user or canonical owner before editing.
447> - NEVER change a test to match broken source, and NEVER change source to satisfy a broken test. (Migration code excluded — schema/data migrations are one-time execution paths, not core application logic.)
448> 4. **Ask the user when intended behavior is unclear.** If no spec covers the behavior, the spec is silent, or the spec is ambiguous about which side is correct, STOP and ask the user directly (or consult the canonical spec owner) before editing either side — never silently pick source or test just to make the suite pass.
449>
450> Reconcile to intended behavior, never to whichever side currently passes — green can encode the very bug.
451
452<!-- /SYNC:test-failure-fault-adjudication -->
453
454<!-- SYNC:spec-tests-code-triangulation -->
455
456> **Spec ↔ Tests ↔ Code Triangulation** — The unit of review is the WHOLE PACKAGE (spec + tests + code), not the diff alone. Load all three faces together and reason mutual-consistency FIRST, before any isolated per-file check.
457>
458> 1. **Locate all three faces** for the changed behavior: the governing Feature Spec section(s) (§3 ACs / §4 BRs / §8 TCs), the tests that guard it, and the production code. A missing face is a finding (SPEC-GAP / TEST-GAP / DEAD-SPEC).
459> 2. **Triangulate pairwise** — classify which face is wrong on every disagreement:
460> - code vs spec → CODE-EXTRA / SPEC-STALE / CODE-WRONG (a [HARD] §4 rule or §5 invariant with no enforcing path is CODE-WRONG).
461> - tests vs spec → TEST-GAP / SPEC-SILENT.
462> - tests vs code → TEST-GAP / WEAK-TEST (a test that survives a deliberately broken invariant).
463> 3. **Capture hidden rules** — an invariant the code enforces but the spec never states (SPEC-SILENT) is surfaced as a finding, added into §3/§4/§8, and guarded with a test: the enrichment loop, never a silent pass.
464> 4. **Re-review after enrichment** — when triangulation adds spec content or a test, re-review the package against the enriched spec; converge only when a full pass surfaces no new disagreement.
465>
466> NEVER mark PASS while any face disagrees without a logged finding. The diff is the entry point; the package is the unit of judgment.
467
468<!-- /SYNC:spec-tests-code-triangulation -->
469
470<!-- SYNC:spec-drift-adjudication -->
471
472> **Spec drift adjudication (code-wrong vs spec-stale).** Whenever changed behavior diverges from a canonical Feature Spec (business rule, acceptance criterion, flow, state transition, or §8 TC under `docs/specs/`), you MUST NOT silently pick a side. Adjudicate per `shared/sdd-artifact-contract.md` → **Drift Gates**:
473>
474> 1. **Detect** — compare the change against the spec's documented intent. No divergence → record `Spec in sync` and move on.
475> 2. **Classify** the divergence:
476> - **CODE-WRONG** — the spec correctly states intended behavior and the change violates it → BLOCKING finding; fix the code/test against intended behavior (write/adjust a regression TC first).
477> - **SPEC-STALE** — the change is the new intended behavior and the spec now documents the old/wrong behavior → update the spec FIRST via `$spec [mode=update]`, then sync `$spec [mode=tests]` + `$spec [mode=sync]`.
478> - **AMBIGUOUS** — intended behavior is unclear → ask the user directly (or the canonical spec owner) before editing either side.
479> - **SPEC-SILENT** — the code correctly enforces an invariant/behavior that NO canonical spec artifact (§3 AC, §4 BR, §5 invariant, §8 TC) states → not drift but an UNWRITTEN rule discovered by review. ENRICH the spec via the **Invariant Harvest** pass (`$spec [mode=sync] direction=harvest` → `spec/references/sync.md`): prove it is always-true (≥2 enforcement points or a rejecting guard), express it as a universally-quantified property, then add the rule to §4 (or §3/§5) AND a §8 TC via `$spec [update]` + `$spec [mode=tests]` and add the guarding test. A discovered invariant left only in code (or only in tests) is INCOMPLETE — this is the highest-value capture (the rule nobody wrote down).
480> 3. **Never normalize drift just because code/tests are green** — green can encode the drift itself. Reconcile to canonical intent, never to whichever side currently passes.
481>
482> A behavior-changing review/implementation that leaves a spec divergence unadjudicated is INCOMPLETE; an unwritten-but-enforced invariant left uncaptured (no §4/§8 entry) is equally INCOMPLETE.
483
484<!-- /SYNC:spec-drift-adjudication -->
485
486<!-- SYNC:integration-test-execution-discipline -->
487
488> **Integration Test Execution Discipline** — How the integration-test family (write · review · verify) runs, diagnoses, and clears a suite. Binds `$integration-test`, `$integration-test-review`, and `$integration-test-verify` identically.
489>
490> 1. **Verify the WHOLE system passes — not a hand-picked subset.** `$integration-test-verify` must prove the full relevant suite is green (every test in the system the change can touch), not one cherry-picked test. "All pass" is only true with actual runner output (Passed/Failed/Skipped counts + names) and only after 2 consecutive green runs without a DB reset.
491> 2. **Drive state through real use-case paths — NEVER hack seed data.** Set up every precondition exactly as a real user would: real commands, queries, production consumers/messages, or valid idempotent seeders. NEVER create or mutate domain data by direct repository writes — that fabricates states a user could never reach and hides the real workflow bug. Hacking seed data to force a green run is forbidden.
492> 3. **On ANY failure → `$debug-investigate` the root cause BEFORE any fix.** Do not guess, do not patch the symptom site. Trace the failure end-to-start and classify whose fault it is: test code (wrong assertion/setup), source/production code (real defect), or environment/infrastructure/data. Then route: test-code fault → `$integration-test-review` to fix the test at the root (never weaken assertions or add skips); source-code fault → fix the production defect at the owning layer and report it; environment fault → mark BLOCKED and point at the startup script. NEVER change a test to match broken code.
493> 4. **60-second runtime cap — a slow test is a RED FLAG, not a tuning knob.** Local integration tests run fast. If any single test (or a stalled suite) exceeds ~60s, STOP and treat the slowness itself as a defect signal — deadlock, missing `await`, infinite poll/retry, a real network/external call, or an unbounded query. `$debug-investigate` the cause; NEVER paper over it by raising the timeout or extending the wait.
494> 5. **Loop until the whole suite is green.** After fixing the validated root cause, restart the full 2-run verification from run 1. Done means the entire relevant suite passes repeatably — never green-once, never a subset.
495
496<!-- /SYNC:integration-test-execution-discipline -->
497
498<!-- SYNC:real-world-fidelity-testing -->
499
500> **Real-World Fidelity Gate** — MANDATORY when authoring, reviewing, or repairing any integration / E2E / system test.
501>
502> A test earns trust by reproducing a situation the system can actually meet in production. A scenario that could never occur in real life proves nothing when it passes, and wastes hours when it fails.
503>
504> 1. **Ask the fidelity question BEFORE writing the setup:** _"Can this sequence, timing, and data actually occur in production?"_ If no, the test is mis-specified — fix the SCENARIO, never the assertion.
505> 2. **Model real pacing between actor steps.** Two distinct actor actions that production separates by seconds, minutes, or hours MUST NOT be fired back-to-back in the same millisecond. Compressed pacing manufactures races the system was never designed to survive, then reports them as product defects.
506> 3. **Wait on a real signal, never a blind sleep.** Find an observable proving the prior step finished — a persisted state change, an audit/version stamp, a queue/worker idle marker, a completion event — and poll until it settles (unchanged across a short stability window). Use a fixed delay ONLY when no observable exists, and say so in a comment.
507> 4. **Barriers belong in ARRANGE, never in ASSERT.** Waiting for a precondition is fidelity. Widening an assertion's timeout, loosening a comparison, adding a retry around a failing assertion, or skipping the test is masking. NEVER do the latter to force green.
508> 5. **Distinguish harness-amplified from real.** Test topologies (shared infra, fan-out consumers, parallel suites, cold starts) can make a rare production race routine locally. Before filing a product defect, state whether the trigger exists in production and at what likelihood.
509> 6. **Keep the protected invariant intact.** Improving fidelity must NEVER reduce what the test protects. If a realistic scenario no longer exercises the rule, the rule needs a DIFFERENT realistic scenario — not a weaker assertion.
510> 7. **Deliberate impossible-state tests are allowed, but MUST be labelled.** Corruption-repair, migration, and fail-safe tests intentionally construct states production should never reach; comment WHY the state is reachable (upstream bug, partial write, legacy data), so they are never confused with unrealistic setups.
511
512<!-- /SYNC:real-world-fidelity-testing -->
513
514<!-- SYNC:ai-mistake-prevention -->
515
516> **AI Mistake Prevention** — Failure modes to avoid on every task:
517>
518> **Re-read files after context changes.** Context compaction, resume, or long-running work can make memory stale; verify current files before acting.
519> **Verify generated content against source evidence.** AI hallucinates APIs, names, claims, and document facts. Check the relevant source before documenting or referencing.
520> **Check downstream references before deleting or renaming.** Removing an artifact can stale docs, generated mirrors, configs, and callers; map references first.
521> **Trace the full impact chain after edits.** Changing a definition can miss derived outputs and consumers. Follow the affected chain before declaring done.
522> **Verify ALL affected outputs, not just the first.** One green check is not all green checks; validate every output surface the change can affect.
523> **Assume existing values are intentional — ask WHY before changing OR flagging one as a defect.** Before changing or reporting a constant, limit, flag, cutoff, wording, or pattern, read nearby context and history, the CALLER's ordering, and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard.
524> **Surface ambiguity before acting — don't pick silently.** Multiple valid interpretations require an explicit question or stated assumption with risk.
525> **Assert the outcome your system owns, not the intermediate state your infrastructure owns.** When verifying async work, assert the final business state — never the delivery/retry bookkeeping held in shared infrastructure that any co-running process can write. Such a check passes when run alone and flakes the moment anything else shares that infrastructure.
526> **Keep shared guidance role-relevant.** Universal guidance must help every receiving skill or agent; code-specific obligations belong only in code-specific protocols.
527
528<!-- /SYNC:ai-mistake-prevention -->
529
530<!-- SYNC:nested-task-creation -->
531
532> **Nested Task Expansion Contract** — For workflow-step invocation, the `[Workflow] ...` row is only a parent container; the child skill still creates visible phase tasks.
533>
534> 1. Call the current task list first. If a matching active parent workflow row exists, set `nested=true` and record `parentTaskId`; otherwise run standalone.
535> 2. Create one task per declared phase before phase work. When nested, prefix subjects `[N.M] $skill-name — phase`.
536> 3. When nested, link the parent with `TaskUpdate(parentTaskId, addBlockedBy: [childIds])`.
537> 4. Orchestrators must pre-expand a child skill's phase list and link the workflow row before invoking that child skill or sub-agent.
538> 5. Mark exactly one child `in_progress` before work and `completed` immediately after evidence is written.
539> 6. Complete the parent only after all child tasks are completed or explicitly cancelled with reason.
540>
541> **Blocked until:** the current task list done, child phases created, parent linked when nested, first child marked `in_progress`.
542
543<!-- /SYNC:nested-task-creation -->
544
545<!-- SYNC:task-tracking-external-report -->
546
547> **Task Tracking & External Report Persistence** — Bootstrap this before execution; then run project-reference doc prefetch before target/source work.
548>
549> 1. Create a small task breakdown before target file reads, grep, edits, or analysis. On context loss, inspect the current task list first.
550> 2. Mark one task `in_progress` before work and `completed` immediately after evidence; never batch transitions.
551> 3. For plan/review work, create `plans/reports/{skill}-{YYMMDD}-{HHmm}-{slug}.md` before first finding.
552> 4. Append findings after each file/section/decision and synthesize from the report file at the end.
553> 5. Final output cites `Full report: plans/reports/{filename}`.
554>
555> **Blocked until:** task breakdown exists, report path declared for plan/review work, first finding persisted before the next finding.
556
557<!-- /SYNC:task-tracking-external-report -->
558
559<!-- SYNC:critical-thinking-mindset -->
560
561> **Critical Thinking Mindset** — Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
562> **Anti-hallucination:** Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
563
564<!-- /SYNC:critical-thinking-mindset -->
565
566<!-- SYNC:project-reference-docs-guide -->
567
568> **Project Reference Docs Gate** — Run after task-tracking bootstrap and before target/source file reads, grep, edits, or analysis. Project docs override generic framework assumptions.
569>
570> 1. Identify scope: file types, domain area, and operation.
571> 2. **Read `docs/project-config.json` first — the project's machine-readable map.** It is the single source of truth for THIS repo (modules/paths, framework + search keywords, test/E2E/integration run-commands, design system, architecture rules, workflow patterns); ground exact paths, run-commands, and conventions on it **before investigating, planning, or coding** — never assume framework defaults (`CLAUDE.md` + reference docs are derived from it). If it — or the docs index, `lessons.md`, `CLAUDE.md`, `AGENTS.md`, or any required reference doc — is missing or stale, auto-run `$project-init` or the narrow route (`$project-config`, `$docs-init`, `$scan-all`, `$scan --target=<key>`, `$claude-md-init`) first; if Codex mirrors or `AGENTS.md` are stale, ask the user to run `$sync-codex` (never auto-run it).
572> 3. Required docs by trigger: always `docs/project-reference/lessons.md`; doc lookup `docs-index-reference.md`; review `code-review-rules.md`; backend/CQRS/API `backend-patterns-reference.md`; domain/entity `domain-entities-reference.md`; frontend/UI `frontend-patterns-reference.md`; styles/design `scss-styling-guide.md` + `design-system/design-system-canonical.md`; integration tests `integration-test-reference.md`; E2E `e2e-test-reference.md`; feature docs/specs `feature-spec-reference.md` + `spec-system-reference.md` + `spec-principles.md`; behavior/public-contract/spec-test-code sync `workflow-spec-test-code-cycle-reference.md`; derived spec index/ERD/reimplementation guides `spec-system-reference.md` + source Feature Specs under `docs/specs/`; architecture/new area `project-structure-reference.md`.
573> 4. Read every required doc, then before target work state: `Reference docs read: ... | Not applicable: ...`.
574>
575> **Ready when:** scope evaluated, `docs/project-config.json` consulted, required docs checked/read or setup route completed, `lessons.md` confirmed, citation emitted.
576
577<!-- /SYNC:project-reference-docs-guide -->
578
579<!-- SYNC:critical-thinking-mindset:reminder -->
580
581**MUST ATTENTION** apply critical + sequential thinking — every claim needs appropriate traced evidence (`file:line` for repo/code claims; source URL or artifact section for research, product, content, and docs claims); confidence >80% to act, <60% DO NOT recommend. Anti-hallucination: never present guess as fact, admit uncertainty freely, cross-reference independently, stay skeptical of own confidence.
582
583<!-- /SYNC:critical-thinking-mindset:reminder -->
584
585<!-- SYNC:ai-mistake-prevention:reminder -->
586
587**MUST ATTENTION** apply AI mistake prevention — verify generated content against evidence, trace downstream references before deleting or renaming, verify all affected outputs, re-read files after context loss, and surface ambiguity before acting.
588
589<!-- /SYNC:ai-mistake-prevention:reminder -->
590
591<!-- SYNC:task-tracking-external-report:reminder -->
592
593- **MANDATORY** Bootstrap task tracking before target work; transition one task at a time.
594- **MANDATORY** Persist plan/review findings to `plans/reports/` incrementally and synthesize from disk.
595
596<!-- /SYNC:task-tracking-external-report:reminder -->
597
598<!-- SYNC:project-reference-docs-guide:reminder -->
599
600- **MANDATORY** Before investigating, planning, or coding, read `docs/project-config.json` (the project map: modules/paths, run-commands, conventions, architecture/workflow rules) + the required project-reference docs, and cite `Reference docs read: ...`.
601- **MANDATORY** Always include `lessons.md`; project config + conventions override generic framework defaults.
602- **MANDATORY** If project config, root instruction files, or any required reference doc is missing or stale, auto-run `$project-init` or the narrow lower-level route before ordinary project-specific work.
603
604<!-- /SYNC:project-reference-docs-guide:reminder -->
605
606<!-- SYNC:nested-task-creation:reminder -->
607
608- **MANDATORY** Parent workflow rows do not replace child phase tracking; expand phases and link the parent when nested.
609- **MANDATORY** Orchestrators pre-expand child skill phases before invocation; use `[N.M] $skill-name — phase` prefixes and one-`in_progress` discipline.
610
611<!-- /SYNC:nested-task-creation:reminder -->
612
613<!-- SYNC:goal-contract-satisfaction-loop:reminder -->
614
615- **MANDATORY** Resolve the active Goal Contract BEFORE work (active plan `goal.md` → `plans/goals/{YYMMDD-HHmm}-{slug}/goal.md` → create from current request) and read saved success criteria before editing.
616- **MANDATORY** Append iteration evidence after execution; emit a Goal Satisfaction matrix (PASS/FAIL/BLOCKED) before reporting PASS; loop on validated FAIL; escalate repeated no-progress or blockers. NEVER store secrets in goal files.
617
618<!-- /SYNC:goal-contract-satisfaction-loop:reminder -->
619
620<!-- PROMPT-ENHANCE:STEP-TASK-CLOSING:START -->
621
622## Prompt-Enhance Closing Anchors
623
624**IMPORTANT MUST ATTENTION** follow declared step order for this skill; NEVER skip, reorder, or merge steps without explicit user approval
625**IMPORTANT MUST ATTENTION** for every step/sub-skill call: set `in_progress` before execution, set `completed` after execution
626**IMPORTANT MUST ATTENTION** every skipped step MUST include explicit reason; every completed step MUST include concise evidence
627**IMPORTANT MUST ATTENTION** if Task tools unavailable, maintain an equivalent step-by-step plan tracker with synchronized statuses
628
629<!-- PROMPT-ENHANCE:STEP-TASK-CLOSING:END -->
630
631<!-- SYNC:project-protocol-overlay -->
632
633> **Project Protocol Overlay** — Before executing this skill, resolve any PROJECT overlay rules layered onto it: match this skill's name against the `Target` column of the project's skill-protocol index (`docs/project-reference/skill-protocols-reference.md` by default; a `referenceDocs` entry in `docs/project-config.json` overrides the path), taking the most specific matching tier ONLY — exact name > glob > `*`. **That precedence orders overlays against EACH OTHER, never against this skill.** Read ONLY the matched bodies, resolved as `<protocols-dir>/<Name>.md`; a row's Body link is display text, never a read path. A matched body that is missing or malformed is REPORTED and skipped — never reconstructed from the index Description. No index, or no match -> proceed with no overlay, silently. Full contract: `.claude/skills/project-skill-protocol/references/registry.md`.
634>
635> Overlays are **ADDITIVE ONLY**: they ADD rules on top of this skill's own protocol and NEVER replace, override, disable, or reinterpret a rule it already states — removing every overlay must return this skill to exactly its documented behavior. An overlay is a BRIEF, not an authority escalation: it can NEVER waive a workflow gate, git discipline, a review gate, or a user-confirmation gate. A genuine overlay-vs-skill conflict, or two equally-specific overlays that directly contradict -> surface both to the user; NEVER resolve silently.
636
637<!-- /SYNC:project-protocol-overlay -->
638
639<!-- SYNC:project-protocol-overlay:reminder -->
640
641**MUST ATTENTION** resolve project protocol overlays for this skill BEFORE executing — most specific matching tier only (exact > glob > `*`, which ranks overlays against each other, NEVER against this skill), read only matched bodies at `<protocols-dir>/<Name>.md`; a missing or malformed body is reported, never reconstructed. Overlays are ADDITIVE ONLY (they never replace this skill's own rules) and are a brief, NEVER an authority escalation; an equal-specificity contradiction goes to the user.
642
643<!-- /SYNC:project-protocol-overlay:reminder -->
644
645## Closing Reminders
646
647**IMPORTANT MUST ATTENTION Goal:** Prove the reviewed integration tests pass repeatably — 2 consecutive green runs without DB reset, using project-configured run commands — with every pass/fail claim backed by actual test-runner output, never assumption.
648
649**IMPORTANT MUST ATTENTION — Protocols in force (concise digest of the SYNC/shared blocks this skill carries):**
650
651- **Source/Test Drift:** On source change, reconcile affected tests vs source-bug from evidence.
652- **Spec↔Tests↔Code Triangulation:** judge the WHOLE PACKAGE (spec §3/§4/§8 + tests + code) for mutual consistency; a disagreeing or missing face is a logged finding, NEVER a silent pass.
653- **Spec Drift Adjudication:** on behavior divergence from a canonical spec, classify CODE-WRONG / SPEC-STALE / AMBIGUOUS / SPEC-SILENT and harvest unwritten invariants into §4/§8 + a guarding test — NEVER normalize drift to whichever side is green.
654- **Real-World Fidelity:** a scenario production could never reach proves nothing green and blames the product red; settle barriers on a real observable belong in ARRANGE — NEVER a widened assertion timeout, a blind sleep, or a retry around a failing assertion; distinguish harness-amplified from real before filing a product defect.
655- **AI Mistake Prevention:** verify generated content against evidence, trace downstream references, verify all affected outputs, re-read after context loss, surface ambiguity.
656- **Nested Task Creation:** Expand child phases and link parent when nested; one `in_progress`.
657- **Task Tracking & External Report:** Bootstrap tracking; persist plan/review findings to `plans/reports/` incrementally.
658- **Critical Thinking:** Traced `file:line` proof per claim; confidence >80% to act.
659- **Project Reference Docs:** Read required project docs and `lessons.md` before target work; cite them.
660
661**IMPORTANT MUST ATTENTION** read `docs/project-config.json` → `integrationTestVerify` FIRST — project-specific guidance overrides defaults; missing section → Fallback Mode — why: hardcoded assumptions about the runner break on any non-default stack.
662**IMPORTANT MUST ATTENTION** use `quickRunCommand` from config — NEVER hardcode `dotnet test` or any language-specific command — why: this skill is language-agnostic and one repo's runner is another's wrong tool.
663**IMPORTANT MUST ATTENTION** read project-specific integration-test reference docs/scripts named by `referenceDocs` before any test command — Codex has no hook injection, so it must open these files directly.
664**IMPORTANT MUST ATTENTION** harvest an Environment Precondition Checklist from those docs (Step 1b) BEFORE any command — derive every item from what the doc declares with a `file:line` citation, NEVER from a fixed list and NEVER invented; no declared prerequisites → record that explicitly — why: reading the doc without extracting its preconditions leaves the run just as blind as not reading it.
665**IMPORTANT MUST ATTENTION** gate on a healthy system before running — run `systemCheckCommand`, and STOP (point user at `startupScript`) when infrastructure/services aren't ready — why: an unreliable system produces unreliable green/red results that prove nothing.
666**IMPORTANT MUST ATTENTION** settle EVERY harvested precondition against real evidence before the first test command — any `UNMET` → STOP, report `ENVIRONMENT-BLOCKED` naming the precondition + its doc line + the setup step, and NEVER run the suite anyway or repair an environment gap by editing tests — why: a half-ready environment reports infrastructure faults as failing tests, which then get "fixed" in the test code.
667**IMPORTANT MUST ATTENTION** determine the test-project set BEFORE running — `testProjectPattern` glob > `testProjects` list > git auto-detect — and run only projects the change touches unless the user asks for all — why: running irrelevant suites wastes the gate and muddies the result.
668**IMPORTANT MUST ATTENTION** pass requires 2 consecutive green runs of each relevant suite WITHOUT DB reset; any single failure restarts the sequence from run 1 — why: a one-off green run hides order-dependent and state-leak flakiness.
669**IMPORTANT MUST ATTENTION** when the set has several independent, per-DB-isolated projects, fan out one `integration-tester` sub-agent per project/balanced group in parallel, barrier on ALL returns, then aggregate into the Step 5 report — each sub-agent owns its full 2-run gate and returns real counts + failing names; suites sharing a DB run sequentially — why: parallel runs over a shared DB cross-contaminate state and silently break the no-reset guarantee.
670**IMPORTANT MUST ATTENTION** show actual runner output (Passed/Failed/Skipped counts + failing names) — "all passed" without evidence is theater, not verification — confidence >80% to claim PASS, and that confidence rests on the captured output, never assumption.
671**IMPORTANT MUST ATTENTION** on failure, diagnose test-bug vs service-bug at the responsible layer BEFORE any edit — fix the root cause; report service bugs as findings, do NOT silently fix — why: patching the symptom site leaves the real defect live.
672**IMPORTANT MUST ATTENTION** the run ended with ANY failing test → RECOMMEND `$workflow-integration-test-green` as the user's next step, listed FIRST in the Next Steps options — it owns the converge-to-green loop (verify → adjudicate → fix → review → fresh re-verify) that this snapshot skill deliberately does not; do NOT recommend it when this run is itself a round of that loop (return counts + failing names to the caller instead) — why: reporting red and stopping leaves the user hand-carrying every failure, while recommending it from inside itself is circular.
673**IMPORTANT MUST ATTENTION** on a FAILED TEST, FIRST read the `$integration-test-review` skill protocol (assertion-quality, coverage & spec↔test↔code fault gates) to set investigation/fix direction — decide whether the fault is a source-code root cause or a test-code setup/assertion issue — why: fixing without that verdict patches the wrong side and can green a broken invariant.
674**IMPORTANT MUST ATTENTION** on an INTERMITTENT failure (red in one run, green in another) adjudicate the cause BEFORE any change and record the verdict with evidence — (a) unrealistic scenario / compressed actor pacing, (b) harness topology amplification (shared infra, fan-out consumers, suite parallelism, cold start), or (c) a genuine product race; do NOT file (c) until (a) and (b) are ruled out — why: reporting a test-fidelity defect as a product defect burns hours and erodes trust in the suite.
675**IMPORTANT MUST ATTENTION** NEVER resolve a flake by widening an assertion timeout, adding a retry around a failing assertion, or skipping the test — repair the SCENARIO (an ARRANGE-phase barrier on a real observable) or the product defect, then restart the 2-run gate from run 1 — why: those three hide all causes equally and destroy the only signal you had.
676**IMPORTANT MUST ATTENTION** to make red go green NEVER weaken/remove assertions, add skip annotations, or mutate domain data outside real use-case paths — instead fix the assertion setup or the handler, then re-run the full 2-run sequence — why: a test that no longer protects its invariant is worse than no test.
677**IMPORTANT MUST ATTENTION** before authoring or changing any test code, grep 3+ sibling integration tests and follow the local pattern (base fixtures, real DI, no mocks) — cite `file:line` — why: the closest example may not share the same preconditions; verify fit before copying.
678**IMPORTANT MUST ATTENTION** bootstrap task tracking before work and mark one task `in_progress` / `completed` at a time; on context loss call the current task list first and resume — never blindly duplicate tasks.
679**IMPORTANT MUST ATTENTION** resolve and update the active Goal Contract — append per-run pass/fail evidence to the goal file's Iteration Log and matrix; NEVER copy raw sensitive fixture data into goal files.
680
681**Anti-Rationalization:**
682
683| Evasion | Rebuttal |
684| ------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
685| "One green run is enough" | 2 consecutive green runs without DB reset, or it isn't verified. Restart on any red. |
686| "I'll just hardcode `dotnet test`" | Read `quickRunCommand` from config — this skill is language-agnostic. |
687| "The test asserts too strictly, relax it" | Fix the code or the setup, never the assertion. Weakened tests protect nothing. |
688| "It's just flaky, re-run it" | Intermittent = unadjudicated. Classify (a) unrealistic scenario, (b) harness amplification, or (c) real product race — with evidence — before any change. |
689| "Bump the timeout and move on" | Widening a timeout masks all three flake causes. The barrier belongs in ARRANGE, on a real observable. |
690| "Found a race — file it as a product bug" | Not until (a) and (b) are ruled out. State whether the trigger exists in production and at what likelihood. |
691| "Looks like it passed" | Show Passed/Failed/Skipped counts from real runner output. No output = no claim. |
692| "Tests failed — report it and stop" | Reporting red is half the job. Recommend `$workflow-integration-test-green`; it owns the loop that clears the suite. |
693| "System probably ready" | Run `systemCheckCommand`. Unhealthy system → STOP, point user at `startupScript`. |
694| "I read the reference doc, that's the gate" | Reading is not checking. Harvest the preconditions into a cited checklist and settle every row before the first test command. |
695| "systemCheckCommand is green, skip the checklist" | It verifies only what the config author encoded. The doc's preconditions are the ones the runner silently assumes — verify each. |
696| "Env is half-up, run the suite and see" | A half-ready environment reports infrastructure faults as failing tests. STOP, report ENVIRONMENT-BLOCKED, name the unmet precondition. |
697| "Too simple to track" | Skip depth, never skip task tracking. Wrong assumptions waste more time. |
698
699> **[IMPORTANT]** Use task tracking to break ALL work into small tasks BEFORE starting — analyze task size first.
700
701---
702
703**IMPORTANT MUST ATTENTION Goal:** Prove reviewed integration tests pass repeatably — 2 consecutive green runs, no DB reset, every pass/fail claim backed by actual runner output.
704**IMPORTANT MUST ATTENTION** read `integrationTestVerify` config AND the project's integration-test reference docs FIRST, harvest their environment preconditions into a cited checklist, and settle every row before the first test command — use `quickRunCommand` from config, NEVER hardcode a language-specific runner.
705**IMPORTANT MUST ATTENTION** NEVER weaken assertions, add skips, or mutate domain data to force green — fix the root-cause layer (test bug vs service bug) and re-run the full 2-run sequence.
706
707---
708
709> **Closing reminder — Easy to Change is the success metric.** Every finding,
710> test, refactor, and abstraction must answer one question: _does this make
711> the next change cheaper or more expensive?_ If it doesn't reduce future
712> change cost, reject it. Coupling, hidden state, duplicated knowledge, and
713> unclear intent are the real enemies — call them out by name.
714
715<!-- CODEX:SYNC-PROMPT-PROTOCOLS:START -->
716
717## Hookless Prompt Protocol Mirror (Auto-Synced)
718
719Source: `.claude/.ck.json` + `.claude/skills/shared/sync-inline-versions.md` (`:full` blocks) + `.claude/scripts/lib/hookless-prompt-protocol.cjs`
720
721## [WORKFLOW-EXECUTION-PROTOCOL] [BLOCKING] Workflow Execution Protocol — MANDATORY IMPORTANT MUST CRITICAL. Do not skip for any reason.
722
723**Generic portability boundary:** Reusable skills and protocol text stay project-neutral; project-specific conventions are discovered from docs/project-config.json and docs/project-reference/. Apply shared AI-SDD from `shared/sdd-artifact-contract.md`. Read `docs/project-config.json` and `docs/project-reference/docs-index-reference.md`, then open the project reference docs named there. For spec, test-case, behavior-change, public-contract, or `docs/specs/` work, route through the local spec docs named by the docs index: `feature-spec-reference.md`, `spec-system-reference.md`, `spec-principles.md`, and `workflow-spec-test-code-cycle-reference.md` when specs/tests/code must stay synchronized. If either file or a required reference doc is missing or stale, auto-run `$project-init` (or the narrow lower-level route such as `$project-config`, `$docs-init`, `$scan-all`, or `$scan --target=<key>`) before ordinary project-specific work. Any supported AI tool may execute when this shared context and local docs are available.
724
7251. **DETECT:** If the prompt starts with an explicit slash skill/workflow command, execute it directly. Otherwise match the prompt against the workflow catalog and skill list.
7262. **ANALYZE:** Choose the best option: execute directly, invoke a skill, activate a standard workflow, or compose a custom step combination.
7273. **AUTO-SELECT:** Pick the best option yourself. Do not ask the user to choose between direct execution, skill, standard workflow, or custom workflow.
7284. **ACTIVATE:** For a selected workflow, call `$start-workflow <workflowId>`; for a selected skill, invoke that skill; for a custom workflow, sequence custom steps directly; for direct execution, proceed with the task.
7295. **CREATE TASKS:** task tracking for ALL workflow/skill/custom steps before execution when the selected path has multiple steps.
7306. **PARALLELIZE:** Before executing the task list, tag each task `PAR` (independent inputs + write set disjoint from every other `PAR` task) or `SEQ` (name the blocking dependency), group `PAR` tasks into waves, declare the wave plan, and spawn each wave's sub-agents in ONE message — all-return barrier per wave, fan-out one level deep unless a sub-agent's own definition authorizes further fan-out. Sequential-by-default is a defect when tasks are independent; do not parallelize shared write targets, output-consuming tasks, trivial single-file work, ordering a skill or workflow explicitly fixes, or user-approval gates.
7317. **EXECUTE:** Advance per the **Workflow Step Advancement & Parallel Phases** rule in your context instructions — model-driven; a sub-agent completion advances a step identically to an inline call; a parallel-phase group is an all-return barrier (advance only after ALL members return, never serialize it)
732
733## Shared AI-SDD Protocol Markers
734
735Source: `.claude/skills/shared/sync-inline-versions.md`
736
737## SYNC:ai-sdd-artifact-contract
738
739> **AI-SDD Artifact Contract** — Shared spec-driven development rules stay portable and source-owned.
740>
741> 1. Keep reusable AI-SDD principles in `.claude`; put repository-specific paths, commands, owners, products, and formats in project config/reference docs.
742> 2. Preserve cycle: `spec -> plan -> tasks -> implement -> verify -> update spec/docs`.
743> 3. Trace every requirement or invariant through decision, task, TC/test, source evidence, and docs/spec update.
744> 4. Treat code-to-spec extraction as reference-only until accepted by the canonical spec owner.
745> 5. Any supported AI tool may plan, implement, review, or verify with synced context; using multiple tools is optional.
746> 6. Update `.claude` source first, then sync generated mirrors; do not manually edit `.agents`, `.codex`, or `AGENTS.md`. — why: mirrors are generated artifacts; hand-edits are overwritten on the next sync
747> 7. If `docs/project-config.json`, root instruction files, or a required project-reference doc is missing or stale, auto-run `$project-init` or the narrow lower-level route before ordinary project-specific work.
748>
749> **Active reference:** `shared/sdd-artifact-contract.md` in the active skills root.
750
751---
752
753## SYNC:ai-sdd-artifact-contract:reminder
754
755- **MANDATORY** Apply `shared/sdd-artifact-contract.md`; keep reusable AI-SDD in `.claude` and local rules in project docs.
756- **MANDATORY** Code-to-spec extraction is reference-only until canonical acceptance; any supported AI tool may execute with synced context.
757- **MANDATORY** Update `.claude` source before syncing generated mirrors; do not manually edit `.agents`, `.codex`, or `AGENTS.md`.
758- **MANDATORY** Missing or stale project config, root instruction files, or required reference docs route project-specific work through `$project-init` or the narrow setup route automatically.
759 **[TASK-PLANNING] [MANDATORY]** BEFORE executing any workflow or skill step, create/update task tracking for all planned steps, then keep it synchronized as each step starts/completes.
760
761## [LESSON-LEARNED-REMINDER] [BLOCKING] Task Planning & Continuous Improvement — MANDATORY. Do not skip.
762
763Break work into small tasks (task tracking) before starting. Add final task: "Analyze AI mistakes & lessons learned".
764
765**Extract lessons — ROOT CAUSE ONLY, not symptom fixes:**
766
7671. Name the FAILURE MODE (reasoning/assumption failure), not symptom — "assumed API existed without reading source" not "used wrong enum value".
7682. Generality test: does this failure mode apply to ≥3 contexts/codebases? If not, abstract one level up.
7693. Write as a universal rule — strip project-specific names/paths/classes. Useful on any codebase.
7704. Consolidate: multiple mistakes sharing one failure mode → ONE lesson.
7715. **Recurrence gate:** "Would this recur in future session WITHOUT this reminder?" — No → skip `$learn`.
7726. **Auto-fix gate:** "Could `$code-review`/`$code-simplifier`/`$security-review`/`$lint` catch this?" — Yes → improve review skill instead.
7737. BOTH gates pass → ask user to run `$learn`.
774 **[CRITICAL-THINKING-MINDSET]** Apply critical thinking, sequential thinking. Every claim needs traced proof, confidence >80% to act.
775 **Anti-hallucination principle:** Never present guess as fact — cite sources for every claim, admit uncertainty freely, self-check output for errors, cross-reference independently, stay skeptical of own confidence — certainty without evidence root of all hallucination.
776 **AI Attention principle (Primacy-Recency):** Put the 3 most critical rules at both top and bottom of long prompts/protocols so instruction adherence survives long context windows.
777 **Goal-driven execution:** Define success criteria first, loop until verified, and stop only when observable checks pass.
778 **Tests verify intent:** Tests must protect business rules/invariants and fail when the protected intent breaks, not only mirror current behavior.
779
780## Common AI Mistake Prevention (System Lessons)
781
782- **Re-read files after context compaction.** Edit requires prior Read in same context; compaction wipes read state. Re-read before editing.
783- **Grep for old terms after bulk replacements.** AI over-trusts find/replace completeness. Grep full repo after bulk edits for missed refs in docs/configs/catalogs.
784- **Check downstream references before deleting.** Deletions cascade doc/code staleness. Map referencing files before removal.
785- **After memory loss, check existing state before creating new.** Compaction wipes prior-work memory. Query current state to resume — never blindly duplicate.
786- **Verify AI-generated content against actual code.** AI hallucinates APIs, class names, method signatures. Grep to confirm existence before documenting/referencing.
787- **Trace full dependency chain after edits.** Changing a definition misses downstream consumers. Trace the full chain.
788- **When renaming, grep ALL consumer file types.** Some file types silently ignore missing refs (no compile error). Search code, templates, configs, generated files.
789- **Trace ALL code paths when verifying correctness.** Code existing ≠ code executing. Trace early exits, error branches, conditional skips — not just happy path.
790- **Update docs that embed canonical data when source changes.** Docs inlining derived data (workflows, schemas, configs) go stale silently. Update all embedding docs alongside source.
791- **Verify sub-agent results after context recovery.** Background agents may finish while parent compacted — grep-verify output, don't trust assumed completion.
792- **Cross-check full target list against sub-agent assignments.** Parallel sub-agents by category miss boundary items. Reconcile union of assignments against target list before proceeding.
793- **Sub-agents inherit knowledge only from their agent .md definition — use custom agent types, not built-in Explore.** Tool adoption = permission + knowledge + enforcement (numbered workflow step).
794- **Persist sub-agent findings incrementally, not as a final batch.** Long sub-agents hit cutoffs before final write — findings lost. Instruct append-per-section to report file.
795- **When debugging, ask "whose responsibility?" before fixing.** Trace caller (wrong data) vs callee (wrong handling). Fix at responsible layer — never patch symptom site.
796- **Test failure → record a provisional verdict before trace/edit, then investigate.** Use the full five-way taxonomy: SOURCE-WRONG (production violates intent), TEST-WRONG (assertion/setup is stale), TEST-NOT-OPTIMAL (valid but fragile or low-signal test), ENVIRONMENT-BLOCKED (external state prevents a verdict), or AMBIGUOUS (intent/evidence cannot choose safely). Then trace root cause and triangulate against the governing spec (`docs/specs/**` if one exists) AND source. NEVER weaken an assertion, add a skip, relax a timeout, or change source merely to force green.
797- **Grep ALL removed names after extraction/refactoring.** Primary file "done" ≠ secondary files clean. Grep entire scope for every removed symbol before declaring complete.
798- **Assume existing values are intentional — ask WHY before changing OR flagging one as a defect.** Pattern-matching as "wrong" skips context. Before changing or reporting any constant/limit/flag/cutoff: read comments, git blame, the CALLER's ordering (the guarantee that makes the value correct usually lives in code running immediately BEFORE the cited line), and 2+ sibling call sites of the same convention. A doc stating WHAT without WHY is missing rationale, not proof of a missing guard — and in a validation pass, an accurate `file:line` citation proves the transcription, never the defect.
799- **Verify ALL affected outputs, not just the first.** One build green ≠ all green. Multi-stack changes (backend/frontend/tests/docs) require verifying EVERY output.
800- **Evaluate fit before copying a nearby pattern.** Closest example ≠ matching preconditions — verify the new context shares the same constraints, base classes, scope, lifetime.
801- **Holistic-first debugging — resist nearest-attention trap.** Don't dive into first plausible cause. List EVERY precondition (config, env vars, paths, DB, endpoints, creds, versions, DI, data). Verify each against evidence (grep/query — not reasoning). Ask "what would falsify this?" — if nothing, it's not a hypothesis. Most expensive failure: going deeper in "obvious" layer while bug sits in layer never questioned.
802- **Surgical changes — apply the diff test (context-aware).** Two modes: (1) Bug fix → every line traces to the bug; no restyling; orphan cleanup only for imports YOUR changes made unused. (2) Review/enhancement → implement improvements AND announce as "Enhancement beyond main request: [what]". Never silently scope-creep. Diff test: "Would this line exist if I wasn't asked to do X?" — if no, delete or announce.
803- **Surface ambiguity before coding — don't pick silently.** Multiple valid interpretations → present each with effort: "[Request] could mean (1) [N h], (2) [N h]. Which matters?" List scope/format/volume/constraints assumptions first. If simpler path exists, say so. Never silently pick.
804- **[MANDATORY FIRST ACTION] ALWAYS activate a suitable skill or workflow BEFORE responding.** Match task against workflow catalog + skill list; invoke via skill invocation or `$start-workflow <workflowId>`. NEVER answer or write code before checking. Skip = protocol violation.
805- **Why-Review adversarial mindset — apply when reviewing any plan, decision, or design.** Default SKEPTIC not VALIDATOR: steel-man a rejected alternative, invert each stated reason ("what does it sacrifice?"), stress-test top 2-3 assumptions, run pre-mortem ("ships, fails in 3 months — what breaks?"), surface 1-2 alternatives author missed. Section presence ≠ quality; quality = causal reasoning + concrete mitigations + evidence, not "it's better" or "monitor closely".
806- **Front-load report-write in sub-agent prompts for large reviews.** Many-file sub-agents hit budget before final write — findings lost. Design prompts so: (1) report-write is first explicit deliverable, (2) append per-file/section (not batched), (3) scope bounded so reads don't exhaust budget. Truncated mid-sentence with no report file → spawn narrower scope, don't retry same prompt.
807- **After context compaction, re-verify all prior phase outcomes before continuing.** Summaries describe intent, not environment state (git index, filesystem, processes). On resume, FIRST audit: git status, re-read modified files, verify filesystem. Every "completed" claim is an untested hypothesis until evidence confirms.
808- **OOM/memory: check row count before row size.** Triage: (1) Unbounded query — no DB filter for trigger? Push filter to DB; eliminates OOM. (2) Large rows? Projection reduces proportionally. Row reduction > projection in ROI.
809- **Assert the outcome your system OWNS, never the intermediate state your INFRASTRUCTURE owns.** When testing anything asynchronous (queue/broker delivery, retries, background jobs, caches, replication), assert the final business/entity state. NEVER assert the delivery bookkeeping — consume/send status, attempt counts, last-error, row existence or counts in a broker, scheduler, or outbox/inbox table. That bookkeeping lives in shared infrastructure that ANY co-running process (a peer worker, a second replica, a leftover local container) can write, usually under a deterministic shared key, so the assertion silently tests the developer's environment instead of the system: green when run alone, flaky the instant anything else shares that broker + database. Gate question for every assertion: "would this hold no matter WHICH process did the work?" — if no, assert the converged data state instead. Corollary: process-local fault injection and in-process telemetry cannot gate work any process may perform — use them as stress amplifiers (arm → bounded window → disarm → assert convergence), never as preconditions.
810- **Keep domain concepts out of generic/shared/infrastructure layers.** Reusable layer (shared library, framework, infra module) must reference NO consumer-specific domain concept — tenant/customer/product IDs, business entities, feature rules. Leak compiles + runs → passes review silently while coupling the "reusable" layer to one consumer. Keep shared type domain-free; push domain fields/logic down into the consumer via subclass/composition. — why: a layer coupled to one consumer's domain is no longer reusable.
811
812<!-- CODEX:SYNC-PROMPT-PROTOCOLS:END -->