Verify implementation matches OpenSpec change artifacts. Use when the user wants to validate that implementation is complete, correct, and coherent before archi
复制下面这句话,粘贴给 Claude Code、Codex、Cursor 等 AI 编程工具,它会读取安装说明并在你确认后完成安装。
请阅读 https://ai.atlankj.com/install/asset/gh-openspec-verify-change-f6ba982178ea ,按照其中的说明把「openspec-verify-change」安装到你(当前 AI 工具)中。执行前先告诉我将运行的命令和写入的位置,等我确认。
查看 AI 将读取的安装说明正在读取 GitHub 原文…
内容来自 GitHub 原始文件,由原作者维护。在 GitHub 查看
Verify that an implementation matches the change artifacts (specs, tasks, design).
Store selection: If the user names a store (a store is a standalone OpenSpec repo registered on this machine) or the work lives in one, run openspec store list --json to discover registered store ids, then pass --store <id> on the commands that read or write specs and changes (new change, status, instructions, list, show, validate, archive, doctor, context, schemas, view). Once selected, treat --store <id> as sticky for the rest of the workflow. Every unscoped example of those commands below is shorthand: before running it, append the flag. For example, run openspec status --change "<name>" --json --store "<id>", not the unscoped form shown below. Other commands do not take the flag. Hints printed by commands already carry the flag; keep it on follow-ups. Without a store, commands act on the nearest local openspec/ root.
Project check: These steps expect a project that already uses OpenSpec. Before the first step that writes anything (new change, archive, sync specs, or authoring an artifact file), confirm the project has a root: run openspec list --json (with --store <id> when a store is selected, since the store is then the root) and read root. A root object means the project is set up. "root": null means it is not - there is no openspec/ directory here, and a write such as openspec new change would create one as a side effect. The command also exits non-zero, which is that answer rather than a broken CLI, so read the JSON instead of retrying or working around it.
One "root": null is not about setup: when a status error message starts with Declared in or Invalid store declaration in and names this project's openspec/config.yaml (or config.yml), the project does use OpenSpec through a store it declares, which this machine cannot resolve (the store is not registered, or the store: line is malformed). Do not treat it as uninitialized and skip the branches below: stop before writing and show the user that error's message and fix.
Otherwise, with no root, what happens next depends on how this workflow was reached:
openspec init), target a store they already have (--store <id>), or continue without OpenSpec for this request. Wait for their answer.In both branches, never create the root as a side effect: do not run openspec init until the user asks for it, do not hand-create openspec/ files, and do not let a command create it.
Input: Optionally specify a change name. If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
Steps
Select the change
If a name is provided, use it. Otherwise:
openspec list --json to get available changes and ask the user to select oneWhen prompting, show all active changes returned by the list, including changes with status: "no-tasks".
Include the schema used for each change if available.
Mark changes with incomplete tasks as "(In Progress)".
Always announce: "Using change: " and how to override (e.g., /openspec-verify-change <other>).
Check status to understand the schema
openspec status --change "<name>" --json
Parse the JSON to understand:
schemaName: The workflow being used (e.g., "spec-driven")planningHome, changeRoot, artifactPaths, and actionContext: path and scope contextGet planning context and load artifacts
openspec instructions apply --change "<name>" --json
This returns the change directory, contextFiles (artifact ID -> array of concrete file paths), taskTrackingConfigured, and top-level tasks and progress aggregated from every concrete file matched by the schema's apply.tracks configuration that could be read. Read all available artifacts from contextFiles.
Treat apply state and instruction as context, not a verification verdict. Do not implement tasks or archive the change during verification.
Initialize verification report structure
Create a report structure with three dimensions:
Each dimension can have CRITICAL, WARNING, or SUGGESTION issues.
Verification is advisory. Respect intentional omissions such as skip_specs: true, optional design documents, and schemas without task tracking. Do not require or invent optional or intentionally omitted artifacts to obtain a clean report. describes a limit of this report, not a new archive prerequisite. Archive retains its own checks and user-confirmation behavior.
Verification Heuristics
Output Format
Use clear markdown with:
file.ts:123Not verifiedMark checks the schema does not define, or artifacts the status reports as intentionally skipped, as Not applicable. The correctness checks of a change whose readable delta specs contain REMOVED or RENAMED requirements but no ADDED or MODIFIED requirements are also Not applicable (see step 6). Exclude them from skipped-check counts and the archive-readiness assessment. Reserve Not verified for applicable checks whose evidence is missing or unusable.
If only task evidence is available for applicable checks, verify task completion only and mark the remaining applicable checks, including Code Pattern Consistency, as not verified with the reason "Only task evidence available".
If artifacts cannot be read or contain no usable requirements, scenarios, or design decisions, mark the affected checks as not verified with the specific reason. Continue checks supported by the remaining evidence, but a partially checked input set is not a fully verified check. Missing requirements affect Spec Coverage and Requirement Implementation Mapping; missing scenarios affect Scenario Coverage; missing design decisions affect Design Adherence.
Verify Completeness
Task Completion:
taskTrackingConfigured is false, report Task Completion as not applicable. Do not treat empty tasks as missing evidence.tasks and progress fields. They already aggregate every readable concrete file matched by apply.tracks, regardless of the tracked artifact's ID; do not infer tracking from a contextFiles key.unavailableTrackingFiles is nonempty, mark Task Completion as not verified and include every unavailable path and reason. Continue using any readable task evidence, but do not infer completion from the partial tasks and progress fields.taskTrackingConfigured is true and tasks is empty, mark Task Completion as not verified and record the reason from apply state and instruction. Nonzero totals alone do not establish evaluable task descriptions.progress.progress.remaining is greater than 0:
Spec Coverage:
skip_specs: true, or the schema defines no spec artifact, report the spec-dependent checks as not applicable.contextFiles is keyed by artifact id, and artifact ids come from the active schema. If contextFiles.specs is absent or empty, mark Spec Coverage, Requirement Implementation Mapping, and Scenario Coverage as not verified; do not treat any of them as clean.contextFiles.specs:
FROM:/TO: pairs under ## RENAMED Requirements) and note the delta section each one sits under: ## ADDED, ## MODIFIED, ## REMOVED, or ## RENAMED Requirements. The section decides what the check looks for.openspec/ artifacts or docs, or in code that serves only the Migration note or an ADDED requirement, are not evidence by themselves. Report any code path that still delivers the removed behavior, including one shared with an ADDED requirement.FROM:/TO:), the name changes but the behavior stays, so check the TO requirement for that unchanged behavior:
<planningHome.root>/openspec/specs/<capability-path>/spec.md, using the same capability path as the delta spec: the requirement under the FROM name, or under the TO name only when the FROM name is absent because the main spec is already synced. Its body and scenarios are the evidence for the behavior the TO requirement keeps.Verify Correctness
If the delta specs are readable and contain at least one REMOVED or RENAMED requirement but no ADDED or MODIFIED requirements (the change only removes or renames requirements), report Requirement Implementation Mapping and Scenario Coverage as Not applicable. The REMOVED and RENAMED checks under Spec Coverage are the evidence for such a change (each RENAMED entry is checked there against its baseline behavior), so do not mark these two checks as not verified. A delta spec with no parseable requirements at all is unusable evidence, not a removal-only change: mark these checks as not verified.
Requirement Implementation Mapping:
Scenario Coverage:
Verify Coherence
Design Adherence:
contextFiles.design exists:
contextFiles.design is absent or empty: mark Design Adherence as not verified. With other supporting artifacts, Code Pattern Consistency still runs; the task-only case remains limited to task completion.Code Pattern Consistency:
Generate Verification Report
Summary Scorecard:
## Verification Report: <change-name>
### Summary
| Dimension | Status |
|--------------|------------------|
| Completeness | X/Y tasks, N reqs|
| Correctness | M/N reqs covered |
| Coherence | Followed/Issues |
In each Status cell, report the results of checks that ran and Not verified (<reason>) for every skipped check. If all checks in a dimension were skipped, start the cell with Not verified. Never score a skipped check as passing. Treat every not verified or partially verified check as skipped in the final assessment. Count only ADDED and MODIFIED requirements in N, and report REMOVED and RENAMED requirements separately (for example, "1 removal confirmed, 1 rename verified"). For a change that only removes or renames requirements, the Correctness cell reads Not applicable (no ADDED or MODIFIED requirements).
Issues by Priority:
CRITICAL (Must fix before archive):
WARNING (Should fix):
SUGGESTION (Nice to fix):
Final Assessment: