@cleocode/skills 2026.5.84 → 2026.5.87

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 (47) hide show
  1. package/package.json +1 -1
  2. package/skills/ct-adr-recorder/SKILL.md +74 -0
  3. package/skills/ct-adr-recorder/__tests__/skill-adr-recorder.test.ts +65 -0
  4. package/skills/ct-docs-lookup/SKILL.md +116 -1
  5. package/skills/ct-docs-lookup/references/ctx7-workflow.md +198 -0
  6. package/skills/ct-docs-lookup/references/library-id-resolution.md +217 -0
  7. package/skills/ct-docs-lookup/references/version-specific-docs.md +220 -0
  8. package/skills/ct-docs-review/SKILL.md +133 -1
  9. package/skills/ct-docs-review/__tests__/skill-docs-review.test.ts +53 -0
  10. package/skills/ct-docs-review/references/inline-comment-patterns.md +268 -0
  11. package/skills/ct-docs-review/references/pr-review-mode.md +270 -0
  12. package/skills/ct-docs-review/references/style-violations.md +341 -0
  13. package/skills/ct-docs-write/SKILL.md +157 -1
  14. package/skills/ct-docs-write/__tests__/skill-docs-write.test.ts +55 -0
  15. package/skills/ct-docs-write/references/audience-targeting.md +305 -0
  16. package/skills/ct-docs-write/references/cleo-style-guide.md +234 -0
  17. package/skills/ct-docs-write/references/markdown-patterns.md +329 -0
  18. package/skills/ct-documentor/SKILL.md +11 -0
  19. package/skills/ct-documentor/references/anti-patterns.md +216 -0
  20. package/skills/ct-documentor/references/chain-orchestration.md +194 -0
  21. package/skills/ct-documentor/references/doc-types-and-templates.md +301 -0
  22. package/skills/ct-documentor/references/style-coordination.md +195 -0
  23. package/skills/ct-research-agent/SKILL.md +9 -0
  24. package/skills/ct-research-agent/references/anti-patterns.md +154 -0
  25. package/skills/ct-research-agent/references/citation-and-evidence.md +140 -0
  26. package/skills/ct-research-agent/references/source-strategy.md +116 -0
  27. package/skills/ct-research-agent/references/triggers-and-routing.md +93 -0
  28. package/skills/ct-skill-validator/SKILL.md +19 -0
  29. package/skills/ct-skill-validator/scripts/check_depth.py +306 -0
  30. package/skills/ct-spec-writer/SKILL.md +71 -1
  31. package/skills/ct-spec-writer/__tests__/skill-spec-writer.test.ts +60 -0
  32. package/skills/ct-spec-writer/references/anti-patterns.md +176 -0
  33. package/skills/ct-spec-writer/references/rfc2119-language.md +138 -0
  34. package/skills/ct-spec-writer/references/spec-templates.md +233 -0
  35. package/skills/ct-spec-writer/references/traceability-matrix.md +145 -0
  36. package/skills/ct-task-executor/SKILL.md +10 -0
  37. package/skills/ct-task-executor/references/acceptance-criteria-mapping.md +163 -0
  38. package/skills/ct-task-executor/references/anti-patterns.md +201 -0
  39. package/skills/ct-task-executor/references/common-failures.md +193 -0
  40. package/skills/ct-task-executor/references/evidence-and-gates.md +179 -0
  41. package/skills/ct-task-executor/references/implementation-patterns.md +160 -0
  42. package/skills/ct-validator/SKILL.md +9 -0
  43. package/skills/ct-validator/references/anti-patterns.md +194 -0
  44. package/skills/ct-validator/references/compliance-reports.md +199 -0
  45. package/skills/ct-validator/references/schema-checking.md +191 -0
  46. package/skills/ct-validator/references/validation-modes.md +185 -0
  47. package/skills/manifest.json +46 -8
