@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,176 @@
1
+ # Anti-Patterns
2
+
3
+ Common failure modes when writing CLEO specs. Each pattern degrades the
4
+ spec from a testable contract into prose. Detection cues and remediations
5
+ are listed; many of these were caught in past `ct-validator` reports and
6
+ in council reviews on previously-shipped specs.
7
+
8
+ ## 1. The Ambiguous MUST
9
+
10
+ **Symptom.** A requirement uses MUST but the failure condition cannot be
11
+ mechanically determined.
12
+
13
+ **Example (bad)**
14
+
15
+ > **REQ-005**: The system MUST handle errors gracefully.
16
+
17
+ **Detection cue.** Words like "gracefully", "appropriately", "reasonably",
18
+ "properly", "sensibly" appear in the requirement body.
19
+
20
+ **Remediation.** Replace fuzzy adverbs with measurable conditions.
21
+
22
+ > **REQ-005**: The system MUST return an LAFS envelope with
23
+ > `success: false` and `error.code` matching one of the registered
24
+ > error codes (see `packages/contracts/src/errors.ts`) on any failure
25
+ > reaching the command dispatcher.
26
+
27
+ ## 2. The Tautological Requirement
28
+
29
+ **Symptom.** The requirement restates the function's name.
30
+
31
+ **Example (bad)**
32
+
33
+ > **REQ-003**: The `validate()` function MUST validate the input.
34
+
35
+ **Detection cue.** The requirement body's main verb matches the
36
+ subject's name without adding constraint.
37
+
38
+ **Remediation.** State the contract — what defines successful validation,
39
+ what the function returns on failure, what side effects it has.
40
+
41
+ > **REQ-003**: The `validate()` function MUST return `{ ok: true }` if
42
+ > the input matches the schema, or `{ ok: false, errors: [...] }`
43
+ > containing one entry per violation otherwise. It MUST NOT mutate
44
+ > the input.
45
+
46
+ ## 3. The Compound Requirement
47
+
48
+ **Symptom.** A single REQ asserts multiple independent constraints joined
49
+ by "and" or commas.
50
+
51
+ **Example (bad)**
52
+
53
+ > **REQ-009**: The release pipeline MUST run lint, MUST run tests, MUST
54
+ > generate a changelog, AND MUST push the tag.
55
+
56
+ **Detection cue.** Multiple MUST/MUST NOT/SHOULD phrases in one REQ; or
57
+ "and" connecting verb phrases.
58
+
59
+ **Remediation.** Split into atomic REQs so each can be tested
60
+ independently and traced individually.
61
+
62
+ > **REQ-009**: The release pipeline MUST run lint.
63
+ > **REQ-010**: The release pipeline MUST run tests after lint passes.
64
+ > **REQ-011**: The release pipeline MUST generate a changelog.
65
+ > **REQ-012**: The release pipeline MUST push the tag only after all
66
+ > prior REQs in this sequence have passed.
67
+
68
+ ## 4. The Implementation Detail Spec
69
+
70
+ **Symptom.** The spec dictates HOW the implementation should work, not
71
+ WHAT it must achieve.
72
+
73
+ **Example (bad)**
74
+
75
+ > **REQ-014**: The cache MUST be implemented using a Map<string, Buffer>
76
+ > with LRU eviction.
77
+
78
+ **Detection cue.** Concrete data structures, library names, or algorithm
79
+ choices appear in MUST clauses.
80
+
81
+ **Remediation.** State the observable contract; let implementations
82
+ choose the structure.
83
+
84
+ > **REQ-014**: The cache MUST support O(1) lookup by string key.
85
+ > **REQ-015**: The cache MUST evict the least-recently-used entry when
86
+ > capacity is exceeded.
87
+
88
+ ## 5. The Untestable SHOULD
89
+
90
+ **Symptom.** SHOULD is used to mean "MAY" or to defer the test problem.
91
+
92
+ **Example (bad)**
93
+
94
+ > **REQ-017**: The orchestrator SHOULD be efficient.
95
+
96
+ **Detection cue.** SHOULD without a measurable cap, threshold, or
97
+ comparison.
98
+
99
+ **Remediation.** Either make it testable, or downgrade to MAY.
100
+
101
+ > **REQ-017**: The orchestrator SHOULD complete a 5-task wave dispatch
102
+ > within 2 seconds on the reference hardware (T9396).
103
+ > [— OR —]
104
+ > **REQ-017**: The orchestrator MAY parallelize wave dispatch.
105
+
106
+ ## 6. The Forgotten Edge Case
107
+
108
+ **Symptom.** The happy-path requirement is stated, but failure modes
109
+ (timeouts, partial completion, concurrent invocation) are unspecified.
110
+
111
+ **Detection cue.** No requirement mentions error codes, retries,
112
+ timeouts, or concurrent semantics — yet the implementation will face
113
+ all of these.
114
+
115
+ **Remediation.** For every operation, add at minimum:
116
+
117
+ - Timeout behavior (REQ: "after N seconds without progress, MUST return
118
+ E_TIMEOUT")
119
+ - Concurrent invocation (REQ: "MUST serialize concurrent calls per
120
+ resource ID")
121
+ - Partial state (REQ: "on failure mid-operation, MUST roll back to
122
+ pre-call state OR persist a recovery record")
123
+
124
+ ## 7. The Spec Without Conformance
125
+
126
+ **Symptom.** The spec has 20 REQs but no `## Compliance` section.
127
+
128
+ **Detection cue.** Last section heading is not `## Compliance`.
129
+
130
+ **Remediation.** Add the section. Without it, `ct-validator` cannot
131
+ produce pass/fail reports, and implementations cannot self-attest. A
132
+ spec without a compliance criteria block is unfinished.
133
+
134
+ ## 8. The Stealth Decision
135
+
136
+ **Symptom.** The spec contains a phrase like "we chose X over Y for
137
+ reasons A, B, C" — but that decision was not recorded in any ADR.
138
+
139
+ **Detection cue.** Spec body explains *why* a choice was made, instead
140
+ of *what* the requirement is.
141
+
142
+ **Remediation.** Pull the decision into a proper ADR. Reference the ADR
143
+ from the REQ's source column. The spec body asserts the requirement
144
+ flatly; the rationale lives in the ADR.
145
+
146
+ ## 9. The Drift-Prone Cross-Reference
147
+
148
+ **Symptom.** A REQ cross-references another section by prose ("as
149
+ discussed in the previous section") or by page number.
150
+
151
+ **Detection cue.** No `REQ-NNN` token in cross-references.
152
+
153
+ **Remediation.** Always reference by stable identifier — `REQ-001`,
154
+ `CON-007`, `§3.2`, `ADR-065`. Prose references rot when sections
155
+ reorder.
156
+
157
+ ## 10. The Version Hostage
158
+
159
+ **Symptom.** The spec hard-codes the version of a dependency or the
160
+ specific commit of an ADR that motivated it.
161
+
162
+ **Example (bad)**
163
+
164
+ > **REQ-021**: The pipeline MUST use drizzle-orm@1.0.0-beta.
165
+
166
+ **Detection cue.** Pinned version in a requirement body.
167
+
168
+ **Remediation.** Pin only the behavior; pin the version in the
169
+ implementation's manifest. If a specific version is genuinely required,
170
+ state the constraint as a range.
171
+
172
+ > **REQ-021**: The pipeline MUST use a Drizzle ORM release that
173
+ > supports `defineRelations` (introduced in v1.0.0-beta or later).
174
+
175
+ This preserves the spec across patch upgrades that do not change
176
+ contracts.
@@ -0,0 +1,138 @@
1
+ # RFC 2119 Language
2
+
3
+ The skill MUST use RFC 2119 keywords correctly. This reference defines each
4
+ keyword precisely, gives positive and negative examples, and lists the
5
+ common misuses that downstream test writers and validators catch most
6
+ often. A spec is only as testable as its language is unambiguous.
7
+
8
+ ## The Five Keywords
9
+
10
+ | Keyword | Synonyms | Precise meaning |
11
+ |---------|----------|-----------------|
12
+ | **MUST** | REQUIRED, SHALL | Absolute requirement. Non-compliance is a defect. |
13
+ | **MUST NOT** | SHALL NOT | Absolute prohibition. Non-compliance is a defect. |
14
+ | **SHOULD** | RECOMMENDED | Recommended; non-compliance requires recorded rationale. |
15
+ | **SHOULD NOT** | NOT RECOMMENDED | Discouraged; non-compliance requires recorded rationale. |
16
+ | **MAY** | OPTIONAL | Truly optional; compliance and non-compliance are both fine. |
17
+
18
+ These keywords are case-sensitive in their normative meaning. Use UPPERCASE
19
+ when carrying RFC 2119 weight; lowercase ("must", "should") is prose and
20
+ does not bind implementations.
21
+
22
+ ## The Mandatory Header
23
+
24
+ Every CLEO specification MUST open with the IETF boilerplate, exactly:
25
+
26
+ ```markdown
27
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
28
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
29
+ document are to be interpreted as described in RFC 2119.
30
+ ```
31
+
32
+ If the boilerplate is missing, the document is a guide, not a spec.
33
+ Downstream tooling — `ct-validator`, the IVT loop, the consensus voter —
34
+ will not enforce normative weight on un-boilerplated documents.
35
+
36
+ ## Positive Examples
37
+
38
+ **Absolute requirement (MUST)**
39
+
40
+ > **REQ-007**: The release-ship command MUST cut the release branch from
41
+ > the tip of `main` after passing all quality gates.
42
+
43
+ This is testable: the test reads the branch's merge-base; if it is not
44
+ the `main`-tip-at-cut-time, the test fails.
45
+
46
+ **Conditional requirement (MUST + when-clause)**
47
+
48
+ > **REQ-008**: When `release.branchModel` is `feat-to-main`, the
49
+ > release pipeline MUST refuse direct pushes to `main`.
50
+
51
+ This is testable: with the config set, attempt a direct push; assert
52
+ rejection.
53
+
54
+ **Recommendation (SHOULD)**
55
+
56
+ > **REQ-012**: The orchestrator SHOULD batch parallel-safe tasks into
57
+ > waves rather than serializing them.
58
+
59
+ Compliant if waves exist; if serialization happens for a documented
60
+ reason (e.g. a dependency the auto-detector missed) the implementation
61
+ remains compliant — but the rationale MUST be recorded.
62
+
63
+ **Truly optional (MAY)**
64
+
65
+ > **REQ-019**: Implementations MAY cache the resolved skill manifest
66
+ > for the duration of a single orchestration session.
67
+
68
+ No conformance pressure either way. Caching and re-fetching are both
69
+ valid implementations.
70
+
71
+ ## Negative Examples (Anti-Spec Language)
72
+
73
+ These phrasings look normative but are not. Replace each before the spec
74
+ ships.
75
+
76
+ | Anti-pattern | Why it fails | Replacement |
77
+ |--------------|--------------|-------------|
78
+ | "The system needs to validate input" | "Needs to" is aspirational, not binding | "The system MUST validate input" |
79
+ | "It is recommended that you encrypt at rest" | "It is recommended" is passive prose | "Implementations SHOULD encrypt at rest" |
80
+ | "We will use HTTPS" | First-person future tense is a plan, not a requirement | "All transports MUST use HTTPS" |
81
+ | "Should ideally be idempotent" | "Ideally" weakens SHOULD into nothing | "MUST be idempotent" or "SHOULD be idempotent" |
82
+ | "Try to keep payloads under 1MB" | "Try to" is unmeasurable | "Payloads SHOULD NOT exceed 1MB" |
83
+ | "Cannot exceed 100 requests/minute" | "Cannot" is descriptive, not normative | "MUST NOT exceed 100 requests/minute" |
84
+
85
+ ## When to Pick Which Keyword
86
+
87
+ Use this decision rubric:
88
+
89
+ 1. **Will an implementation that violates this rule fail user expectations
90
+ or break interoperability?**
91
+ - Yes → MUST / MUST NOT
92
+ - Maybe → continue
93
+ 2. **Is there a legitimate operating environment where violating this rule
94
+ is the right call?**
95
+ - Yes → SHOULD / SHOULD NOT
96
+ - No → revisit step 1
97
+ 3. **Is the behavior genuinely a choice with no preferred direction?**
98
+ - Yes → MAY
99
+ - No → revisit steps 1-2
100
+
101
+ If you cannot decide between MUST and SHOULD, the requirement is probably
102
+ under-specified — sharpen the failure condition first, then re-evaluate.
103
+
104
+ ## Cross-Reference Patterns
105
+
106
+ When one requirement depends on another, link them explicitly so the test
107
+ matrix can build the dependency graph.
108
+
109
+ ```markdown
110
+ **REQ-021**: The skill MUST emit a `pipeline_manifest` entry per
111
+ **REQ-008** before completing the task.
112
+ ```
113
+
114
+ Avoid prose-cross-references ("as mentioned above") — they cannot be
115
+ machine-extracted. Use the `REQ-NNN` token.
116
+
117
+ ## Compliance Statements
118
+
119
+ Every spec MUST close with a `## Compliance` section that enumerates the
120
+ conditions under which an implementation is conformant.
121
+
122
+ ```markdown
123
+ ## Compliance
124
+
125
+ An implementation is **conformant** if and only if:
126
+
127
+ 1. All MUST and MUST NOT requirements (REQ-001 through REQ-007) hold.
128
+ 2. Each SHOULD or SHOULD NOT requirement either holds OR is accompanied
129
+ by a recorded rationale in the implementation's `decisions` table.
130
+ 3. MAY requirements are reported in the implementation's capability
131
+ manifest if applicable.
132
+
133
+ Non-conformant implementations SHOULD provide a remediation plan with
134
+ target conformance date.
135
+ ```
136
+
137
+ This section is what `ct-validator` reads when producing the validation
138
+ report — without it, validation cannot proceed.
@@ -0,0 +1,233 @@
1
+ # Spec Templates
2
+
3
+ Templates for the spec types that CLEO produces most frequently. Each
4
+ template includes the canonical sections, required cross-references, and
5
+ the conformance criteria block that `ct-validator` reads downstream.
6
+
7
+ ## Protocol Specification
8
+
9
+ For inter-component or inter-process contracts. Examples: the
10
+ `cleo-subagent` protocol, the `pipeline_manifest` schema, the LAFS
11
+ envelope contract.
12
+
13
+ ```markdown
14
+ # {Protocol Name} Specification v{X.Y.Z}
15
+
16
+ The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
17
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
18
+ document are to be interpreted as described in RFC 2119.
19
+
20
+ **Status**: draft | proposed | accepted | deprecated
21
+ **Supersedes**: (none) | {ADR-XXX} | {Spec-Name v{X.Y.Z-1}}
22
+ **Related ADRs**: ADR-XXX, ADR-YYY
23
+
24
+ ---
25
+
26
+ ## Abstract
27
+
28
+ {One paragraph: what this protocol governs and why it exists.}
29
+
30
+ ## Definitions
31
+
32
+ | Term | Definition |
33
+ |------|------------|
34
+ | {term} | {precise definition; avoid synonyms} |
35
+
36
+ ## Roles
37
+
38
+ - **{Role A}**: {responsibilities}
39
+ - **{Role B}**: {responsibilities}
40
+
41
+ ## Message Types / Operations
42
+
43
+ ### {Operation 1}
44
+
45
+ **REQ-001**: {what MUST happen}.
46
+ - Inputs: {field list with types}
47
+ - Outputs: {field list with types}
48
+ - Errors: {error code enumeration}
49
+
50
+ ### {Operation 2}
51
+ ...
52
+
53
+ ## State Machine (if applicable)
54
+
55
+ | State | Transitions | Triggers |
56
+ |-------|-------------|----------|
57
+ | init | → ready | start() |
58
+ | ready | → running, → cancelled | run(), cancel() |
59
+ | running | → done, → failed | (auto) |
60
+
61
+ ## Security Considerations
62
+
63
+ {What can go wrong; threat model.}
64
+
65
+ ## Compliance
66
+
67
+ An implementation is conformant if {enumerated conditions}.
68
+ ```
69
+
70
+ ## API Specification
71
+
72
+ For HTTP, gRPC, or CLI-level interfaces.
73
+
74
+ ```markdown
75
+ # {API Name} Specification v{X.Y.Z}
76
+
77
+ {RFC 2119 boilerplate}
78
+
79
+ ## Overview
80
+
81
+ {One paragraph.}
82
+
83
+ ## Endpoints / Commands
84
+
85
+ ### `{METHOD} /path` or `cleo {verb} {noun}`
86
+
87
+ **REQ-001**: The endpoint MUST return 2xx on success, 4xx on client
88
+ error, 5xx on server error.
89
+
90
+ **Request schema**:
91
+ ```json
92
+ { "field": "type", "field2": "type" }
93
+ ```
94
+
95
+ **Response schema (success)**:
96
+ ```json
97
+ { "result": "type" }
98
+ ```
99
+
100
+ **Errors**:
101
+ | Code | Meaning | When |
102
+ |------|---------|------|
103
+ | E_NOT_FOUND | Resource missing | {trigger} |
104
+ | E_VALIDATION | Bad input | {trigger} |
105
+
106
+ **REQ-002**: The endpoint SHOULD complete within {N}ms p95.
107
+
108
+ ## Authentication
109
+
110
+ {Required headers, scopes, etc.}
111
+
112
+ ## Versioning
113
+
114
+ {How breaking changes are communicated.}
115
+
116
+ ## Compliance
117
+
118
+ {Conditions.}
119
+ ```
120
+
121
+ ## Architecture Document
122
+
123
+ For high-level structural decisions that do not fit the ADR (single
124
+ decision) shape but need normative weight. The ADR records the decision;
125
+ the architecture document specifies the resulting structure.
126
+
127
+ ```markdown
128
+ # {System Name} Architecture v{X.Y.Z}
129
+
130
+ {RFC 2119 boilerplate}
131
+
132
+ ## Context
133
+
134
+ {Why this system exists; what problem it solves.}
135
+
136
+ ## Constraints
137
+
138
+ | ID | Constraint | Source |
139
+ |----|------------|--------|
140
+ | CON-001 | All DB opens go through openCleoDb() | ADR-D003 |
141
+ | CON-002 | No raw new DatabaseSync() outside chokepoint | ADR-D003 |
142
+
143
+ ## Components
144
+
145
+ ### {Component A}
146
+ - **Responsibility**: {one sentence}
147
+ - **Inputs**: {what it consumes}
148
+ - **Outputs**: {what it produces}
149
+ - **Constraints**: CON-XXX, CON-YYY
150
+
151
+ ### {Component B}
152
+ ...
153
+
154
+ ## Dependencies
155
+
156
+ ```mermaid
157
+ graph LR
158
+ A[Component A] --> B[Component B]
159
+ B --> C[Component C]
160
+ ```
161
+
162
+ ## Cross-cutting Concerns
163
+
164
+ - **Observability**: {logging, metrics, tracing requirements}
165
+ - **Security**: {authn, authz, secrets handling}
166
+ - **Resilience**: {failure modes, recovery}
167
+
168
+ ## Compliance
169
+
170
+ {Conditions.}
171
+ ```
172
+
173
+ ## Requirements Document (small/targeted)
174
+
175
+ For a single feature where a full protocol spec is overkill but a
176
+ testable contract is needed.
177
+
178
+ ```markdown
179
+ # {Feature Name} Requirements v{X.Y.Z}
180
+
181
+ {RFC 2119 boilerplate}
182
+
183
+ ## Scope
184
+
185
+ {What's in; what's out.}
186
+
187
+ ## Requirements
188
+
189
+ **REQ-001**: {requirement}
190
+ - Rationale: {why}
191
+ - Verification: {how to test}
192
+
193
+ **REQ-002**: {requirement}
194
+ - Rationale: {why}
195
+ - Verification: {how to test}
196
+
197
+ ## Constraints
198
+
199
+ {CON-XXX list if relevant.}
200
+
201
+ ## Open Questions
202
+
203
+ {Anything not yet resolved — these block acceptance.}
204
+
205
+ ## Compliance
206
+
207
+ {Conditions.}
208
+ ```
209
+
210
+ ## Naming Conventions
211
+
212
+ | Type | Filename pattern | Location |
213
+ |------|------------------|----------|
214
+ | Protocol spec | `<name>-protocol-v<x>.md` | `docs/specs/protocols/` |
215
+ | API spec | `<name>-api-v<x>.md` | `docs/specs/apis/` |
216
+ | Architecture | `<name>-architecture-v<x>.md` | `docs/architecture/` |
217
+ | Requirements | `<name>-requirements.md` | `docs/specs/requirements/` |
218
+ | ADR | `ADR-NNN-<short-slug>.md` | `.cleo/adrs/` |
219
+
220
+ When in doubt: protocol vs requirements — a protocol governs a contract
221
+ between two parties; requirements govern behavior of a single party.
222
+
223
+ ## Versioning Rules
224
+
225
+ | Bump | Trigger |
226
+ |------|---------|
227
+ | Patch (`X.Y.Z+1`) | Clarification, typo fix, no semantic change |
228
+ | Minor (`X.Y+1.0`) | Added requirement (additive) |
229
+ | Major (`X+1.0.0`) | Changed or removed requirement (breaking) |
230
+
231
+ A major bump REQUIRES a corresponding deprecation period for the prior
232
+ major version. State the period in `## Status` (e.g., "v2.x deprecated
233
+ 2026-Q3, removed 2026-Q4").
@@ -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.
@@ -309,3 +309,13 @@ This skill binds to the **implementation** LOOM lifecycle stage. Governing ADRs:
309
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
310
 
311
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