@cleocode/skills 2026.5.83 → 2026.5.86

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 (55) hide show
  1. package/package.json +1 -1
  2. package/skills/_shared/__tests__/lifecycle-protocol-reconcile.test.ts +112 -0
  3. package/skills/_shared/__tests__/loom-adr-links.test.ts +163 -0
  4. package/skills/_shared/__tests__/loom-stage-coverage.test.ts +167 -0
  5. package/skills/ct-adr-recorder/SKILL.md +92 -0
  6. package/skills/ct-adr-recorder/__tests__/skill-adr-recorder.test.ts +65 -0
  7. package/skills/ct-consensus-voter/SKILL.md +14 -0
  8. package/skills/ct-contribution/SKILL.md +80 -0
  9. package/skills/ct-docs-lookup/SKILL.md +116 -1
  10. package/skills/ct-docs-lookup/references/ctx7-workflow.md +198 -0
  11. package/skills/ct-docs-lookup/references/library-id-resolution.md +217 -0
  12. package/skills/ct-docs-lookup/references/version-specific-docs.md +220 -0
  13. package/skills/ct-docs-review/SKILL.md +133 -1
  14. package/skills/ct-docs-review/__tests__/skill-docs-review.test.ts +53 -0
  15. package/skills/ct-docs-review/references/inline-comment-patterns.md +268 -0
  16. package/skills/ct-docs-review/references/pr-review-mode.md +270 -0
  17. package/skills/ct-docs-review/references/style-violations.md +341 -0
  18. package/skills/ct-docs-write/SKILL.md +157 -1
  19. package/skills/ct-docs-write/__tests__/skill-docs-write.test.ts +55 -0
  20. package/skills/ct-docs-write/references/audience-targeting.md +305 -0
  21. package/skills/ct-docs-write/references/cleo-style-guide.md +234 -0
  22. package/skills/ct-docs-write/references/markdown-patterns.md +329 -0
  23. package/skills/ct-documentor/SKILL.md +11 -0
  24. package/skills/ct-documentor/references/anti-patterns.md +216 -0
  25. package/skills/ct-documentor/references/chain-orchestration.md +194 -0
  26. package/skills/ct-documentor/references/doc-types-and-templates.md +301 -0
  27. package/skills/ct-documentor/references/style-coordination.md +195 -0
  28. package/skills/ct-epic-architect/SKILL.md +15 -0
  29. package/skills/ct-ivt-looper/SKILL.md +32 -0
  30. package/skills/ct-release-orchestrator/SKILL.md +16 -0
  31. package/skills/ct-research-agent/SKILL.md +24 -0
  32. package/skills/ct-research-agent/references/anti-patterns.md +154 -0
  33. package/skills/ct-research-agent/references/citation-and-evidence.md +140 -0
  34. package/skills/ct-research-agent/references/source-strategy.md +116 -0
  35. package/skills/ct-research-agent/references/triggers-and-routing.md +93 -0
  36. package/skills/ct-skill-validator/SKILL.md +19 -0
  37. package/skills/ct-skill-validator/scripts/check_depth.py +306 -0
  38. package/skills/ct-spec-writer/SKILL.md +86 -1
  39. package/skills/ct-spec-writer/__tests__/skill-spec-writer.test.ts +60 -0
  40. package/skills/ct-spec-writer/references/anti-patterns.md +176 -0
  41. package/skills/ct-spec-writer/references/rfc2119-language.md +138 -0
  42. package/skills/ct-spec-writer/references/spec-templates.md +233 -0
  43. package/skills/ct-spec-writer/references/traceability-matrix.md +145 -0
  44. package/skills/ct-task-executor/SKILL.md +25 -0
  45. package/skills/ct-task-executor/references/acceptance-criteria-mapping.md +163 -0
  46. package/skills/ct-task-executor/references/anti-patterns.md +201 -0
  47. package/skills/ct-task-executor/references/common-failures.md +193 -0
  48. package/skills/ct-task-executor/references/evidence-and-gates.md +179 -0
  49. package/skills/ct-task-executor/references/implementation-patterns.md +160 -0
  50. package/skills/ct-validator/SKILL.md +44 -0
  51. package/skills/ct-validator/references/anti-patterns.md +194 -0
  52. package/skills/ct-validator/references/compliance-reports.md +199 -0
  53. package/skills/ct-validator/references/schema-checking.md +191 -0
  54. package/skills/ct-validator/references/validation-modes.md +185 -0
  55. package/skills/manifest.json +82 -16
