skills/specops-spec-coherence/SKILL.md
Audit a set of SpecOps analysis specs for cross-spec coherence — establish a dependency-ordered implementation sequence, then verify pairwise integration contracts at module boundaries plus three cross-cutting consistency dimensions (shared data models, side-effect ownership, terminology) — and patch the affected specs to resolve gaps. Use this skill whenever the user mentions cross-spec consistency, integration gaps between specs, conflicts between specs, duplicate work across specs, implementation order, dependency order for migration, building an implementation-order checklist, ensuring specs interoperate, terminology drift across specs, or shared data model conflicts. Also trigger when the user describes "do my specs agree with each other," "what order should I implement these in," "find inconsistencies across all my specs," or asks to audit a folder of analysis specs as a set rather than individually. Run this once after generating a full set of analysis specs, before deriving implementation specs.
npx skillsauth add ryan-mahoney/ryan-llm-skills specops-spec-coherenceInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Each analysis spec is generated from a single module's source files in isolation. The result is a set of specs that are individually coherent but collectively under-coordinated. Two specs can each be internally correct and still disagree about the shape of a shared data structure, the owner of a shared resource, or the name of a shared concept.
This skill audits the entire set of analysis specs as a system. It produces five things:
Findings from all five become patches applied to the relevant specs, with deferral for items that genuinely need a design decision.
Confirm with the user before starting:
docs/specs/analysis/). The skill operates on every spec in this tree.core/ and ui/) for incremental work. Default is the full tree.docs/specs/implementation-order.mddocs/specs/coherence-audit.mdIf the project has an analysis-orchestration document (e.g., docs/specops/analysis-orchestration.md), read it first — it usually lists the canonical set of specs and their source-file groupings, which is faster than directory scanning.
Read every spec in scope. From each spec's "Dependencies" section (and any internal references in other sections), extract:
Build a directed graph where each node is a spec and each edge is "X depends on Y." Detect cycles; if any exist, flag them as findings (a true cycle in legacy code is rare but possible — it indicates a shared mutable state or a bidirectional protocol that needs explicit handling in the implementation).
Produce a topological ordering with leaf modules first. When ties occur (multiple modules with no remaining dependencies at the same level), order by simplicity — smaller surface area first — to maximize the value of early implementations as building blocks.
# Implementation Order
- **Generated:** <date>
- **Specs audited:** <count>
- **Cycles detected:** <count, with details>
This order is derived from the dependency graph across all analysis specs. Modules earlier in the list have fewer or simpler dependencies and should be implemented first. Each tier groups modules that are mutually independent and can be implemented in parallel.
## Tier 1 — Leaf modules (no internal dependencies)
- [ ] 1. `config` — <one-line summary>
- [ ] 2. `utils` — <one-line summary>
## Tier 2 — Depend only on Tier 1
- [ ] 3. `providers` — depends on: utils
- [ ] 4. `core/file-io` — depends on: config, utils
## Tier 3 — ...
...
## Cycles requiring resolution
- (none) | <list with the modules involved and the nature of the dependency>
This file is also a living checklist. As migration progresses, the user can check off items.
From the dependency graph and a scan of all specs, enumerate four categories of checks. Each check becomes one subagent task.
For each edge (A → B) in the graph (A depends on B), generate one check:
There are typically tens to a hundred such edges. They run in parallel.
Scan all specs for named data structures (typically in Section 3 of each analysis spec). Build an index: for each structure name (Job, Task, Status, PipelineEvent, etc.), list every spec that references it.
For each name appearing in 2+ specs, generate one check:
<name> agree on its fields, types, optionality, and valid value ranges? If they disagree, what's the actual shape according to the source code?A name appearing in only one spec needs no check.
Scan all specs (typically Sections 5 and 7 — State Management and Side Effects) for shared resources:
For each resource referenced by 2+ specs, generate one check:
A single check, not parallelized. Build a glossary of domain terms used across all specs (entities like "job", "task", "execution", "run", "pipeline"; verbs like "submit", "enqueue", "dispatch", "trigger"). For each cluster of terms that may refer to the same concept, generate a glossary entry showing where each variant appears.
All checks fan out in parallel. Use one subagent per check from 2a, 2b, and 2c, plus one subagent for 2d.
You are auditing the integration contract between two SpecOps analysis specs. Your job is to determine whether the depender's assumptions match the dependee's stated interface, and propose patches if they don't.
# The pair
- Depender (A): <path>
- Dependee (B): <path>
- Edge nature: <function call | data flow | event subscription | etc.>
# Your task
1. Read both specs. Focus on: A's references to B (what A assumes B provides, accepts, returns, throws); B's Public Interface section, Data Models section, and Error Handling section.
2. Identify any mismatch:
- A calls B's function with arguments B doesn't accept
- A consumes a return shape B doesn't produce
- A assumes B handles an error mode B doesn't describe
- A assumes ordering/concurrency B doesn't guarantee
- A and B disagree on a side effect (e.g., A says B creates the directory; B says A creates it)
3. For each mismatch, propose a patch to A, B, or both — specifying which side to change.
# Output
{
"edge": "A → B",
"mismatches": [
{
"type": "<argument | return | error | concurrency | side_effect_ownership>",
"description": "<what disagrees>",
"evidence": [{"spec": "<A or B>", "section": "<section>", "excerpt": "<quote>"}],
"patch": [
{"spec": "<A or B>", "section": "<section>", "operation": "<add | modify | annotate>", "before": "...", "after": "...", "rationale": "..."}
],
"deferred": <true | false>,
"defer_reason": "<if deferred>"
}
]
}
You are auditing whether all specs that reference a shared data structure agree on its shape.
# The structure
- Name: <e.g., Job>
- Specs that reference it: <list>
# Your task
1. Read every listed spec's references to <name>. Note the fields, types, optionality, valid ranges, and lifecycle each spec describes.
2. Build a unified picture: are there contradictions, omissions, or extensions?
3. If contradictions exist, the source code is the tiebreaker. The original analysis spec generation may have introduced inconsistency that the source resolves cleanly.
4. Produce patches: usually, one spec is "right" and others should be aligned to it. Sometimes all are wrong and need correction. Each patch targets a specific spec.
# Output
{
"structure_name": "<name>",
"specs_affected": [<list>],
"canonical_shape": "<the agreed-upon shape, prose>",
"inconsistencies": [
{
"spec": "<path>",
"section": "<section>",
"issue": "<what's wrong>",
"patch": {"operation": "...", "before": "...", "after": "...", "rationale": "..."}
}
],
"deferred": <true | false>
}
You are auditing ownership of a shared resource across multiple specs.
# The resource
- Resource: <e.g., the directory `pipeline-data/jobs/<id>/status.json`>
- Specs that reference it: <list>
# Your task
1. For each spec, identify what role it plays toward this resource (creates / reads / writes / deletes / watches / locks).
2. Determine whether ownership is well-defined: exactly one creator, clear writer protocol, consistent reader assumptions.
3. Identify gaps: nobody creates it, multiple specs claim creation, conflicting concurrency assumptions, etc.
4. Produce patches that establish a single owner and align reader/writer claims.
# Output
{
"resource": "<resource>",
"specs_affected": [<list>],
"intended_owner": "<spec path>",
"issues": [
{"type": "<no_owner | multiple_owners | reader_writer_conflict | concurrency_mismatch>", "description": "...", "patches": [...]}
],
"deferred": <true | false>
}
You are performing a single global terminology audit across all SpecOps analysis specs in a set.
# Specs in scope
<list of all spec paths>
# Your task
1. Build a glossary of domain terms used as nouns or verbs across the specs. Focus on entities the system reasons about (job, task, run, execution, pipeline, stage, step) and verbs that act on them (submit, enqueue, dispatch, trigger, run, execute).
2. Cluster terms that appear to refer to the same concept. Within each cluster, identify the term that appears most consistently or matches the source code's actual identifiers.
3. For each spec that uses a non-canonical term, propose a patch that aligns it with the canonical term — preserving any place where the term is intentionally distinct (e.g., a "task" inside a "job" is a different concept than the "job" itself; don't collapse those).
# Output
{
"glossary": [
{
"canonical_term": "<term>",
"definition": "<one-line>",
"variants_seen": ["<variant>", "<variant>"],
"patches": [
{"spec": "<path>", "section": "<section>", "before": "...", "after": "...", "preserves_distinction": <true | false>}
]
}
],
"deferred": [<terms where the canonical choice needs a human decision, with context>]
}
When all subagents return:
Collect all patches across all four check types. Group them by target spec — a single spec often receives patches from multiple sources (a pairwise check, a data model check, and a terminology check might all touch the same section).
Reconcile patch overlaps. If two patches modify the same passage of the same spec, merge them into a single coherent edit. If they conflict, prefer the patch with the strongest evidence (source code > pairwise > terminology) and log the conflict.
Apply patches to each affected spec. Append an entry to each spec's audit log:
### <YYYY-MM-DD> — Coherence audit (cross-spec)
- Patches applied: <count>
- Sources: <pairwise | data_model | side_effect | terminology>
- Coherence report: `<path>`
Write the coherence report at docs/specs/coherence-audit.md:
# Coherence Audit
- **Audited:** <date>
- **Specs in scope:** <count>
- **Implementation order:** `implementation-order.md`
## Summary
- Pairwise edges checked: <count>
- Pairwise mismatches found: <count> (resolved: <n>, deferred: <n>)
- Shared data structures checked: <count>
- Data model inconsistencies: <count> (resolved: <n>, deferred: <n>)
- Shared resources checked: <count>
- Ownership issues: <count> (resolved: <n>, deferred: <n>)
- Terminology variants normalized: <count>
- Total patches applied: <count> across <n> specs
- Cycles in dependency graph: <count>
## Findings by category
<per-category sections with details>
## Deferred items
<items needing design decisions, with full context per the deferral schema>
## Glossary
<canonical terms and definitions>
Write/update the implementation order file with any cycles discovered, plus the dependency tier listing.
Summarize for the user.
User: "Run a coherence audit on docs/specs/analysis/."
docs/specs/implementation-order.md with 5 tiers, leaf modules (config, utils) first, UI components last. No cycles detected.Job referenced in 9 specs, 3 disagree on the status enum values; PipelineEvent referenced in 4 specs, all agree.coherence-audit.md with full findings and the glossary.This skill operates on the full set of analysis specs after they're individually generated. Updated pipeline:
The four skills together cover the four classes of drift: within-spec (ambiguity), cross-spec (coherence), spec-to-spec downstream (conformance), spec-to-code (drift). Each catches a class the others structurally cannot see.
testing
This skill should be used when the user asks to "run the spec", "implement the spec", or "execute the spec". Implements every step in a SpecOps implementation spec by delegating each step (or logical group of adjacent steps) to a sequential subagent, conventional-committing each one independently, and — when `roborev` is on the path — running `roborev check` on every commit and `roborev fix` (with spec context, so the fix cannot silently drift the implementation away from the spec) on any commit that fails.
development
Exhaustively audit a top-level UI implementation component against an HTML prototype and produce a grouped markdown checklist of corrections. Use when a user asks for UI parity review, visual QA, design implementation audit, pixel-level drift detection, or behavior/style mismatch analysis between prototype HTML and shipped component code.
development
Audit a SpecOps implementation spec against its source analysis spec to find requirements, policies, contracts, edge cases, error modes, invariants, defaults, side effects, or implementation steps that the implementation has dropped, weakened, contradicted, or silently changed — then patch the implementation spec to restore them. Use this skill whenever the user mentions auditing, comparing, conforming, reconciling, or checking an implementation spec against an analysis spec, finding gaps between two specs, ensuring an implementation spec preserves analysis behavior, or verifying spec derivation or traceability. Also trigger when the user describes "did the implementation spec lose anything from the analysis," "does the implementation match the analysis," "verify the implementation spec covers everything," or asks to confirm one spec is faithful to another. Run this before generating code from an implementation spec and after either spec is edited.
development
This skill should be used when the user asks to create a refactor-focused SpecOps plan for a specific source folder and explicit refactor goal.