refine-spec
Use when the user asks whether a spec is still accurate, suspects spec drift, wants a capability's behavior captured before or after a change, or names code that has no spec. Reconciles one capability's loom spec against its tests and code and reports drift by requirement id.
- License 许可
- MIT
- 所属仓库
- ZPerrin/loom
- 最近更新
- 2026-09-08
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- refine-spec
- description
- Use when the user asks whether a spec is still accurate, suspects spec drift, wants a capability's behavior captured before or after a change, or names code that has no spec. Reconciles one capability's loom spec against its tests and code and reports drift by requirement id.
03 SKILL.md 正文
Refine spec
Hold one capability's living spec against the code that claims to implement it. Read what the tests and code do, compare it with what the spec says by id, put each divergence to the operator with a recommended direction, and land only what the operator rules. Drift runs both ways: a spec that lags the code and code that broke the spec look the same until the operator says which is the bug.
Two entry states:
- No repo spec: every behavior the evidence shows is undocumented. The findings are the fence, and
specwrites the first repo spec from it. - Repo spec exists: compare by id. Findings land as change-log lines, as in-place edits through
spec, or as blocks in a work spec.
Refine Spec Control Surfaces
These are the surfaces refine-spec reads or writes directly; the full key map is the reference project.
| Surface | Refine spec uses it for |
|---|---|
[specs].repo_dir |
where the capability's repo spec is looked for (default docs/specs) |
[specs].work_dir |
where a proposal with text lands, as a work spec spec writes (default .loom/specs) |
.loom/skills/spec.md |
repo opinion shared with spec: capability boundaries and the form a test ref is resolved by |
.loom/skills/refine-spec.md |
optional repo opinion: how to sample a run, refs known to be stale, where a sweep costs too much |
doc-linter |
the gate on every file touched |
doc-stamp |
updated=<today> on the repo spec a line was appended to |
spec |
writes every requirement block: a first repo spec, an in-place extension, a work spec |
| tests, code, a sampled run | the evidence, in that order of authority |
Hard constraints
- Evidence in order, named. Every finding names its evidence: the test first, the code it exercises where no test speaks, a sampled run only where both are silent. A sample answers one named question; it is never a sweep.
- Findings carry an id. A finding is keyed by the id it contradicts, the id it extends, or the id
specmints for it. A file or a line number is a locator, never a key. - Never a silent rewrite. This skill writes only change-log lines and the stamp to a repo spec, the tier the grammar gives a reconciliation pass. Recommend a direction for each finding, and write only what the operator ruled.
- Confirm before writing. Present the whole set of findings before any file changes. An invocation that fixes a direction for every finding kind, such as leaving all of them open, is a confirmed set, which is how a brief drives this skill with no operator present.
- Writing is spec's. New blocks, replacement blocks, and a first repo spec go through
spec, handed the fence in its own terms: capability, token, boundary, and every decision and invariant the operator gave, so its Confirm needs no second round. Where the harness cannot invoke a skill from a skill, read spec and follow it. - One capability. The scope is the capability named or the one the diff touched. Behavior that belongs to a neighbor is a finding for the neighbor's spec, reported and not chased.
Workflow
The gate first: a loom gate: refine-spec receipt in your context says whether the repo opinion was read and which hook ran, with that opinion and that hook's output beneath it. Without one for this invocation, do the same by hand: read .loom/skills/refine-spec.md if it exists and run bash "${CLAUDE_PLUGIN_ROOT}/scripts/skill-hook" refine-spec; exit 3 is no hook. A receipt from an earlier invocation does not count, and a hook tolerates a repeat.
1. Read
When no capability is named, or the name is a script, a module, or a test file, map first: list the product's features from the front doors (README, roadmap, the skills' descriptions), put the cut to the operator as features at the 20,000-foot view, and read no test until one is chosen. Evidence is walked inside a fence, never to find one.
The repo spec if one exists, .loom/skills/spec.md, the tests the scenarios name and the tests that cover the capability, then the code they exercise. Resolve every test ref by the repo's form; a ref that resolves to nothing is a finding. Where a sampled run is called for, write down what was run.
2. Compare
Walk the spec by id: for each requirement and scenario, what the evidence says. Then walk the evidence for what the spec does not say: every assertion a test makes, a clean expectation included, and every branch the code takes. Classify each divergence:
- Undocumented: behavior the evidence asserts and no id covers.
- Drift: the evidence contradicts a requirement or scenario; either side may be the bug.
- Unverified: a scenario without a test ref, a ref that resolves to nothing, a test that does not establish the sentence it is named for, or a requirement without a scenario.
- Dead: no test and no code path exercises the requirement.
- Detail: the evidence pins how the code does something rather than what the feature promises; it is named in the report and never logged, and a test that pins the how gets no scenario.
An existing change-log line that already records the observation under the id is a finding already open: cite it, do not log it again. A finding doc-linter already reports by id is carried in the report from the lint output, not logged; the change log holds what only this pass observed.
3. Confirm
Present the findings by id, each with its kind, its evidence, and your recommended direction: the spec follows the code (for a dead requirement, the block goes and its id retires), the code is the bug, or open. Rounds as needed; wait for the operator between them. With no repo spec, present the fence in spec's terms plus the behaviors found, the test each names, and the neighbors the evidence touched.
4. Land
- Left open: append the change-log line to the repo spec. Where there is text to propose,
specwrites it as a work spec carrying only those blocks. - Ruled: the operator has closed the finding. Hand the ruling to
spec, which makes the edit and deletes the open line it closes in the same diff, or leaves the line open with the ruling in its text while the code is the bug. Lines this skill writes itself endopen. - No repo spec:
specwrites the first repo spec from the fence.
Stamp the repo spec with bash "${CLAUDE_PLUGIN_ROOT}/scripts/doc-stamp" <file> updated=<today> when a line was appended. Run bash "${CLAUDE_PLUGIN_ROOT}/scripts/doc-linter"; a finding on a line this skill wrote sends it back here.
Output
Report the capability and the evidence read, with any sampled run and the question it answered; each finding on one line with its id, kind, evidence, and the direction ruled or left open; the change-log lines appended and the open lines cited instead; the file spec wrote, or that it wrote nothing; the refs that resolved to nothing; behavior handed to a neighbor's spec; and the lint result. If the spec and the evidence agree, say so and write nothing.
References
The grammar and the writing rules the findings and the change-log lines obey:
!cat "${CLAUDE_PLUGIN_ROOT}/references/spec-grammar.md" "${CLAUDE_PLUGIN_ROOT}/references/spec-writing-rules.md" 2>/dev/null || true
If the line above shows a command instead of the grammar, read spec-grammar.md and spec-writing-rules.md before comparing.
04 同仓库更多 Skills
weft
Use when a loom-managed documentation set needs an editorial pass to prune, condense, reroute, and realign durable project docs with the code and the editorial ethos.
weave
Use when wrapping up a loom work session, especially when durable docs, close-out checks, merge handoff, or branch cleanup need attention.
warp
Use when opening a unit of work in a loom managed repo, especially when orientation, branch/worktree setup, ticket context, or kickoff guidance may be needed.
spec
Use when the user asks to spec a capability, write its requirements, or capture what the code does before changing it. Produces a repo spec of what the code does or a work spec of what one unit of work will make true, under the loom spec grammar.
dress
Use when adopting loom on a repo, or re-tuning an existing loom configuration.