@@ -0,0 +1,145 @@
1
+ # Traceability Matrix
2
+
3
+ Every REQ in a CLEO spec MUST be traceable to (a) the source justifying
4
+ its existence and (b) the test that verifies its implementation. The
5
+ traceability matrix is the table that makes those links explicit and
6
+ machine-readable. Without it, specs decay — requirements survive
7
+ implementations they no longer reflect.
8
+
9
+ ## Three-Way Trace
10
+
11
+ A complete trace links three artifacts:
12
+
13
+ ```
14
+ [Source] ── justifies ──> [Requirement] ── verified by ──> [Test]
15
+ ```
16
+
17
+ - **Source.** The research finding, ADR, user need, or upstream spec that
18
+ motivates the requirement.
19
+ - **Requirement.** The REQ-NNN entry in this spec.
20
+ - **Test.** The test file/case that exercises the requirement.
21
+
22
+ Each link MUST be a stable identifier — not prose. "REQ-007 was discussed
23
+ in a meeting" is not a trace; "REQ-007 derives from ADR-065 §3" is.
24
+
25
+ ## The Matrix Block
26
+
27
+ Include this block in every spec, immediately before the `## Compliance`
28
+ section.
29
+
30
+ ```markdown
31
+ ## Traceability
32
+
33
+ | REQ | Source | Verification |
34
+ |-----|--------|--------------|
35
+ | REQ-001 | ADR-065 §3 | `packages/cleo/__tests__/release-pipeline.test.ts::cuts-from-main-tip` |
36
+ | REQ-002 | ADR-065 §3 | `packages/cleo/__tests__/release-pipeline.test.ts::refuses-direct-push` |
37
+ | REQ-003 | T9580 acceptance | `packages/cleo/__tests__/release-ship.test.ts::epic-completeness-check` |
38
+ | REQ-004 | RFC 7230 §3.2 | `packages/transport/__tests__/http.test.ts::header-canonicalization` |
39
+ | REQ-005 | (TODO: assign source) | (TODO: write test) |
40
+ ```
41
+
42
+ Rows with `(TODO: ...)` are acceptable in `draft` status, NOT in
43
+ `accepted`. A spec cannot move to `accepted` while any TODO row remains.
44
+
45
+ ## Source Token Conventions
46
+
47
+ The source column accepts these forms:
48
+
49
+ | Form | Example | When to use |
50
+ |------|---------|-------------|
51
+ | ADR reference | `ADR-065 §3` | Decision recorded in `.cleo/adrs/` |
52
+ | Spec reference | `Spec-foo v1.2 REQ-007` | Inherited from upstream spec |
53
+ | Task reference | `T9580 acceptance` | Direct from task acceptance criteria |
54
+ | Research reference | `.cleo/agent-outputs/2026-05-19_caching.md §Findings` | From research output |
55
+ | External standard | `RFC 7230 §3.2` | IETF / W3C / ISO standard |
56
+ | BRAIN reference | `D003` or `O-mpd07uma-0` | Stored decision or observation |
57
+ | User mandate | `Owner directive 2026-05-19` | Direct from user/owner |
58
+
59
+ The form `(meeting notes)` or `(slack thread)` is NOT acceptable — these
60
+ are ephemeral and not citable.
61
+
62
+ ## Verification Token Conventions
63
+
64
+ The verification column accepts these forms:
65
+
66
+ | Form | Example | Meaning |
67
+ |------|---------|---------|
68
+ | Test ID | `pkg/__tests__/foo.test.ts::case-name` | Unit/integration test exists |
69
+ | Eval ID | `eval-suite-x::scenario-7` | Agent eval covers this REQ |
70
+ | Manual procedure | `docs/qa/manual-release-checklist.md §A` | Human verification step |
71
+ | Tool gate | `pnpm run typecheck` | Toolchain enforces this REQ |
72
+ | Linter rule | `biome.json::rules.style.X` | Linter rule covers this REQ |
73
+
74
+ A REQ that cannot be verified is not a requirement — it is a wish.
75
+ Reject any REQ that lacks a verification plan during draft review.
76
+
77
+ ## Bidirectional Index
78
+
79
+ Large specs (more than 30 REQs) SHOULD include a reverse index from test
80
+ back to REQ, so a failing test can be located against its requirement
81
+ quickly.
82
+
83
+ ```markdown
84
+ ## Test → REQ Reverse Index
85
+
86
+ - `release-pipeline.test.ts::cuts-from-main-tip` → REQ-001
87
+ - `release-pipeline.test.ts::refuses-direct-push` → REQ-002
88
+ - `release-ship.test.ts::epic-completeness-check` → REQ-003
89
+ - `http.test.ts::header-canonicalization` → REQ-004
90
+ ```
91
+
92
+ Generate this manually for small specs; large specs SHOULD include a
93
+ script at `scripts/extract-trace.ts` that produces it from the forward
94
+ matrix.
95
+
96
+ ## Trace Health Metrics
97
+
98
+ A healthy spec has these properties — `ct-validator` reports on them.
99
+
100
+ | Metric | Healthy | Warning | Failure |
101
+ |--------|---------|---------|---------|
102
+ | REQs without source | 0 | 1-2 | 3+ |
103
+ | REQs without verification | 0 | 1-2 | 3+ |
104
+ | Tests not linked from any REQ | low | 10-25% | 25%+ |
105
+ | External standard refs | present | (n/a) | (n/a) |
106
+ | TODO rows in accepted spec | 0 | (cannot be) | any |
107
+
108
+ ## Drift Detection
109
+
110
+ When the implementation evolves, the matrix drifts. Detect drift with:
111
+
112
+ ```bash
113
+ # List tests that exist on disk
114
+ find packages -name "*.test.ts" -exec grep -l "REQ-" {} \;
115
+
116
+ # Compare to REQs claimed in the matrix
117
+ grep "^| REQ-" docs/specs/*.md
118
+
119
+ # Diff yields:
120
+ # - tests referencing REQs not in any matrix (orphan tests)
121
+ # - matrix REQs whose tests have disappeared (broken trace)
122
+ ```
123
+
124
+ This SHOULD run in CI on `pull_request` touching `docs/specs/**`. The
125
+ existing CI `skills` job (or a new `spec-trace-check` job) is the right
126
+ home — the workflow MUST fail when broken traces appear in `accepted`
127
+ specs.
128
+
129
+ ## Inheritance When Specs Refactor
130
+
131
+ When Spec-A is superseded by Spec-B, copy the matrix forward and add a
132
+ `Supersedes` column for the legacy REQ ID. This preserves test trace
133
+ across the rename.
134
+
135
+ ```markdown
136
+ | REQ (new) | Supersedes | Source | Verification |
137
+ |-----------|------------|--------|--------------|
138
+ | REQ-001 | Spec-A REQ-007 | ADR-065 §3 | test::cuts-from-main-tip |
139
+ | REQ-002 | Spec-A REQ-008 | ADR-065 §3 | test::refuses-direct-push |
140
+ | REQ-003 | (new) | T9580 | test::epic-completeness-check |
141
+ ```
142
+
143
+ The legacy spec MUST mark itself `deprecated` and link forward to the
144
+ successor. Never delete the legacy spec until all tests have been
145
+ re-attributed.
@@ -6,6 +6,10 @@ tier: 2
6
6
  core: true