@@ -0,0 +1,163 @@
1
+ # Acceptance Criteria Mapping
2
+
3
+ Every CLEO task ships with explicit acceptance criteria (ACs) — usually
4
+ 3-6 pipe-separated entries on the task's `acceptance` field. The executor's
5
+ job is to map each AC to a verifiable deliverable, exercise it, and report
6
+ the mapping in the manifest. This reference defines the mapping discipline.
7
+
8
+ ## Read the Whole AC Set First
9
+
10
+ Before touching code, run `cleo show <TASK_ID>` and copy the full `acceptance`
11
+ array into your scratch notes. Do not start with a partial reading — ACs
12
+ interact, and some only make sense in light of others.
13
+
14
+ Example AC set (from T9660):
15
+
16
+ ```text
17
+ 1. packages/skills/skills/ct-research-agent/references/ created with 4 files (...)
18
+ 2. each reference doc is >=50 lines of genuine multi-source research guidance (...)
19
+ 3. SKILL.md updated to link references via standard 'See references/' resolution pattern
20
+ 4. packages/skills/skills/manifest.json references array updated to enumerate all reference files
21
+ 5. skill body >=10K bytes per gold standard; load-time token budget verified <=8000
22
+ 6. Code placed in packages/skills/ per Package-Boundary Check - verified against AGENTS.md
23
+ ```
24
+
25
+ This task has six ACs — three structural (1, 4, 6), two content-quality
26
+ (2, 5), and one cross-link (3). The implementation must touch all of them.
27
+
28
+ ## Build a Mapping Table
29
+
30
+ For each AC, identify the deliverable and the verification mechanism.
31
+ Write the table to your scratch first — do not start implementing until
32
+ every AC has a row.
33
+
34
+ | AC | Deliverable | Verification |
35
+ |----|-------------|--------------|
36
+ | AC1 | 4 .md files under references/ | `ls` + filename match |
37
+ | AC2 | ≥50 lines each, genuine content | `wc -l` + manual review |
38
+ | AC3 | SKILL.md footer with "See references/" | grep for footer block |
39
+ | AC4 | manifest.json `references` array populated | `jq` extract + length |
40
+ | AC5 | Skill body ≥10K bytes | `wc -c packages/.../SKILL.md` |
41
+ | AC6 | Files placed in packages/skills/ | path inspection |
42
+
43
+ The verification column MUST yield a yes/no answer — not "looks good".
44
+ If an AC cannot be reduced to a mechanical check, push back to the
45
+ orchestrator: "AC-N is not testable; please clarify the success
46
+ condition."
47
+
48
+ ## AC Categories and Standard Verifications
49
+
50
+ | Category | Signal phrases | Standard verification |
51
+ |----------|----------------|----------------------|
52
+ | Existence | "created", "added", "exists" | `ls`, `stat`, `[ -f path ]` |
53
+ | Count | "with N files", "≥3 entries" | `find -type f | wc -l` |
54
+ | Length/size | "≥50 lines", "≥10K bytes" | `wc -l`, `wc -c` |
55
+ | Linkage | "linked from", "referenced in" | `grep -F` |
56
+ | Tests pass | "all tests pass", "no regressions" | `pnpm run test` |
57
+ | Lint clean | "biome check passes" | `pnpm biome check .` |
58
+ | Build clean | "compiles", "type-checks" | `pnpm run build && pnpm run typecheck` |
59
+ | Spec match | "satisfies REQ-NNN" | manual trace + test |
60
+ | Boundary | "placed in packages/X per Package-Boundary Check" | path inspection |
61
+ | Provenance | "commit message includes task ID" | `git log --grep=<TID>` |
62
+
63
+ When an AC mentions "Package-Boundary Check", you MUST cite the AGENTS.md
64
+ section by name in the manifest's `key_findings` — the orchestrator
65
+ greps for that compliance phrase.
66
+
67
+ ## Acceptance Criteria Anti-Patterns
68
+
69
+ These shapes signal that the AC needs refinement before execution.
70
+
71
+ | Anti-pattern AC | Why it fails | What to ask the orchestrator |
72
+ |-----------------|--------------|------------------------------|
73
+ | "Implementation works as expected" | Not testable | What is the expected behavior? |
74
+ | "User experience improved" | Subjective | Which metric should improve and by how much? |
75
+ | "Performance is good" | No baseline | What's the target latency / throughput? |
76
+ | "Documentation updated" | Which docs? | Specific file paths or section names? |
77
+ | "No regressions" | Whole-suite test or focused? | Which test files must pass? |
78
+
79
+ When an AC is fuzzy, push back BEFORE starting. The orchestrator can
80
+ refine the AC; rework caused by guessing the AC is much more expensive.
81
+
82
+ ## Pre-Flight: AC → Test Mapping
83
+
84
+ Before writing implementation code, for each AC that mentions testable
85
+ behavior, identify or create the test that exercises it.
86
+
87
+ ```bash
88
+ # AC-7: "the new release-plan verb errors with E_VALIDATION on missing --epic"
89
+
90
+ # Find existing test file
91
+ find packages/cleo -path '*/release-plan*' -name '*.test.ts'
92
+
93
+ # If no test exists yet, create the skeleton
94
+ cat > packages/cleo/__tests__/release-plan.test.ts <<'EOF'
95
+ import { describe, it, expect } from "vitest";
96
+ describe("release-plan", () => {
97
+ it("errors with E_VALIDATION on missing --epic", () => {
98
+ // RED — test fails until handler exists
99
+ });
100
+ });
101
+ EOF
102
+ ```
103
+
104
+ Run the test now — it should fail (the implementation is not there yet).
105
+ This confirms your mapping: the test exercises the right AC.
106
+
107
+ ## During Implementation
108
+
109
+ Keep the mapping table open in your scratch. After each significant edit,
110
+ re-run the verification for the AC you just touched. Do not let mappings
111
+ drift — if you discover an AC requires a different deliverable than you
112
+ planned, update the table BEFORE making the change.
113
+
114
+ ## Post-Implementation: AC Verification Walkthrough
115
+
116
+ Before calling `cleo verify` or `cleo complete`, execute every verification
117
+ in the table.
118
+
119
+ ```bash
120
+ # AC1: 4 files exist
121
+ ls packages/skills/skills/ct-research-agent/references/ | wc -l
122
+ # expect: 4
123
+
124
+ # AC2: each ≥50 lines
125
+ wc -l packages/skills/skills/ct-research-agent/references/*.md
126
+ # expect: each line count >= 50
127
+
128
+ # AC3: SKILL.md has footer
129
+ grep -q "## See references/" packages/skills/skills/ct-research-agent/SKILL.md
130
+ # expect: exit 0
131
+
132
+ # AC4: manifest.json references array populated
133
+ jq '.skills[] | select(.name=="ct-research-agent") | .references | length' \
134
+ packages/skills/skills/manifest.json
135
+ # expect: 4
136
+
137
+ # AC5: skill body ≥10K bytes
138
+ wc -c packages/skills/skills/ct-research-agent/SKILL.md
139
+ # expect: byte count >= 10000
140
+
141
+ # AC6: path inspection
142
+ echo "All files under packages/skills/ — confirms Package-Boundary Check"
143
+ ```
144
+
145
+ ## Manifest Reporting
146
+
147
+ The pipeline_manifest entry's `key_findings` MUST report AC outcomes
148
+ concisely. Use this shape:
149
+
150
+ ```json
151
+ {
152
+ "key_findings": [
153
+ "AC1-4 met: 4 reference files created (triggers, source, citation, anti-patterns)",
154
+ "AC2 met: line counts 116/93/140/154 (all >=50)",
155
+ "AC3-4 met: SKILL.md footer added; manifest references[] populated",
156
+ "AC5 verified: skill body 11.2KB",
157
+ "AC6 verified: all files under packages/skills/ per AGENTS.md"
158
+ ]
159
+ }
160
+ ```
161
+
162
+ If any AC failed or was partial, surface it. Silent partial completion
163
+ breaks the orchestrator's rollup logic.
@@ -0,0 +1,201 @@
1
+ # Anti-Patterns
2
+
3
+ The instant-rejection list for executor work — from AGENTS.md
4
+ "Anti-Patterns (INSTANT REJECTION)" plus session-observed additions.
5
+ Each anti-pattern is testable by the orchestrator's reviewer; do not
6
+ ship work that contains any of these.
7
+
8
+ ## 1. Test Theater
9
+
10
+ **Anti-pattern.** Claiming "tests pass" without actually running
11
+ `pnpm run test`.
12
+
13
+ **Detection.** Manifest reports `testsPassed: true` but no
14
+ `tool:test` evidence atom; or evidence atom references a stale cache
15
+ key.
16
+
17
+ **Cost.** Reviewer must reject and re-spawn the work, doubling the
18
+ token spend on the task.
19
+
20
+ **Correct pattern.** Always run tests, capture the exit code, and pass
21
+ `--evidence "tool:test"` to `cleo verify`. The cache will skip re-running
22
+ if state is unchanged; running it is free.
23
+
24
+ ## 2. Workaround Over Root Cause
25
+
26
+ **Anti-pattern.** Adding `// @ts-ignore`, `eslint-disable-next-line`, or
27
+ `as unknown as X` chains to suppress an error rather than fixing it.
28
+
29
+ **Detection.** Suppression comments or escape-hatch casts in the diff.
30
+
31
+ **Cost.** Technical debt accumulates; the actual contract violation
32
+ remains; the next worker encounters the same problem.
33
+
34
+ **Correct pattern.** Diagnose the type/lint failure; update the
35
+ contract in `packages/contracts/` or fix the source. Suppression is
36
+ permitted only with an inline TODO referencing a follow-up task ID,
37
+ e.g., `// @ts-ignore — TODO(T9999): legacy adapter pending refactor`.
38
+
39
+ ## 3. Skipped Lint/Format
40
+
41
+ **Anti-pattern.** Committing without `pnpm biome check --write .`,
42
+ producing a diff with unrelated whitespace or import-order churn that
43
+ biome would normalize.
44
+
45
+ **Detection.** Reviewer's `pnpm biome check .` (in CI) reports
46
+ violations on lines the worker did not intentionally touch.
47
+
48
+ **Cost.** Biome's auto-fix produces large drive-by diffs in the next
49
+ PR; review noise drowns the actual change.
50
+
51
+ **Correct pattern.** Run `pnpm biome check --write .` BEFORE every
52
+ commit. Make biome's output part of the commit, not a follow-up cleanup.
53
+
54
+ ## 4. New File Where Existing Suffices
55
+
56
+ **Anti-pattern.** Creating a new helper file when the existing utility
57
+ module could be extended.
58
+
59
+ **Detection.** Diff contains a new file in `src/` that exports a single
60
+ function which logically belongs alongside existing functions in a
61
+ sibling file.
62
+
63
+ **Cost.** Code duplication; future maintainers do not find the helper
64
+ because the search lands on the older file.
65
+
66
+ **Correct pattern.** Before creating any new file, run
67
+ `Grep "<related-keyword>" packages/<pkg>/src/` and add to the most
68
+ related existing module. NEVER create files unless they are absolutely
69
+ necessary.
70
+
71
+ ## 5. `catch (err: unknown)`
72
+
73
+ **Anti-pattern.** Wrapping a function body in `try { ... } catch (err:
74
+ unknown) { ... }` and then casting `err` to read its `.message`.
75
+
76
+ **Detection.** Grep for `catch (err: unknown)` or `catch (e: unknown)`.
77
+
78
+ **Cost.** Defeats type narrowing; hides real error types; AGENTS.md
79
+ explicitly bans this.
80
+
81
+ **Correct pattern.** Use the contract's typed error classes from
82
+ `packages/contracts/src/errors.ts`. Throw and catch by class, not by
83
+ the generic `Error` shape.
84
+
85
+ ```typescript
86
+ import { TaskNotFoundError, ValidationError } from "@cleocode/contracts";
87
+ try {
88
+ ...
89
+ } catch (err) {
90
+ if (err instanceof TaskNotFoundError) { ... }
91
+ if (err instanceof ValidationError) { ... }
92
+ throw err; // re-throw unknown
93
+ }
94
+ ```
95
+
96
+ ## 6. console.log in Production Code
97
+
98
+ **Anti-pattern.** Leftover `console.log("debug:", x)` after debugging.
99
+
100
+ **Detection.** `pnpm biome check .` flags it; grep for `console.log`
101
+ in `src/` (test files may legitimately log).
102
+
103
+ **Cost.** Spam in user-facing CLI output; potential PII leakage.
104
+
105
+ **Correct pattern.** Remove debug logs before commit. For genuine
106
+ operational logging, use the project's logger (LAFS envelope meta
107
+ field, or `packages/core/src/log/` if present).
108
+
109
+ ## 7. Import Without Boundary Check
110
+
111
+ **Anti-pattern.** Adding an import that creates a circular dependency
112
+ or crosses a package boundary the consumer does not declare.
113
+
114
+ **Detection.** `pnpm run build` fails with module-resolution error, or
115
+ the build succeeds locally but CI's clean install fails.
116
+
117
+ **Cost.** CI-only failure; PR cannot land.
118
+
119
+ **Correct pattern.** Before adding an import: (a) check if the source
120
+ package is in the consumer's `package.json` dependencies; (b) if it's
121
+ a relative import within the same package, check for cycles by reading
122
+ the source's imports too.
123
+
124
+ ## 8. Test Expectation Modification
125
+
126
+ **Anti-pattern.** A test fails; instead of fixing the implementation,
127
+ the worker modifies the test's expected value to match the actual
128
+ output.
129
+
130
+ **Detection.** Diff modifies `expect(x).toBe(...)` or `toMatchSnapshot()`
131
+ inputs in a test file without corresponding implementation changes.
132
+
133
+ **Cost.** Test no longer guards the original contract; the regression
134
+ ships silently.
135
+
136
+ **Correct pattern.** Determine which is wrong — the test or the
137
+ implementation. If the test was wrong (spec changed, contract updated),
138
+ update the test AND the source AND the spec. Never change the test
139
+ alone.
140
+
141
+ ## 9. Worktree Boundary Violation
142
+
143
+ **Anti-pattern.** Editing files outside the worktree path the spawn
144
+ prompt assigned.
145
+
146
+ **Detection.** The git shim blocks most operations; if it slips
147
+ through, the change does not land in the PR.
148
+
149
+ **Cost.** Lost work; integration confusion; potential corruption of
150
+ sibling worker's branch.
151
+
152
+ **Correct pattern.** First action is `cd <worktree-path>`. All
153
+ subsequent paths SHOULD be absolute within the worktree. Use
154
+ `git rev-parse --show-toplevel` to confirm cwd if uncertain.
155
+
156
+ ## 10. Self-Attestation Without Proof
157
+
158
+ **Anti-pattern.** "I completed the task" returned to the orchestrator
159
+ without `cleo verify` evidence atoms.
160
+
161
+ **Detection.** Manifest entry lacks evidence; `cleo show <id>` shows
162
+ gates pending; orchestrator cannot programmatically confirm completion.
163
+
164
+ **Cost.** Orchestrator must re-verify manually; if the work was not
165
+ actually done, the rollback is much more expensive.
166
+
167
+ **Correct pattern.** ADR-051 ritual. Every gate gets evidence; verify
168
+ re-validates programmatically. Self-attestation without atoms is
169
+ rejected by the post-ADR-051 system.
170
+
171
+ ## 11. Skipped Memory Observation
172
+
173
+ **Anti-pattern.** Non-trivial task completed; session ends; nothing
174
+ new in BRAIN.
175
+
176
+ **Detection.** `cleo memory find <task-topic>` returns no new
177
+ observations from this session.
178
+
179
+ **Cost.** The next session relearns the same lesson; institutional
180
+ knowledge does not accumulate.
181
+
182
+ **Correct pattern.** After every non-trivial complete:
183
+
184
+ ```bash
185
+ cleo memory observe "<learning, 1-2 sentences>" --title "<short title>"
186
+ ```
187
+
188
+ The CLEO-INJECTION.md trigger row says this explicitly. Honor it.
189
+
190
+ ## 12. Premature `cleo complete`
191
+
192
+ **Anti-pattern.** Calling `cleo complete` before all gates have been
193
+ verified, on the theory that the worker can verify in parallel.
194
+
195
+ **Detection.** Exit code 80 (`E_LIFECYCLE_GATE_FAILED`) or
196
+ `E_EVIDENCE_MISSING`.
197
+
198
+ **Cost.** Failed complete; worker must back out, re-verify, re-complete.
199
+
200
+ **Correct pattern.** Verify all six gates first; complete last. The
201
+ verify steps are fast (cached) and idempotent. No reason to skip.
@@ -0,0 +1,193 @@
1
+ # Common Failures
2
+
3
+ The most frequent worker-agent failure modes observed across CLEO
4
+ sessions. Each entry includes a recognition signal, the root cause, and
5
+ the corrected approach. Many of these are recorded in BRAIN observations
6
+ under `O-*` IDs.
7
+
8
+ ## False Success Reports
9
+
10
+ **Symptom.** Worker returns "Task complete. All tests pass." The
11
+ orchestrator later finds (via `cleo show <id>` showing pending gates,
12
+ or `git log` showing no commits, or `pnpm test` showing failures) that
13
+ the work was not actually done.
14
+
15
+ **Recognition.** Reported success without (a) a commit SHA in the
16
+ response, (b) the test output excerpt, or (c) a `cleo verify` audit
17
+ trail.
18
+
19
+ **Root cause.** The worker conflated "I drafted code that should work"
20
+ with "I ran the tests and they passed." Often correlates with model
21
+ fatigue at >70% context utilization.
22
+
23
+ **Fix.** The worker MUST run the full quality-gate sequence (biome →
24
+ build → typecheck → test) and capture the exit codes / output before
25
+ reporting completion. The spawn prompt's tier-1+ injection contains this
26
+ ritual — re-read it if uncertain.
27
+
28
+ This failure mode was first formally documented in T1450 PROOF
29
+ (`spawn-capability-gap-2026-04-25.md` — historical context, the
30
+ underlying gap is now resolved but the pattern recurs at the worker
31
+ level).
32
+
33
+ ## Outside-Worktree Edits
34
+
35
+ **Symptom.** Worker edits files outside its assigned worktree path. The
36
+ git shim usually blocks this, but if it slips through, the change does
37
+ not get into the PR.
38
+
39
+ **Recognition.** Files appear modified in `/mnt/projects/cleocode/` but
40
+ not in the worktree's branch.
41
+
42
+ **Root cause.** Worker resolved a relative path against the wrong cwd
43
+ (persistent shell state was not reset between tool calls), or
44
+ deliberately followed an absolute path from a prior session's notes.
45
+
46
+ **Fix.** The spawn prompt's `FIRST ACTION: cd <path>` MUST be the first
47
+ command. All subsequent paths SHOULD be absolute within the worktree.
48
+ If unsure, prefix with `git rev-parse --show-toplevel` first.
49
+
50
+ ## Cherry-Pick Instead of Merge
51
+
52
+ **Symptom.** When integrating completed work to main, the worker (or
53
+ overzealous orchestrator) used `git cherry-pick` instead of
54
+ `git merge --no-ff`.
55
+
56
+ **Recognition.** `git log --grep "<task-id>"` shows different SHAs in
57
+ the task branch vs main. The author email is lost. `cleo find` cannot
58
+ relate commits to the task.
59
+
60
+ **Root cause.** Following a generalized "cherry-pick is safer" instinct
61
+ without reading ADR-062. The CLEO contract is that workers commit on
62
+ their task branch; the integrator MUST use `git merge --no-ff
63
+ task/<id>` to preserve SHAs, author identity, and the
64
+ `cleo find <task-id> --commits` trace.
65
+
66
+ **Fix.** Always `git merge --no-ff task/<TID>` for integration. See
67
+ `feedback_cherry_pick_worktrees.md` for the full pattern.
68
+
69
+ ## Hard Reset Disasters
70
+
71
+ **Symptom.** Multiple worktree-spawn agents working in parallel suddenly
72
+ find their work has vanished from main. The orchestrator's primary
73
+ working dir's branch is on main; an agent or the orchestrator ran
74
+ `git reset --hard origin/main`, wiping local commits that had not yet
75
+ been pushed.
76
+
77
+ **Recognition.** `git reflog` on the primary working dir shows a
78
+ recent `HEAD@{N}: reset: moving to origin/main`.
79
+
80
+ **Root cause.** The primary working dir's branch is shared across
81
+ parallel orchestrators. A reset there wipes shared state. Caught in
82
+ T9354 session and recovered via reflog cherry-pick — at the cost of 3
83
+ PRs.
84
+
85
+ **Fix.** NEVER `git reset --hard` on the orchestrator's primary working
86
+ dir while any worker agents are alive. Apply fixes from inside the
87
+ worker's worktree path, or use `git update-ref` + push to land
88
+ corrections without resetting the local branch.
89
+
90
+ ## ESM Import Path Drift
91
+
92
+ **Symptom.** Build fails locally with `ERR_MODULE_NOT_FOUND` or CI fails
93
+ with `Cannot find module './foo'` even though the file exists.
94
+
95
+ **Recognition.** Import line `import { foo } from "./foo";` (no
96
+ `.js` extension).
97
+
98
+ **Root cause.** The repo's TypeScript config uses pure ESM with explicit
99
+ `.js` extensions on imports. Stripping the extension works at write
100
+ time but fails at runtime under Node's strict ESM resolver.
101
+
102
+ **Fix.** Always include `.js` in relative imports — even for `.ts`
103
+ sources. The compiled output uses the same extension. Workspace imports
104
+ (`@cleocode/...`) do not need the extension.
105
+
106
+ ## Cross-Package Reach
107
+
108
+ **Symptom.** Worker imports across package boundaries without declaring
109
+ the dependency in the consumer's `package.json`. Build succeeds locally
110
+ (pnpm hoists) but CI fails on a clean install.
111
+
112
+ **Recognition.** Import like `import { thing } from "../../core/src/foo.js"`
113
+ inside `packages/cleo/`.
114
+
115
+ **Root cause.** Took a relative-path shortcut instead of using the
116
+ workspace import `@cleocode/core`. Also bypasses the type contract.
117
+
118
+ **Fix.** Add the consumer's `package.json` dependency and use the
119
+ workspace import:
120
+
121
+ ```typescript
122
+ import { thing } from "@cleocode/core/foo";
123
+ ```
124
+
125
+ If the function being imported is not exported from the consumer
126
+ package, add an export — do not reach through internals.
127
+
128
+ ## Type Cast Chains
129
+
130
+ **Symptom.** Code contains `as unknown as SomeType`, `any` types, or
131
+ empty `catch (err: unknown)` blocks. AGENTS.md type-safety rules ban
132
+ all three.
133
+
134
+ **Recognition.** `pnpm biome check` warnings on `any` / `unknown` usage,
135
+ or grep for `as unknown as`.
136
+
137
+ **Root cause.** Worker hit a type mismatch and reached for the escape
138
+ hatch instead of fixing the underlying contract.
139
+
140
+ **Fix.** Inspect the actual types; update or extend the contract in
141
+ `packages/contracts/src/` if necessary. The repo's policy is "find the
142
+ root cause" — type casts hide the cause and accumulate as debt.
143
+
144
+ ## Drive-By Refactors
145
+
146
+ **Symptom.** PR for T9660 includes unrelated changes to files outside
147
+ the task's scope. Reviewer comments "scope creep" and requests a split.
148
+
149
+ **Recognition.** `git diff --stat HEAD` shows files modified that do
150
+ not appear in the task's acceptance criteria.
151
+
152
+ **Root cause.** Worker noticed something to improve while reading
153
+ adjacent code and "fixed it in passing".
154
+
155
+ **Fix.** Revert unrelated changes; file a new task for them. One task =
156
+ one purpose = one PR. The CLEO contract relies on this for traceability.
157
+
158
+ ## Stale Cache Confusion
159
+
160
+ **Symptom.** `cleo complete` fails with `E_EVIDENCE_STALE` even though
161
+ the worker is sure they didn't touch the file after verify.
162
+
163
+ **Recognition.** Error message references a file the worker only read,
164
+ never edited.
165
+
166
+ **Root cause.** A formatter (biome auto-fix on save, or a sibling
167
+ agent's commit) modified the file between `cleo verify` and
168
+ `cleo complete`. The sha256 no longer matches.
169
+
170
+ **Fix.** Re-run `cleo verify` for the affected gate(s) before
171
+ `cleo complete`. Treat verify+complete as an atomic pair — minimize the
172
+ time between them.
173
+
174
+ ## Forgotten Memory Observation
175
+
176
+ **Symptom.** Task completed; the session ends; the next session
177
+ re-discovers a fact that should have been retained.
178
+
179
+ **Recognition.** `cleo memory find <topic>` after the task returns
180
+ nothing, even though the worker learned something non-trivial.
181
+
182
+ **Root cause.** Worker skipped the post-complete `cleo memory observe`
183
+ step (CLEO-INJECTION.md trigger row 2: "after non-trivial task
184
+ completion").
185
+
186
+ **Fix.** After every non-trivial `cleo complete`, run:
187
+
188
+ ```bash
189
+ cleo memory observe "<one-paragraph learning>" --title "<short title>"
190
+ ```
191
+
192
+ Trivial tasks (typo fix, version bump) do not need observations.
193
+ Anything that changed your mental model does.