The workflow selects a change, reads its delta specs, and checks the remote base before editing canonical specs. It merges requirement changes against the remote snapshot, handles already-synced changes without edits, and validates updated specs. Guardrails require preserving unspecified content, asking when unclear, and summarizing the changes.
85%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Passed
No findings from the security scan
Sync delta specs from a change to main specs.
This is an agent-driven operation - you will read delta specs and directly edit main specs to apply the changes. This allows intelligent merging (e.g., adding a scenario without copying the entire requirement).
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). 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.
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
If no change name provided, prompt for selection
Run openspec list --json to get available changes. Use the AskUserQuestion tool to let the user select.
Show changes that have delta specs (under specs/ directory).
IMPORTANT: Do NOT guess or auto-select a change. Always let the user choose.
Resolve change context
Run:
openspec status --change "<name>" --jsonFind delta specs
Use artifactPaths.specs.existingOutputPaths from the status JSON as the list of delta spec files.
Each delta spec file contains sections like:
## ADDED Requirements - New requirements to add## MODIFIED Requirements - Changes to existing requirements## REMOVED Requirements - Requirements to remove## RENAMED Requirements - Requirements to rename (FROM:/TO: format)If no delta specs found, inform user and stop.
Preflight against the remote base before reading canonical specs
Before reading or editing any canonical capability spec, fetch origin and resolve the
target base branch. Use the dispatch context's BASE value when present; otherwise use
main. A caller-provided BASE_BRANCH override takes precedence.
git fetch origin || { echo "Sync preflight failed: could not fetch origin" >&2; exit 1; }
BASE_BRANCH="${BASE_BRANCH:-${BASE:-main}}"
git rev-parse --verify "refs/remotes/origin/${BASE_BRANCH}^{commit}" >/dev/null || {
echo "Sync preflight failed: origin/${BASE_BRANCH} could not be resolved" >&2
exit 1
}If the fetch fails or the remote base ref cannot be resolved, report the preflight failure
and stop before editing any canonical spec. Do not update the worktree's local base branch.
Read every canonical capability spec from origin/<base> with git show "origin/${BASE_BRANCH}:openspec/specs/<capability>/spec.md"; never use the worktree copy as
the merge baseline. Use that fetched remote snapshot for both the already-synced check and
any merge.
Before editing, compare each affected delta requirement with its matching remote
requirement, normalizing only trailing whitespace (rstrip). If every affected requirement
is already reflected in the remote spec, report already synced and stop with no edits,
commits, or new canonical spec files. For removed or renamed requirements, treat the
operation as already reflected only when the removed name is absent (and, for a rename,
the target requirement is present with matching content). If any requirement is missing,
different, or cannot be matched, continue with the normal intelligent merge using the
remote spec content as its starting point; do not infer convergence from commit ancestry.
For each delta spec, apply changes to main specs
For each repo-local capability delta spec path returned by the CLI:
a. Read the delta spec to understand the intended changes
b. Read the remote main spec at origin/<base>:openspec/specs/<capability>/spec.md
(it may not exist yet). Base all edits on this content, not the worktree's local copy.
c. Apply changes intelligently:
ADDED Requirements:
MODIFIED Requirements:
REMOVED Requirements:
RENAMED Requirements:
d. Create new main spec if capability doesn't exist at origin/<base>:
openspec/specs/<capability>/spec.md# <capability> Specification (using the
capability's directory name) followed by a blank line — a main spec is not a
delta and openspec validate requires this line## Requirements header — not the delta's ## ADDED Requirements
header, which is delta-only syntax and fails openspec validate on a main
spec — followed by the ADDED requirements verbatimShow summary
After applying all changes, summarize:
Delta Spec Format Reference
## ADDED Requirements
### Requirement: New Feature
The system SHALL do something new.
#### Scenario: Basic case
- **WHEN** user does X
- **THEN** system does Y
## MODIFIED Requirements
### Requirement: Existing Feature
#### Scenario: New scenario to add
- **WHEN** user does A
- **THEN** system does B
## REMOVED Requirements
### Requirement: Deprecated Feature
## RENAMED Requirements
- FROM: `### Requirement: Old Name`
- TO: `### Requirement: New Name`Key Principle: Intelligent Merging
Unlike programmatic merging, you can apply partial updates:
Output On Success
## Specs Synced: <change-name>
Updated main specs:
**<capability-1>**:
- Added requirement: "New Feature"
- Modified requirement: "Existing Feature" (added 1 scenario)
**<capability-2>**:
- Created new spec file
- Added requirement: "Another Feature"
Main specs are now updated. The change remains active - archive when implementation is complete.Guardrails
openspec validate <capability> --json
(or --all for the whole batch) and fix any reported issues before summarizing —
a spec missing its title line or still carrying a delta-only ## ADDED Requirements
header fails validationbehindthedash/worktrail
7b4ae30
openspecopenspec storeopenspec store listopenspec listopenspec statusopenspec newopenspec new changeopenspec instructionsopenspec showopenspec validateopenspec archiveopenspec doctoropenspec contextgitgit fetchgit rev-parsegit showechoBashAskUserQuestionIf you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.