7
7
  category: core
8
8
  protocol: implementation
9
+ loomStage: implementation
10
+ adrRefs:
11
+ - ADR-070
12
+ - ADR-062
9
13
  dependencies: []
10
14
  sharedResources:
11
15
  - subagent-protocol-base
@@ -294,3 +298,24 @@ cleo session gc --include-active
294
298
  | Partial deliverables | Missing outputs | Complete all or report partial |
295
299
  | Undocumented changes | Lost context | Write detailed output file |
296
300
  | Silent failures | Orchestrator unaware | Report via manifest status |
301
+
302
+ ---
303
+
304
+ ## See also / References
305
+
306
+ This skill binds to the **implementation** LOOM lifecycle stage. Governing ADRs:
307
+
308
+ - [ADR-070 — three-tier orchestration](../../../../.cleo/adrs/ADR-070-three-tier-orchestration.md) — defines the Worker tier that ct-task-executor occupies.
309
+ - [ADR-062 — worktree merge, not cherry-pick](../../../../.cleo/adrs/ADR-062-worktree-merge-not-cherry-pick.md) — defines the integration path that preserves the executor's commit SHAs end-to-end.
310
+
311
+ LOOM coverage matrix: [docs/skills/loom-coverage-matrix.md](../../../../docs/skills/loom-coverage-matrix.md).
312
+
313
+ ## See references/
314
+
315
+ Progressive disclosure — load on demand only:
316
+
317
+ - `references/implementation-patterns.md` — read-before-write, file-placement, ESM imports, quality-gate sequence
318
+ - `references/acceptance-criteria-mapping.md` — mapping table, AC categories, verification commands
319
+ - `references/evidence-and-gates.md` — ADR-051 atom shape, gate ritual, tool resolution + cache
320
+ - `references/common-failures.md` — twelve observed worker failure modes with corrected approach
321
+ - `references/anti-patterns.md` — instant-rejection patterns from AGENTS.md
@@ -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.