openspec-snack
Quick code-first sync: generate or update proposal + specs + simplified design from git diff when the code is already written. Use after iterative coding to back-fill specs and OPSX delta without redoing propose→apply. Does not generate tasks.md.
- License 许可
- MIT
- 所属仓库
- cp-yu/edera
- 最近更新
- 2026-06-23
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- openspec-snack
- license
- MIT
- metadata
- { "author": "openspec", "version": "1.0", "generatedBy": "1.4.1-cpyu.1" }
- description
- Quick code-first sync: generate or update proposal + specs + simplified design from git diff when the code is already written. Use after iterative coding to back-fill specs and OPSX delta without redoing propose→apply. Does not generate tasks.md.
- compatibility
- Requires openspec CLI.
03 SKILL.md 正文
Synchronize specs and OPSX from already-written code (code-first, reverse of propose/apply).
Input
- Optional
<change-name>(kebab-case). - If omitted, run
openspec list --jsonand reuse the single active change; if multiple or none, ask which change name to target.
Flow
- Resolve change name. If
openspec/changes/<name>/does not exist, runopenspec new change "<name>"; otherwise update in place (do not recreate proposal). - Load shared OPSX context before generating artifacts.
Before reading other context files, check whether
openspec/project.opsx.yamlexists.
- If it exists, read it first for domains → capabilities structure
- Read the
project:block for project intent and scope - Treat it as navigation context, not as a replacement for change artifacts
- Analyze the code change with git diff.
- Run
git diff --name-only(andgit diff --cached --name-onlywhen needed) to list modified files. - Run
git diffto inspect symbol-level changes (new/deleted exports, modified signatures). - Exclude non-code files (
.md,.json,.yaml, lock files) from spec inference.
- Run
- Reverse-map files to capabilities via code-map.
- Read
openspec/project.opsx.code-map.yamland map each modified path to its capability/domain node IDs. - Files without a code-map entry are [REVIEW NEEDED] candidates for new capabilities.
- Read
- Use CLI-backed OPSX navigation after code-map reverse lookup.
After reading shared
project.opsx.yamlcontext, use OpenSpec CLI query surfaces for node details.
- Run
openspec list --specs --jsonto get specs and theircapabilitiesstring arrays; specs without frontmatter returncapabilities: []. - For known or affected OPSX node IDs, run
openspec opsx query <node-id...> --jsonto get node details, relations and code-map refs in one batch; add--depth 2when broader related context is needed. - Treat CLI output as navigation context, not as a replacement for change artifacts.
- Determine the capability list first, then generate
proposal.md.- Run
openspec instructions proposal --change "<name>" --json. - Use the returned
template,instruction,outputPath, andconfigProjection; do not invent non-template sections. - Determine the
## Capabilitieslist before specs generation and reuse the same list as specs input. - Prefer code-map reverse lookup; files without code-map coverage may use git diff inference but MUST be marked
[REVIEW NEEDED]. - Preserve the template headings including
## Why,## What Changes,## Capabilities, and## Impact.
- Run
- Generate delta specs in
specs/<capability>/spec.mdfrom the artifact instruction.- Run
openspec instructions specs --change "<name>" --json. - Use the returned
template,instruction,outputPath, andconfigProjection; do not invent non-template sections. - Follow the returned
instructionfor ADDED/MODIFIED selection, spec directory naming, and MODIFIED requirement title matching. - Reuse an existing
openspec/specs/<capability>/directory when the instruction says it applies; otherwise use the proposal capability name. - New concerns use
## ADDED Requirements; changed existing behavior uses## MODIFIED Requirementswith the exact existing Requirement title. - Requirement text MUST contain SHALL/MUST language and at least one
#### Scenario:block with WHEN/THEN style. - Mark uncertain inferences with
[REVIEW NEEDED].
- Run
- Generate simplified
design.mdfrom the artifact instruction.- Run
openspec instructions design --change "<name>" --json. - Use the returned
template,instruction,outputPath, andconfigProjection; do not invent non-template sections. - Preserve the full template skeleton: Context, Goals / Non-Goals, Decisions, and Risks / Trade-offs.
- Mark inferred content with
[INFERRED FROM CODE]; mark unresolved risks or trade-offs with[REVIEW NEEDED].
- Run
- OPSX delta heuristic — generate
opsx-delta.yamlONLY when git diff shows new/deleted exports or new files; otherwise skip and log "No architecture-level changes detected. Skipping OPSX delta generation". Generate opsx-delta.yaml:
- Read
openspec instructions opsx-delta --change "<name>" --json - Use the returned
template,instruction, andoutputPathto generateopsx-delta.yaml - Read
proposal.mdto extract the capability list - Read all delta specs in
openspec/changes/<name>/specs/*/spec.md - For existing capability or domain IDs, run
openspec opsx query <node-id...> --jsonfor current-system context in one batch; add--depth 2when related context is needed - Treat
ADDED,MODIFIED, andREMOVEDas YAML object keys, not Markdown headings - Follow a concrete YAML object structure such as:
schema_version: 1 ADDED: capabilities: - id: cap.example.feature type: capability intent: Describe the new capability relations: - from: cap.example.feature type: contains to: dom.example MODIFIED: capabilities: - id: cap.example.existing intent: Updated intent text REMOVED: capabilities: - id: cap.example.legacy - Delta nodes contain only id, type, intent, status — no code_refs or spec_refs
- Keep this agent-driven: capture merge intent in the YAML, not in programmatic code
- Do NOT generate
tasks.md(code is already implemented). - Run
openspec validate "<name>" --type change --jsonafter all generated artifacts are written.
- If validation returns ERROR or WARNING, run one repair pass using the relevant artifact
instructionrules, then runopenspec validate "<name>" --type change --jsononce more. - Treat the second validation result as final evidence.
- Output validate result: if passed, indicate self-check passed; if ERROR/WARNING remain, list each and advise user review.
- Finish with the output hints below, including the validate result.
Output Hints
After artifacts are generated, output:
Fast path (skip verify):
• Continue development: openspec sync "<change-name>" --no-verify
• Fast archive: openspec archive "<change-name>" --no-verify
Correction path: ⚠️ Generated specs are based on code inference. Review items marked [REVIEW NEEDED]
- Correction branch 1: review change → manually edit specs → sync → archive
- Correction branch 2: review change → modify code → run
/opsx-snackagain → continue iterating
Artifact Contract
Document Language Contract:
- Treat
openspec/config.yamlas the compact source of truth, but consume its compiled prompt projection rather than reinterpreting raw keys ad hoc - If the compiled projection includes
proseLanguage, apply it to natural-language prose you write or revise in the artifact body - Natural-language prose includes task titles, check names, Requirement titles, Scenario titles, bullet descriptions, Expect/Evidence descriptions, rationale, goals, risks, and summaries
- Follow the existing template structure exactly; do not invent a different layout because the prose language changes
- Keep template headings, normative keywords, BDD keywords, IDs, schema keys, relation types, file paths, commands, and code identifiers in their canonical form
- Preserve exact existing Requirement titles required for MODIFIED matching
- English project terminology may remain embedded in prose, but ordinary English sentences and titles still follow
proseLanguage - If no
proseLanguageprojection is present, keep the default writing behavior for prose
Keep generated specs coarse and behavior-focused; preserve template headings, canonical IDs, schema keys, BDD keywords, paths, commands, and code identifiers.
04 同仓库更多 Skills
openspec-reviewer
Internal clean-context Phase 1 verification reviewer. Judges implementation completeness, correctness, coherence, and cleanliness by reading files from changeName, changeDir, and projectRoot. Never accesses conversation history.
openspec-propose
Propose a new change with all artifacts generated in one step. Use when the user wants to quickly describe what they want to build and get a complete proposal with design, specs, and tasks ready for implementation.
openspec-optimizer
Internal clean-context Phase 2 optimization proposer. Analyzes implementation files and outputs behavior-preserving Search/Replace blocks. Never modifies files directly. Reads failedDirections to avoid repeating broken strategies.
openspec-impact-sweeper
Generate a lightweight OPSX-grounded JSON impact report for one project concept. Use from explore before scope or proposal readiness claims.
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-bootstrap-opsx
Bootstrap OPSX architecture map from existing codebase using a structured five-phase workflow (init → scan → map → review → promote).