一键导入
openspec-apply-change
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Archive a completed change in the experimental workflow. Use when the user wants to finalize and archive a completed change after implementation is complete.
Bootstrap OPSX architecture map from existing codebase using a structured five-phase workflow (init → scan → map → review → promote).
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.
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.
Manage version sync, release commits, tags, pushes, and post-release verification for the cc-switch fork. Use when the user asks to bump or align versions, cut a new release, create or push a tag, verify GitHub Actions or Releases, or troubleshoot why a build artifact did not appear in the release for this repository.
| name | openspec-apply-change |
| description | Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks. |
| license | MIT |
| compatibility | Requires openspec CLI. |
| metadata | {"author":"openspec","version":"1.0","generatedBy":"1.2.0-cpyu.9"} |
Implement tasks from an OpenSpec change.
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 use the AskUserQuestion tool to let the user selectAlways announce: "Using change: " and how to override (e.g., /opsx:apply <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")Get apply instructions
openspec instructions apply --change "<name>" --json
This returns:
Handle states:
state: "blocked" (missing artifacts): show message, suggest using openspec-continue-changestate: "needs_verify": skip back to Phase 1 and run canonical verificationstate: "needs_seal": skip implementation and continue with Phase 2/3state: "all_done": congratulate, suggest archiveRead context files
Before reading other context files, check whether openspec/project.opsx.yaml exists.
If it exists, read it first for domains → capabilities structure
Check openspec/project.opsx.code-map.yaml for code location references
Check openspec/specs/ for behavior documentation
Treat it as navigation context, not as a replacement for change artifacts
Read the files listed in contextFiles from the apply instructions output.
The files depend on the schema being used:
path.join(changeDir, '.verify-result.json') and check whether the previous verify result exists.verify-result.json defensively: newer results may include an optimization object in addition to result, issues, and verificationContextresult === 'FAIL_NEEDS_REMEDIATION':
issues arrayoptimization.status is DEGRADED or ABORTED_UNSAFE, treat it as advisory context only; do NOT let it override the canonical Phase 1 remediation signaltasks.md contains a ## Remediation section:
[code_fix] or [artifact_fix]Document Language Contract:
openspec/config.yaml as the compact source of truth, but consume its compiled prompt projection rather than reinterpreting raw keys ad hocdocLanguage, apply it only to natural-language prose you write in the artifact bodydocLanguage projection is present, keep the default writing behavior for proseShow current progress
Display:
.verify-result.json reports FAIL_NEEDS_REMEDIATION[code_fix] and [artifact_fix]Phase 0: Implement tasks (loop until done or blocked)
For each pending task:
[code_fix] remediation items, update code/tests until the missing behavior is implemented[artifact_fix] remediation items, update the affected spec/design/tasks artifact instead of forcing code changes- [ ] → - [x]## Remediation sectionPause if:
Phase 1: Run canonical verification
After all implementation tasks and remediation items are complete:
.verify-result.json when presentopenspec-reviewer skill, which loads the full reviewer contract (role, constraints, 6-step verification protocol, severity thresholds, three-dimension coverage, structured output schema)FAIL_NEEDS_REMEDIATION, write back only CRITICAL issues to tasks.md, add typed ## Remediation entries, and return to Phase 0PASS or PASS_WITH_WARNINGS, persist Phase 1:
openspec verify phase1 "<change-name>" --input '<json>' --json
Verify CLI JSON Schema Reference:
| CLI call | --input JSON |
|---|---|
openspec verify phase1 "<change-name>" --input '<json>' --json | {"result":"PASS","issues":[],"evidenceFiles":["..."],"executionMode":"..."} |
openspec verify phase2 "<change-name>" --type=optimization --input '<json>' --json | {"status":"NO_OPTIMIZATION_NEEDED","summary":"..."} (summary is required, must be non-empty) |
openspec verify phase2 "<change-name>" --type=optimization --files "<affected-files>" --input '<json>' --json | {"status":"OPTIMIZATION_PROPOSED","summary":"..."} |
openspec verify phase2 "<change-name>" --type=optimization --input '<json>' --json | {"status":"SKIPPED"} |
openspec verify phase2 "<change-name>" --type=verification --input '<json>' --json | {"result":"PASS","issues":[]} |
openspec verify phase2 "<change-name>" --type=verification --input '<json>' --json | {"result":"FAIL_NEEDS_REMEDIATION","issues":[...],"behaviorRetryCounter":N} |
Phase 2: Optimize under checkpoint protection
Role constraint: The master agent is an evidence collector and patch applicator in Phase 2. It MUST NOT substitute its own judgment for the optimizer subagent's decision on whether optimization is needed. Always spawn the optimizer subagent as the first action in Phase 2.
--skip-optimization or optimization.enabled: false; record SKIPPED through openspec verify phase2optimization.optRetries from openspec/config.yaml; default to 2git stash push -u -m "apply-opt-checkpoint-r0"optRetries budget, whether it passes or failsopenspec-optimizer skill (loads full optimizer contract: role, constraints, optimization principles, Search/Replace format, failed directions protocol). Proposes Search/Replace blocks only; it MUST NOT edit filesopenspec verify phase2 "<change-name>" --type=optimization --files "<affected-files>" --input '<json>' to record OPTIMIZATION_PROPOSED with pre-patch file hashes (disk MUST still be in pre-patch state at this point)verification PASS, and continue until no opportunities remain or optRetries is exhaustedgit reset --hard HEAD, git clean -fd, then git stash apply stash@{0}; record the failed direction in .verify-result.jsonapply-opt-checkpoint-* stash entries only after the final safe workspace state is confirmedSimple Change Fast Path:
NO_OPTIMIZATION_NEEDED with the optimizer's conclusion as the summary field:
openspec verify phase2 "<change-name>" --type=optimization --input '{"status":"NO_OPTIMIZATION_NEEDED","summary":"<optimizer conclusion>"}' --json
--skip-optimization flag or optimization.enabled: false in configVerify CLI Error Recovery Guide:
Invalid JSON input: re-check that --input is a JSON string, not a file path; issues must be an array and evidenceFiles must be an array of stringsstatus must be NO_OPTIMIZATION_NEEDED, OPTIMIZATION_PROPOSED, ABORTED_UNSAFE, or SKIPPED: fix the --input.status value and confirm whether optimization.status already has affectedFileHashesresult must be PASS, PASS_WITH_WARNINGS, or FAIL_NEEDS_REMEDIATION: fix the --input.result value and keep issues as an array when provided尚未提交优化结果,请先调用 phase2 --type=optimization: call phase2 --type=optimization before retrying verificationFILES_REQUIRED: add --files "<affected-files>" with the space-separated list of files the optimizer subagent declared as affected, then retry the same commandVerify State Machine:
Phase 1 PASS / PASS_WITH_WARNINGS
|
v
PENDING_VERIFICATION
|-- no affectedFileHashes --> Phase 2 optimization analysis
| |-- NO_OPTIMIZATION_NEEDED --> NOT_NEEDED
| |-- SKIPPED / optimization.enabled=false --> SKIPPED
|-- affectedFileHashes ------> PENDING_VERIFICATION (optimization proposed)
|-- verification PASS --> IMPROVED
|-- verification FAIL_NEEDS_REMEDIATION --> retry or DEGRADED
|-- retries exhausted --> DEGRADED
Archive gate accepts: SKIPPED | NOT_NEEDED | IMPROVED | DEGRADED
Archive gate rejects: PENDING_VERIFICATION | ABORTED_UNSAFE
Phase 3: Seal final result
Run:
openspec verify seal "<change-name>" --json
If seal passes, report apply as complete with verified and optimized status. If seal fails, preserve diagnostics and pause for remediation.
On completion or pause, show status
Display:
Output During Implementation
## Implementing: <change-name> (schema: <schema-name>)
Working on task 3/7: <task description>
[...implementation happening...]
✓ Task complete
Working on task 4/7: <task description>
[...implementation happening...]
✓ Task complete
Output On Completion
## Implementation Complete
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 7/7 tasks complete ✓
### Completed This Session
- [x] Task 1
- [x] Task 2
...
All tasks complete and sealed. Ready to archive this change.
Output On Pause (Issue Encountered)
## Implementation Paused
**Change:** <change-name>
**Schema:** <schema-name>
**Progress:** 4/7 tasks complete
### Issue Encountered
<description of the issue>
**Options:**
1. <option 1>
2. <option 2>
3. Other approach
What would you like to do?
Guardrails
Fluid Workflow Integration
This skill supports the "actions on a change" model: