Agent skill
openspec-sync-change-docs
Rewrite the active OpenSpec change artifacts under `openspec/changes/CHANGE_NAME/` so they match the code currently implemented on the branch relative to `main`. Use when implementation drift appears after `/opsx:apply`, after review-driven tweaks, or whenever the user asks to sync, refresh, catch up, or align OpenSpec change docs with the real code before verify or archive.
Install this agent skill to your Project
npx add-skill https://github.com/qixing-jk/all-api-hub/tree/main/.codex/skills/openspec-sync-change-docs
SKILL.md
OpenSpec Sync Change Docs
Overview
Treat the current branch implementation as the source of truth and update the active change docs to describe what was actually built.
Keep the edits inside openspec/changes/<name>/ unless the user explicitly asks for a later sync into openspec/specs/.
Workflow
-
Select the change
If the user names a change, use it.
Otherwise, discover active changes first:
bashopenspec list --jsonThen:
- If there are no active changes, stop and explain there is no active change to sync
- If there is exactly one active change, auto-select it
- If recent workflow context makes one change clearly intended, use that change and say why
- If multiple active changes remain plausible, prompt the user to choose
Announce the selected change and the comparison base branch. Default to
main. Ifmaindoes not exist locally, stop and ask for the correct base branch instead of guessing. -
Load the change context
Prefer the OpenSpec CLI:
bashopenspec status --change "<name>" --json openspec instructions apply --change "<name>" --jsonIf the CLI is unavailable or errors, fall back to direct filesystem discovery under
openspec/changes/<name>/and read whichever of these files exist:proposal.mddesign.mdtasks.md- delta specs in
openspec/changes/<name>/specs/*/spec.md
For each capability touched by the change, read the base-branch main spec from the base branch itself, not from the working tree:
bashgit show <base>:openspec/specs/<capability>/spec.mdIf that path does not exist on the base branch, treat the capability as new. The change docs are deltas against the base branch, not standalone full specs.
-
Measure implementation drift
Inspect the branch against the selected base branch before editing docs:
bashgit diff --name-only <base>...HEAD git diff --stat <base>...HEADUse the full branch diff only as a discovery aid. Then narrow the evidence set to files that clearly implement the selected change based on:
- capability names from the delta specs
- tasks and design references
- imports, symbols, tests, and entrypoints tied to the selected change
Read the changed code, tests, and configuration files that explain the actual behavior. Prefer implementation evidence over earlier artifact wording.
Pay special attention to:
- Behaviors added after the initial
/opsx:apply - Review-driven or user-requested tweaks
- Renamed or removed capabilities
- Test cases that describe the real acceptance behavior better than the stale spec text
If the branch contains unrelated work and you cannot confidently isolate the selected change, stop and ask instead of folding the whole branch into one change's docs.
-
Rewrite the change artifacts to match the code
Update only the active change artifacts unless the user explicitly asks for more:
- Rewrite
proposal.mdwhen the change scope, capability list, or impact statement materially shifted - Rewrite
design.mdwhen the implemented architecture, data flow, API shape, or tradeoffs differ from the draft - Rewrite
tasks.mdso completed work is checked off, obsolete tasks are removed or reworded, and remaining follow-ups reflect reality - Rewrite each delta spec so it describes the actual diff from
main
For delta specs:
- Use
## ADDED Requirementsfor behavior that exists on this branch but not inmain - Use
## MODIFIED Requirementswhen branch behavior changes an existing requirement frommain - Use
## REMOVED Requirementswhen the branch intentionally removes behavior present inmain - Use
## RENAMED Requirementsonly for genuine renames
Keep delta specs minimal and capability-scoped. Do not copy an entire main spec into the change unless the whole requirement actually changed.
- Rewrite
-
Decide whether the change should still be the same change
Stop and recommend a new change instead of force-fitting the docs when:
- The branch now implements a different intent from the original proposal
- The work spans unrelated capabilities that should be reviewed independently
- The old change can still be completed or archived on its own without rewriting history
Small scope adjustments, clarified requirements, and design corrections should stay in the same change.
-
Validate the rewritten docs
Re-read the updated artifacts against both:
- the changed code on the current branch
- the relevant base-branch specs read via
git show <base>:openspec/specs/*/spec.md
Confirm:
- the docs describe what is actually implemented
- the delta specs still read as diffs, not full copies
tasks.mdstatus matches reality- no edits leaked into unrelated change folders or main specs
-
Report the outcome
Summarize:
- which change was updated
- which artifact files changed
- the main implementation differences captured
- any remaining ambiguity or intentional drift that still needs a human decision
Guardrails
- Treat code and tests on the current branch as the source of truth for this skill.
- Do not modify
openspec/specs/unless the user explicitly asks to sync main specs too. - Do not archive the change as part of this skill.
- Do not rewrite one change to account for unrelated branch work.
- Do not invent unimplemented requirements just to preserve older wording.
- Preserve useful existing text when it is still accurate; prefer targeted rewrites over wholesale churn.
- If the repo does not have a clean or available
mainreference, stop and ask for the correct base branch.
Do Not Use This Skill When
- The user wants to sync delta specs into
openspec/specs/; useopenspec-sync-specsinstead. - The user wants to validate readiness or detect divergence without editing docs; use
openspec-verify-changeinstead. - The user wants to continue implementation work; use
openspec-apply-changeinstead.
Example Triggers
change openspec change docs in current branch to align with the implemented codecatch up the current OpenSpec change docs with what we actually builtrewrite this change's proposal, specs, design, and tasks so they match the branch against mainrefresh the active openspec change docs before verify
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
openspec-onboard
Guided onboarding for OpenSpec - walk through a complete workflow cycle with narration and real codebase work.
openspec-archive-change
Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a change after implementation is complete.
openspec-explore
Enter explore mode - a thinking partner for exploring ideas, investigating problems, and clarifying requirements. Use when the user wants to think through something before or during a change.
openspec-apply-change
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
openspec-ff-change
Fast-forward through OpenSpec artifact creation. Use when the user wants to quickly create all artifacts needed for implementation without stepping through each one individually.
openspec-continue-change
Continue working on an OpenSpec change by creating the next artifact. Use when the user wants to progress their change, create the next artifact, or continue their workflow.
Didn't find tool you were looking for?