بنقرة واحدة
spec-sync
Reconcile SPEC.md and the source — full-domain coverage + drift analysis, applied as one-way syncs.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Reconcile SPEC.md and the source — full-domain coverage + drift analysis, applied as one-way syncs.
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Look up, trace, and create spec requirements, and bootstrap a new SPEC.md.
Graduate the winning candidate from the spec-driven `implementations/<version>/<n>-<name>/` tree to the sole implementation at the repo root — a one-way move, only once one candidate has clearly won.
Scaffold a new candidate implementation in the spec-driven `implementations/<version>/<n>-<name>/` tree, to stress-test the spec against a fresh stack.
Refresh STATUS.md to match current spec coverage — the lightweight, hook-safe ledger writer in the spec-sync family.
| name | spec-sync |
| disable-model-invocation | true |
| description | Reconcile SPEC.md and the source — full-domain coverage + drift analysis, applied as one-way syncs. |
| argument-hint | [--to-spec | --to-source] |
The single skill for understanding and reconciling the relationship between SPEC.md and the implementation. Every run analyzes the full domain — all requirements against all code, in both directions, plus requirement-quality checks — and reports where the contract and the code agree, diverge, or drift.
By default it analyzes and proposes; it writes nothing but the coverage ledger
(STATUS.md). When you name a direction, it applies that resolution:
--to-spec (source → spec): the code does something the spec doesn't
capture. The skill drafts an EARS requirement and routes it through
spec-req for your confirmation — it proposes, it does not canonize code
into the contract silently.--to-source (spec → code): the spec requires something the code doesn't
do. Writing that code is implementation — design, tests, review — not a
mechanical sync. The skill produces the gap list and hands off to a
development session. It never silently writes code to match a sentence.Only the ledger is ever written without a judgment call, and that write is
delegated to spec-status so the two skills never
duplicate it.
%%{ init: { 'look': 'handDrawn' } }%%
flowchart TD
Start(["/sextant:spec-sync [dir]"]) --> Locate["Locate SPEC.md + impls"]
subgraph "Step 2: Full-domain analysis (read-only)"
Locate --> Forward["Forward: spec → code coverage"]
Forward --> Reverse["Reverse: code → spec drift + orphan check"]
Reverse --> Quality["Requirement quality: EARS + overly-specific"]
Quality --> Cross["Cross-impl comparison (if multiple)"]
end
Cross --> Classify["Classify each divergence + recommend direction"]
Classify --> Mode{"Direction flag?"}
Mode -->|"none (default)"| Plan["Report + reconciliation plan"]
Plan --> Ledger1["Refresh ledger (spec-status)"]
Ledger1 --> Done1(["Stop — nothing else written"])
Mode -->|"--to-spec"| Draft["Draft EARS requirements from drift"]
Draft --> ConfirmS["Confirm each → spec-req writes SPEC.md"]
ConfirmS --> Ledger2["Refresh ledger (spec-status)"]
Mode -->|"--to-source"| Gaps["Build impl gap list"]
Gaps --> Handoff["Hand to dev session (no auto-code)"]
Handoff --> Ledger3["Refresh ledger (spec-status)"]
Find the current SPEC.md using the shared discovery order in
references/locate-spec.md (that file is the
source of truth). In brief, first hit wins: STATUS.md spec-pointer → spec/
directory (incl. vnext/, exploration/, migration/) → justfile spec
variable → CURRENT_SPEC_VERSION → root SPEC.md (or docs/spec.md).
spec-sync is always user-invoked and interactive — it is not wired to
hooks or called from a release workflow like /ship-it. So if no spec is found, say so and point the
user at spec-req init rather than no-op'ing silently:
No SPEC.md found. spec-sync reconciles a spec against code — there's no spec
here yet. Run /sextant:spec-req init to scaffold one.
Read the spec and extract every requirement ID ([XX-NN] format) into a
full inventory:
Found N requirements across M categories:
CM: CM-01, CM-02, CM-03
OP: OP-01, OP-02
...
FUT: FUT-01, FUT-02 (deferred — excluded from coverage)
Counting rule. Count per references/counting-rule.md
(the source of truth): one distinct [XX-NN] ID = one requirement, lettered
decompositions (CL-21a, …) each count as one, FUT/deferred and retired IDs
excluded. Getting this wrong is the most common STATUS.md drift, so the
inventory count must be exact before anything downstream relies on it.
Then locate the implementation(s): the repo root, a versioned
implementations/<version>/<impl>/ tree, and any STATUS.md files that
already track coverage. A pre-existing STATUS.md is a starting point, not the
answer — the analysis verifies whether it's accurate.
This is the read-only core. It runs in full on every invocation — there is no narrowed-axis mode. (The analysis is the heavy part of the skill; for a large spec it is a good candidate to delegate to a subagent — pass the spec path and impl root, let it return the structured findings while the main agent works.)
For each non-FUT requirement ID:
Best-effort, from available signals:
git log for features/behaviors that don't map to any
requirement ID.Flag anything the code does that the spec doesn't mention as drift.
Scan every requirement's text (this needs only the spec, not the code):
EARS conformance. Requirements should use one of the five EARS patterns
(see references/ears-patterns.md).
Flag non-conforming requirements with a suggested rewrite. Advisory, not
blocking — early drafts may be intentionally informal.
Overly-specific. Flag requirements that prescribe how (specific OSC sequences, file paths, library names, hardcoded numbers, internal function names) instead of what. The contract is user-observable behavior; mechanism belongs in implementation notes. Suggest a higher-level rewrite for each.
When multiple implementations exist, classify each separately and present a matrix:
| Requirement | impl-1 (Python) | impl-2 (JS) | impl-3 (hybrid) |
|-------------|-----------------|-------------|-----------------|
| CM-01 | Covered | Covered | Missing |
| OP-01 | Missing | Missing | Missing |
A requirement missing from all implementations is a strong signal of a spec problem — the requirement may be unclear or impractical.
The analysis is simpler: report the full requirement inventory, run the quality checks, flag ambiguous or contradictory requirements, and confirm the spec is ready to build against.
Present findings as a structured report:
## Spec ⇄ Code — <project> (spec <version>)
### Coverage: N/M requirements (X%)
| Status | Count | Requirements |
|-------------|-------|-------------------------|
| Covered | N | CM-01, CM-02, OP-01, … |
| Partial | N | OP-03, BR-01, … |
| Missing | N | LS-02, CM-04, … |
| Contradicts | N | OP-02, … |
| Deferred | N | FUT-01, FUT-02, … |
### Detailed findings
(for each non-Covered requirement: status, evidence, gap)
### Drift (code → spec)
(undocumented behavior; orphaned tracking)
### Requirement quality
(EARS non-conformance; overly-specific requirements; with suggested rewrites)
Map every non-aligned item to the direction that should fix it:
| Divergence | Resolution direction | What applying it means |
|---|---|---|
| Spec requires X, code is Missing it | --to-source | implement X (dev work) |
| Spec requires X, code Contradicts (does Y) | needs a decision | reword the spec or fix the code — surface, don't pick |
| Code does Z, spec is silent (drift) | --to-spec | add a requirement for Z (or decide Z should be removed) |
| Spec is ambiguous and impls disagree | --to-spec | tighten the requirement text |
Contradictions are never auto-resolved in either direction. They are the case where both artifacts make a claim and only a human can say which is right. Surface each with both sides stated; let the user choose the direction.
Present the report above plus a reconciliation plan grouped by direction:
→ to-source (spec leads, code missing): 3 items
[OP-04] retry-with-backoff — no implementation found
[CM-05] config validation on startup — partial (src/cfg.ts:40, no error path)
→ to-spec (code leads, spec silent): 2 items
src/export.ts:88 — CSV export; no requirement covers it
⚠ needs decision (contradiction): 1 item
[UP-01] "system monospace" — code ships a bundled font (src/ui.css:12)
Recommended: run `spec-sync --to-spec` to capture the 2 drift items, then a
dev session for the 3 to-source gaps. Resolve [UP-01] by hand.
Then refresh the ledger (call spec-status) so STATUS.md records current
coverage and the open divergences, and stop. The ledger is the only thing
the default writes — it leaves the tracker correct without touching spec or
code.
--to-spec — capture code into the contractFor each --to-spec drift item:
spec-req new patterns) describing
the observed behavior.spec-req's create flow
(auto-assigned category + number, sorted into the right section).Never write a requirement the user hasn't confirmed. Capturing code wholesale
would canonize whatever the code happens to do — the opposite of spec-leads
development. The default lean is source → spec because code usually moves
faster than the spec; the confirmation gate keeps that lean from becoming
rubber-stamping. After writing, refresh the ledger via spec-status.
--to-source — surface the implementation gapspec-sync does not write code. For each --to-source item (Missing or
Partial requirements where the spec is authoritative), produce an actionable
gap list:
Implementation gaps (spec → code):
[OP-04] When a request fails transiently, the system shall retry with
exponential backoff. → no implementation. Suggested home: src/http.ts
[CM-05] config validation on startup → partial; missing the error path.
src/cfg.ts:40
Then hand off to a development session seeded with this list — a
new-feature workflow (or a greenfield one for a fresh implementation). If your
setup has the recipe plugin, /recipe new-feature / /recipe greenfield are
those workflows; otherwise just start a normal dev session with the gap list.
The user (or a dev session) writes and tests the code; spec-status then flips
the rows to Covered on the next ledger refresh.
--to-spec or --to-source, confirmed per item.--to-source emits a gap list and hands to a
dev session.--to-spec drafts and asks
before writing SPEC.md.spec-status, never written directly here./sextant:spec-status — the lightweight ledger
writer. spec-sync delegates every STATUS.md refresh to it. Use it on its
own (or wired into /ship-it) for the automatable "just update the tracker"
loop, where spec-sync is the deliberate, interactive deep look./sextant:spec-req — --to-spec routes drafted
requirements through its create flow; also the place to look up or trace a
single requirement. Its init mode is what to run first when there's no spec
to reconcile against yet./sextant:impl-new — scaffolds a candidate whose
seeded STATUS.md this skill's analysis reads against.