@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,199 @@
1
+ # Compliance Reports
2
+
3
+ The shape, severity calculus, and downstream consumption of the
4
+ validation report. The report is the validator's product — its format
5
+ is rigid because `ct-ivt-looper`, `ct-release-orchestrator`, and HITL
6
+ gates all parse it.
7
+
8
+ ## Canonical Report Scaffold
9
+
10
+ Every report MUST use this structure. Sections are mandatory; their
11
+ content varies by mode.
12
+
13
+ ```markdown
14
+ # Validation Report: {{VALIDATION_TARGET}}
15
+
16
+ **Mode**: schema | code | document | protocol
17
+ **Date**: {{DATE}}
18
+ **Validator**: ct-validator v2.0.0
19
+
20
+ ---
21
+
22
+ ## Summary
23
+
24
+ - **Status**: PASS | PARTIAL | FAIL
25
+ - **Compliance**: {X}%
26
+ - **Critical Issues**: {N}
27
+ - **Warnings**: {N}
28
+ - **Suggestions**: {N}
29
+
30
+ ## Checklist Results
31
+
32
+ | Check | Status | Details |
33
+ |-------|--------|---------|
34
+ | {CHECK_1} | PASS/FAIL | {Details} |
35
+ | {CHECK_2} | PASS/FAIL | {Details} |
36
+
37
+ ## Issues Found
38
+
39
+ ### Critical
40
+ {List or "None"}
41
+
42
+ ### Warnings
43
+ {List or "None"}
44
+
45
+ ### Suggestions
46
+ {List or "None"}
47
+
48
+ ## Remediation
49
+
50
+ {Required fixes if FAIL/PARTIAL, or "No remediation required" if PASS}
51
+
52
+ ## Trace
53
+
54
+ - Target: {file/spec/diff path}
55
+ - Tooling: {versions of tools run}
56
+ - Reproducer: {one command that re-runs this report}
57
+ ```
58
+
59
+ The Trace section is essential — without a reproducer, the report
60
+ cannot be re-run later to confirm a remediation worked.
61
+
62
+ ## Status Calculus
63
+
64
+ | Mode | PASS | PARTIAL | FAIL |
65
+ |------|------|---------|------|
66
+ | Schema | 0 violations | (n/a) | ≥1 violation |
67
+ | Code | 0 critical, ≤2 warnings | 0 critical, 3+ warnings | ≥1 critical |
68
+ | Document | All required sections present, 0 broken links | 1-2 missing sections | 3+ missing sections OR broken refs |
69
+ | Protocol | 100% REQ compliance | 70-99% compliance | <70% compliance |
70
+
71
+ The status is not a vote — it is a computed function of the findings.
72
+ Two validators running on the same target MUST produce the same
73
+ status.
74
+
75
+ PARTIAL is reserved for cases where the target is shippable WITH
76
+ recorded remediation; FAIL means the target cannot ship as-is.
77
+
78
+ ## Severity Definitions
79
+
80
+ | Severity | Meaning | Examples |
81
+ |----------|---------|----------|
82
+ | Critical | Blocks ship; data corruption, security, AGENTS.md rejection | `any` type, missing required field, broken link in spec |
83
+ | Warning | Should fix soon; degrades quality but does not block | Long body, unused import, missing optional section |
84
+ | Suggestion | Improvement opportunity; no obligation | Extract helper, rename for clarity |
85
+
86
+ Each finding MUST carry a severity. Findings without severity are
87
+ unactionable — the consumer cannot prioritize.
88
+
89
+ ## Per-Finding Format
90
+
91
+ ```markdown
92
+ ### Critical
93
+
94
+ **C-001**: `packages/cleo/src/dispatch.ts:42` uses `any` type.
95
+ - Rule: AGENTS.md Type Safety §1 — "NEVER use `any` type"
96
+ - Fix: Import the relevant type from `@cleocode/contracts` or
97
+ define a narrower union.
98
+ - Verification: `pnpm biome check packages/cleo/src/dispatch.ts`
99
+
100
+ **C-002**: `packages/cleo/src/release.ts:107` catches `err: unknown`.
101
+ - Rule: AGENTS.md Type Safety §5 — "NEVER use `catch (err: unknown)`"
102
+ - Fix: Throw and catch by class from `@cleocode/contracts/errors`.
103
+ - Verification: Replace with `catch (err)` and pattern-match by
104
+ `instanceof`.
105
+
106
+ ### Warnings
107
+
108
+ **W-001**: `packages/cleo/src/dispatch.ts` is 487 lines (warn at 400).
109
+ - Rule: ct-skill-validator audit_body §body-length
110
+ - Fix: Extract sub-handlers into sibling files.
111
+ - Verification: re-run audit_body.py.
112
+
113
+ ### Suggestions
114
+
115
+ **S-001**: `packages/cleo/src/dispatch.ts:120` has a TODO with no task ID.
116
+ - Rule: Internal — TODOs should reference task IDs.
117
+ - Fix: File a task, attach the ID: `// TODO(T9999): ...`.
118
+ ```
119
+
120
+ Each finding gets a stable ID (`C-NNN`, `W-NNN`, `S-NNN`) so subsequent
121
+ reports can reference whether the same issue persists.
122
+
123
+ ## Compliance Percentage
124
+
125
+ For modes that report a percentage:
126
+
127
+ ```text
128
+ compliance = (passed_checks / total_checks) × 100
129
+ ```
130
+
131
+ Round to one decimal. For Protocol mode (REQ compliance), checks are
132
+ the REQs in the spec's traceability matrix. For Schema mode, "checks"
133
+ is the count of constraints evaluated.
134
+
135
+ When the denominator is zero (e.g., a spec with no REQs), the
136
+ percentage is undefined — emit `N/A` and report a Critical finding for
137
+ the empty spec.
138
+
139
+ ## Integration with ct-ivt-looper
140
+
141
+ The IVT loop reads the validator's `status` and `compliance` fields
142
+ to decide whether to continue iterating. The contract:
143
+
144
+ - `status: PASS` → IVT loop converges; release-orchestrator may proceed.
145
+ - `status: PARTIAL` → IVT loop loops once more with the remediation as
146
+ input; if still PARTIAL on iteration 3, escalates to HITL.
147
+ - `status: FAIL` → IVT loop blocks; release-orchestrator MUST not
148
+ proceed; HITL escalation immediate.
149
+
150
+ This contract is the reason status calculus is rigid — fuzzy statuses
151
+ break the loop's termination conditions.
152
+
153
+ ## Integration with Release
154
+
155
+ `ct-release-orchestrator` reads the most recent validation report
156
+ for the epic before allowing ship. The release pipeline (ADR-065)
157
+ contains a gate that asserts `status: PASS` on the implementation
158
+ against the spec. PARTIAL reports trigger a recorded remediation
159
+ plan; FAIL reports block.
160
+
161
+ ## Machine-Readable Sidecar
162
+
163
+ Always emit a JSON sidecar next to the markdown report:
164
+
165
+ ```json
166
+ {
167
+ "target": "packages/cleo/src/release.ts",
168
+ "mode": "code",
169
+ "status": "FAIL",
170
+ "compliance": 88.5,
171
+ "findings": {
172
+ "critical": [
173
+ {"id": "C-001", "file": "...", "line": 42, "rule": "...", "fix": "..."},
174
+ {"id": "C-002", "file": "...", "line": 107, "rule": "...", "fix": "..."}
175
+ ],
176
+ "warnings": [...],
177
+ "suggestions": [...]
178
+ },
179
+ "trace": {
180
+ "tooling": ["biome@2.4.11", "tsc@5.6.0"],
181
+ "reproducer": "pnpm biome check . && pnpm exec tsc -b",
182
+ "timestamp": "2026-05-19T19:35:00Z"
183
+ }
184
+ }
185
+ ```
186
+
187
+ The orchestrator parses this when programmatic decisions are needed;
188
+ the human report (.md) is for review.
189
+
190
+ ## Anti-Patterns
191
+
192
+ | Anti-pattern | Why it fails |
193
+ |--------------|--------------|
194
+ | Vague finding ("file looks weird") | Cannot remediate |
195
+ | Missing severity | Consumer cannot prioritize |
196
+ | No reproducer in trace | Cannot re-validate after fix |
197
+ | PARTIAL with no remediation plan | Status calculus violation |
198
+ | Findings without rule reference | Disputable, not actionable |
199
+ | Markdown only, no JSON sidecar | Breaks orchestrator integration |
@@ -0,0 +1,191 @@
1
+ # Schema Checking
2
+
3
+ Deeper guidance for Schema Validation mode (Mode 1 from
4
+ `validation-modes.md`). Schema checking is the most mechanical of the
5
+ four modes — but only if the inputs are correctly configured. This
6
+ reference covers the configuration pitfalls and tool-selection rules.
7
+
8
+ ## Pick the Right Engine
9
+
10
+ | Engine | Strength | When to use |
11
+ |--------|----------|-------------|
12
+ | AJV (`ajv-cli`) | Fast; draft-07 / 2019-09 / 2020-12 | Generic JSON Schema validation |
13
+ | Zod | Type-safe; integrates with TypeScript | Project-internal data validation |
14
+ | drizzle-orm/zod | Schema → Zod auto-generation | Drizzle ORM consumers |
15
+ | jsonschema (Python) | Cross-language; same draft support | Python-side validation |
16
+ | `cargo schema` / serde | Type-safe; Rust-side | Rust crates |
17
+
18
+ The CLEO repo's primary engine is Zod (via `@cleocode/contracts`) — most
19
+ internal schemas are exported as Zod schemas with optional drizzle
20
+ codegen. Use Zod's `safeParse` to get structured errors.
21
+
22
+ For external contracts (LAFS envelope spec, JSON-RPC requests from
23
+ non-CLEO clients), use AJV or jsonschema for cross-language portability.
24
+
25
+ ## Draft Selection
26
+
27
+ Always state the draft explicitly. Draft-07 and draft-2020-12 have
28
+ incompatible semantics around `$ref`, `if/then/else`, and tuple arrays.
29
+
30
+ | Draft | Best for | Caveats |
31
+ |-------|----------|---------|
32
+ | draft-04 | Legacy | `id` not `$id`; many engines deprecated this |
33
+ | draft-07 | Industry standard | Most engines support fully |
34
+ | draft-2019-09 | New work, conservative | `$defs` replaces `definitions` |
35
+ | draft-2020-12 | New work, full | Some engines lag |
36
+
37
+ CLEO contracts target draft-07 unless the schema needs 2020-12-only
38
+ features (typically `prefixItems` for tuple arrays). Add the explicit
39
+ `"$schema"` field on every published schema:
40
+
41
+ ```json
42
+ {
43
+ "$schema": "http://json-schema.org/draft-07/schema#",
44
+ "title": "TaskEnvelope",
45
+ "type": "object",
46
+ "required": ["success", "meta"],
47
+ ...
48
+ }
49
+ ```
50
+
51
+ ## The Standard Validation Loop
52
+
53
+ ```bash
54
+ # 1. Choose engine; choose draft
55
+ ENGINE=ajv
56
+ DRAFT=draft-07
57
+
58
+ # 2. Resolve schema file (must include $schema or pass --spec)
59
+ SCHEMA=packages/contracts/schemas/envelope.json
60
+
61
+ # 3. Iterate over data files
62
+ for DATA in path/to/*.json; do
63
+ echo "=== $DATA ==="
64
+ npx ajv validate -s "$SCHEMA" -d "$DATA" --spec=$DRAFT --all-errors
65
+ done
66
+
67
+ # 4. Aggregate by file in the report
68
+ ```
69
+
70
+ The `--all-errors` flag (AJV) or `--exhaustive` (Zod's `safeParse` does
71
+ this by default) is essential — the spec ground rule is "report every
72
+ violation", not "stop at the first one".
73
+
74
+ ## Pitfalls
75
+
76
+ ### 1. $ref Resolution Failure
77
+
78
+ **Symptom.** Validator complains "could not resolve $ref" or "unknown
79
+ keyword $ref".
80
+
81
+ **Cause.** Schema references another file by relative path; the engine
82
+ does not know the base directory.
83
+
84
+ **Fix.** Pass `--ref` (AJV) pointing at the referenced files, or inline
85
+ the references with `$defs`. For multi-file schemas, use AJV's
86
+ `addSchema()` API or a bundler step that flattens before validation.
87
+
88
+ ### 2. Implicit Type Coercion
89
+
90
+ **Symptom.** A string `"123"` validates against `{"type": "number"}`.
91
+
92
+ **Cause.** Engine has coercion enabled (`coerceTypes: true` in AJV).
93
+
94
+ **Fix.** Disable coercion for strict validation:
95
+
96
+ ```javascript
97
+ new Ajv({ coerceTypes: false, strict: true, allErrors: true })
98
+ ```
99
+
100
+ CLEO contracts are strict by default — incoming data must already be
101
+ typed correctly.
102
+
103
+ ### 3. Missing required not flagged
104
+
105
+ **Symptom.** A required field is missing; schema says it's required;
106
+ validator passes.
107
+
108
+ **Cause.** The schema's `required` is at the wrong level (nested vs
109
+ top), or the validator is in non-strict mode.
110
+
111
+ **Fix.** Re-check the schema structure. `required` must be a peer of
112
+ `properties` at the same nesting level.
113
+
114
+ ### 4. Additional Properties Silently Allowed
115
+
116
+ **Symptom.** Data has extra fields not in the schema; validator passes.
117
+
118
+ **Cause.** Schema does not specify `additionalProperties: false`.
119
+
120
+ **Fix.** CLEO contracts default to `additionalProperties: false` — extra
121
+ fields indicate either drift in the producer or a malicious payload.
122
+ Override only with an inline justification.
123
+
124
+ ## Reporting Schema Violations
125
+
126
+ Each violation goes in the report as:
127
+
128
+ ```markdown
129
+ ### Violations
130
+
131
+ | Path | Keyword | Actual | Expected | File |
132
+ |------|---------|--------|----------|------|
133
+ | `/data/items/3/id` | required | (absent) | string | manifest-instance.json |
134
+ | `/data/version` | type | "1.2.3" (string) | number | manifest-instance.json |
135
+ | `/meta/timestamp` | format | "today" | date-time | manifest-instance.json |
136
+ | `/error.code` | enum | "E_WUT" | one of [E_NOT_FOUND, E_VALIDATION, ...] | response.json |
137
+ ```
138
+
139
+ The Path column uses JSON Pointer (RFC 6901). The Keyword column names
140
+ the schema constraint violated. Actual + Expected gives the diff
141
+ needed to fix.
142
+
143
+ ## Bulk Schema Validation
144
+
145
+ When validating many instances (e.g., every manifest file in
146
+ `.cleo/agent-outputs/`), produce a summary table first, then drill
147
+ into failures.
148
+
149
+ ```markdown
150
+ ## Summary
151
+
152
+ - **Files validated**: 47
153
+ - **Pass**: 42
154
+ - **Fail**: 5
155
+ - **Compliance**: 89.4%
156
+
157
+ ## Failed Files
158
+
159
+ | File | Violations |
160
+ |------|-----------|
161
+ | `.cleo/agent-outputs/2026-05-19_old.md` | 3 |
162
+ | `.cleo/agent-outputs/2026-05-19_draft.md` | 1 |
163
+ | ... | ... |
164
+
165
+ ## Detail (per-file)
166
+
167
+ ### `.cleo/agent-outputs/2026-05-19_old.md`
168
+
169
+ | Path | Keyword | Actual | Expected |
170
+ |------|---------|--------|----------|
171
+ | ... | ... | ... | ... |
172
+ ```
173
+
174
+ Bulk reports SHOULD be machine-readable. Emit a sibling JSON report
175
+ under the same name when the consumer is automation.
176
+
177
+ ## Self-Test the Schema
178
+
179
+ Before trusting any schema for validation, verify it accepts known-good
180
+ instances and rejects known-bad instances. Maintain a `fixtures/`
181
+ directory next to the schema:
182
+
183
+ ```text
184
+ packages/contracts/schemas/envelope.json
185
+ packages/contracts/schemas/fixtures/envelope-valid.json
186
+ packages/contracts/schemas/fixtures/envelope-missing-success.json
187
+ packages/contracts/schemas/fixtures/envelope-wrong-type.json
188
+ ```
189
+
190
+ A test that exercises all three confirms the schema does what it
191
+ claims. Without fixtures, schema drift goes undetected.
@@ -0,0 +1,185 @@
1
+ # Validation Modes
2
+
3
+ `ct-validator` operates in four distinct modes. Each has different inputs,
4
+ different verification mechanics, and different report shape. The mode is
5
+ determined by the target type — the spawn prompt or task body MUST make
6
+ the mode explicit.
7
+
8
+ ## Mode 1: Schema Validation
9
+
10
+ **Target.** A data instance (JSON, YAML, TOML, etc.) checked against a
11
+ schema (JSON Schema, Zod, drizzle/zod, ajv, JSON-LD).
12
+
13
+ **Inputs.**
14
+ - One or more data files (or stdin)
15
+ - A schema (file path or inline)
16
+ - Optional: schema dialect (draft-07, draft-2020-12, etc.)
17
+
18
+ **Mechanics.** Run the schema engine; collect every violation; classify
19
+ by JSON Path. Do not short-circuit on first failure — exhaustive
20
+ reporting is the whole value-add.
21
+
22
+ **Tool examples.**
23
+
24
+ ```bash
25
+ # AJV (Node)
26
+ npx ajv validate -s schema.json -d data.json --spec=draft7
27
+
28
+ # Zod (Node, via project's contracts)
29
+ node -e "
30
+ import { Schema } from '@cleocode/contracts';
31
+ const result = Schema.safeParse(JSON.parse(input));
32
+ if (!result.success) console.log(JSON.stringify(result.error.format()));
33
+ "
34
+
35
+ # jsonschema (Python)
36
+ python -m jsonschema -i data.json schema.json
37
+ ```
38
+
39
+ **Report shape.** Each violation gets file + JSON Path + violated keyword
40
+ + actual value + expected. Group by file when validating many instances.
41
+
42
+ ## Mode 2: Code Compliance
43
+
44
+ **Target.** A code change (PR, diff, or working-tree state) checked
45
+ against project standards — lint rules, style guide, naming conventions,
46
+ import boundaries, type discipline.
47
+
48
+ **Inputs.**
49
+ - A diff (or branch comparison)
50
+ - The project's lint/format configs (biome.json, .eslintrc, clippy.toml)
51
+ - The relevant AGENTS.md / ADR rules
52
+
53
+ **Mechanics.** Run each tool; collect findings; classify by severity.
54
+ Aggregate the toolchain (biome + tsc + project-specific rules) into a
55
+ single report.
56
+
57
+ **Tool examples.**
58
+
59
+ ```bash
60
+ # Biome (lint + format in one)
61
+ pnpm biome check . --reporter=json
62
+
63
+ # TypeScript strict
64
+ pnpm exec tsc -b --pretty false
65
+
66
+ # Custom AGENTS.md rule checks
67
+ grep -rn "catch (err: unknown)" packages/ --include='*.ts'
68
+ grep -rn ": any\b" packages/ --include='*.ts'
69
+
70
+ # Package-boundary check
71
+ find packages -name "*.ts" -exec grep -l "../../../" {} \;
72
+ ```
73
+
74
+ **Report shape.** Each finding gets file + line + rule + severity + fix
75
+ suggestion. The AGENTS.md "INSTANT REJECTION" anti-patterns get
76
+ `critical` severity; biome warnings get `warning` severity.
77
+
78
+ ## Mode 3: Document Validation
79
+
80
+ **Target.** A markdown document (spec, ADR, agent-output, skill) checked
81
+ against a structural standard — required sections, frontmatter, link
82
+ validity, style guide.
83
+
84
+ **Inputs.**
85
+ - The document(s) under validation
86
+ - The structural standard (e.g., "every spec MUST have RFC 2119
87
+ boilerplate, REQ-NNN numbered requirements, and a Compliance section")
88
+ - The CLEO style guide (`packages/skills/skills/_shared/cleo-style-guide.md`)
89
+
90
+ **Mechanics.** Parse the document; check section presence; validate
91
+ links; scan for placeholder text; verify formatting.
92
+
93
+ **Tool examples.**
94
+
95
+ ```bash
96
+ # Use the ct-skill-validator scripts as a model
97
+ python packages/skills/skills/ct-skill-validator/scripts/validate.py <skill-dir>
98
+ python packages/skills/skills/ct-skill-validator/scripts/audit_body.py <skill-dir>
99
+
100
+ # Generic markdown link check
101
+ markdown-link-check docs/specs/*.md
102
+
103
+ # Section presence check (ad-hoc)
104
+ for f in docs/specs/*.md; do
105
+ grep -q "^## Compliance" "$f" || echo "FAIL: $f missing Compliance"
106
+ grep -q "RFC 2119" "$f" || echo "FAIL: $f missing RFC 2119 boilerplate"
107
+ done
108
+ ```
109
+
110
+ **Report shape.** Each finding gets file + section/line + violated rule
111
+ + fix suggestion. Document-mode reports are the most useful when paired
112
+ with traceability — see Mode 4.
113
+
114
+ ## Mode 4: Protocol Compliance
115
+
116
+ **Target.** An implementation checked against its specification — the
117
+ spec defines REQ-NNN, the implementation MUST satisfy each.
118
+
119
+ **Inputs.**
120
+ - The specification document (with traceability matrix)
121
+ - The implementation source
122
+ - The test suite (each REQ should have a verifying test)
123
+
124
+ **Mechanics.** For each REQ in the matrix, run the verifying test;
125
+ record pass/fail; record any REQs that lack a verifying test. Compute
126
+ compliance percentage.
127
+
128
+ **Tool examples.**
129
+
130
+ ```bash
131
+ # Run the specific test for each REQ
132
+ pnpm vitest run --testNamePattern="REQ-001|REQ-002|REQ-003"
133
+
134
+ # Extract REQ→test map from the spec's traceability matrix
135
+ grep -E "^\| REQ-" docs/specs/foo-spec.md | awk -F'|' '{print $2, "->", $4}'
136
+
137
+ # Detect REQs without verification
138
+ grep -E "^\| REQ-.*\| \(TODO" docs/specs/foo-spec.md
139
+ ```
140
+
141
+ **Report shape.** Compliance percentage + per-REQ pass/fail + list of
142
+ unverified REQs. This is the input to release-gate decisions.
143
+
144
+ ## Mode Selection Cheat Sheet
145
+
146
+ | Signal in task description | Mode |
147
+ |----------------------------|------|
148
+ | "validate this JSON against schema X" | Schema |
149
+ | "check the PR for style violations" | Code |
150
+ | "review this spec for completeness" | Document |
151
+ | "verify the implementation satisfies the spec" | Protocol |
152
+ | "audit the release pipeline against ADR-065" | Protocol |
153
+ | "lint the changes" | Code |
154
+ | "validate the LAFS envelope" | Schema |
155
+ | "review the agent-output for style guide compliance" | Document |
156
+
157
+ ## Mode Composition
158
+
159
+ A single task may chain modes. Example: "validate the new release-plan
160
+ implementation."
161
+
162
+ 1. Mode 3 (Document) — does `docs/specs/release-plan-spec.md` have
163
+ RFC 2119 boilerplate, numbered REQs, traceability matrix, compliance
164
+ section?
165
+ 2. Mode 4 (Protocol) — does the implementation pass each REQ's test?
166
+ 3. Mode 2 (Code) — does the implementation's diff pass lint + typecheck?
167
+ 4. Mode 1 (Schema) — do the LAFS envelopes the new code emits validate
168
+ against the contract schema?
169
+
170
+ When composing, run the modes in this order — document → protocol →
171
+ code → schema. Each later mode assumes the earlier modes have passed,
172
+ so they bail early on irrelevant failures.
173
+
174
+ ## Output Per Mode
175
+
176
+ | Mode | Status fields | Key metric |
177
+ |------|---------------|------------|
178
+ | Schema | `status: PASS|FAIL`, `violations: [...]` | violation count |
179
+ | Code | `status: PASS|FAIL`, `findings: [...]` | finding count by severity |
180
+ | Document | `status: PASS|FAIL`, `sections_missing: [...]` | missing-section count |
181
+ | Protocol | `status: PASS|PARTIAL|FAIL`, `compliance: X%`, `unverified: [...]` | compliance percentage |
182
+
183
+ All modes share the canonical report scaffold in SKILL.md — `## Summary`,
184
+ `## Checklist Results`, `## Issues Found`, `## Remediation`. Only the
185
+ content differs.
@@ -125,7 +125,13 @@
125
125
  "protocol": "implementation",
126
126
  "loomStage": "implementation",
127
127
  "adrRefs": ["ADR-070", "ADR-062"],
128
- "references": [],
128
+ "references": [
129
+ "skills/ct-task-executor/references/implementation-patterns.md",
130
+ "skills/ct-task-executor/references/acceptance-criteria-mapping.md",
131
+ "skills/ct-task-executor/references/evidence-and-gates.md",
132
+ "skills/ct-task-executor/references/common-failures.md",
133
+ "skills/ct-task-executor/references/anti-patterns.md"
134
+ ],
129
135
  "capabilities": {
130
136
  "inputs": ["TASK_ID", "TASK_NAME", "TASK_INSTRUCTIONS", "DELIVERABLES_LIST", "ACCEPTANCE_CRITERIA"],
131
137
  "outputs": ["deliverables", "manifest-entry"],
@@ -187,7 +193,12 @@
187
193
  "protocol": "research",
188
194
  "loomStage": "research",
189
195
  "adrRefs": ["ADR-023", "ADR-070"],
190
- "references": [],
196
+ "references": [
197
+ "skills/ct-research-agent/references/triggers-and-routing.md",
198
+ "skills/ct-research-agent/references/source-strategy.md",
199
+ "skills/ct-research-agent/references/citation-and-evidence.md",
200
+ "skills/ct-research-agent/references/anti-patterns.md"
201
+ ],
191
202
  "capabilities": {
192
203
  "inputs": ["TASK_ID", "TOPIC", "RESEARCH_QUESTIONS"],
193
204
  "outputs": ["research-file", "manifest-entry"],
@@ -218,7 +229,12 @@
218
229
  "protocol": "specification",
219
230
  "loomStage": "specification",
220
231
  "adrRefs": ["ADR-014", "ADR-023"],
221
- "references": [],
232
+ "references": [
233
+ "skills/ct-spec-writer/references/rfc2119-language.md",
234
+ "skills/ct-spec-writer/references/spec-templates.md",
235
+ "skills/ct-spec-writer/references/traceability-matrix.md",
236
+ "skills/ct-spec-writer/references/anti-patterns.md"
237
+ ],
222
238
  "capabilities": {
223
239
  "inputs": ["TASK_ID", "SPEC_NAME", "spec_topic"],
224
240
  "outputs": ["specification-file", "manifest-entry"],
@@ -249,7 +265,12 @@
249
265
  "protocol": "validation",
250
266
  "loomStage": "validation",
251
267
  "adrRefs": ["ADR-051", "ADR-023"],
252
- "references": [],
268
+ "references": [
269
+ "skills/ct-validator/references/validation-modes.md",
270
+ "skills/ct-validator/references/schema-checking.md",
271
+ "skills/ct-validator/references/compliance-reports.md",
272
+ "skills/ct-validator/references/anti-patterns.md"
273
+ ],
253
274
  "capabilities": {
254
275
  "inputs": ["TASK_ID", "VALIDATION_TARGET", "VALIDATION_CRITERIA"],
255
276
  "outputs": ["validation-report", "manifest-entry"],
@@ -305,7 +326,12 @@
305
326
  "status": "active",
306
327
  "tier": 2,
307
328
  "token_budget": 8000,
308
- "references": [],
329
+ "references": [
330
+ "skills/ct-documentor/references/chain-orchestration.md",
331
+ "skills/ct-documentor/references/doc-types-and-templates.md",
332
+ "skills/ct-documentor/references/style-coordination.md",
333
+ "skills/ct-documentor/references/anti-patterns.md"
334
+ ],
309
335
  "capabilities": {
310
336
  "inputs": ["TASK_ID", "documentation_topic"],
311
337
  "outputs": ["documentation-file", "manifest-entry", "review-report"],
@@ -333,7 +359,11 @@
333
359
  "status": "active",
334
360
  "tier": 2,
335
361
  "token_budget": 6000,
336
- "references": [],
362
+ "references": [
363
+ "skills/ct-docs-lookup/references/ctx7-workflow.md",
364
+ "skills/ct-docs-lookup/references/library-id-resolution.md",
365
+ "skills/ct-docs-lookup/references/version-specific-docs.md"
366
+ ],
337
367
  "capabilities": {
338
368
  "inputs": ["library_name", "query", "version"],
339
369
  "outputs": ["documentation-content", "code-examples"],
@@ -361,7 +391,11 @@
361
391
  "status": "active",
362
392
  "tier": 2,
363
393
  "token_budget": 6000,
364
- "references": [],
394
+ "references": [
395
+ "skills/ct-docs-write/references/cleo-style-guide.md",
396
+ "skills/ct-docs-write/references/markdown-patterns.md",
397
+ "skills/ct-docs-write/references/audience-targeting.md"
398
+ ],
365
399
  "capabilities": {
366
400
  "inputs": ["file_path", "content_topic", "audience"],
367
401
  "outputs": ["documentation-file", "markdown-content"],
@@ -389,7 +423,11 @@
389
423
  "status": "active",
390
424
  "tier": 2,
391
425
  "token_budget": 6000,
392
- "references": [],
426
+ "references": [
427
+ "skills/ct-docs-review/references/style-violations.md",
428
+ "skills/ct-docs-review/references/pr-review-mode.md",
429
+ "skills/ct-docs-review/references/inline-comment-patterns.md"
430
+ ],
393
431
  "capabilities": {
394
432
  "inputs": ["file_path", "pr_url", "diff_content"],
395
433
  "outputs": ["review-comments", "style-violations"],