Install
$ agentstack add skill-cp-yu-cc-switch-web-openspec-apply-change ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
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:
- Infer from conversation context if the user mentioned a change
- Auto-select if only one active change exists
- If ambiguous, run
openspec list --jsonto get available changes and use the AskUserQuestion tool to let the user select
Always announce: "Using change: " and how to override (e.g., /opsx:apply ).
- Check status to understand the schema
``bash openspec status --change "" --json `` Parse the JSON to understand:
schemaName: The workflow being used (e.g., "spec-driven")- Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
- Get apply instructions
``bash openspec instructions apply --change "" --json ``
This returns:
- Context file paths (varies by schema - could be proposal/specs/design/tasks or spec/tests/implementation/docs)
- Progress (total, complete, remaining)
- Task list with status
- Dynamic instruction based on current state
Handle states:
- If
state: "blocked"(missing artifacts): show message, suggest using openspec-continue-change - If
state: "needs_verify": skip back to Phase 1 and run canonical verification - If
state: "needs_seal": skip implementation and continue with Phase 2/3 - If
state: "all_done": congratulate, suggest archive - Otherwise: proceed to implementation
- Read 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.yamlfor 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:
- spec-driven: proposal, specs, design, tasks
- Other schemas: follow the contextFiles from CLI output
- Build
path.join(changeDir, '.verify-result.json')and check whether the previous verify result exists - Read
.verify-result.jsondefensively: newer results may include anoptimizationobject in addition toresult,issues, andverificationContext - If the file exists and
result === 'FAIL_NEEDS_REMEDIATION': - Read the persisted
issuesarray - Keep only CRITICAL issues as mandatory remediation context
- If
optimization.statusisDEGRADEDorABORTED_UNSAFE, treat it as advisory context only; do NOT let it override the canonical Phase 1 remediation signal - If
tasks.mdcontains a## Remediationsection: - Parse each checkbox item
- Track whether the item is tagged
[code_fix]or[artifact_fix] - Treat unchecked remediation items as priority work
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
docLanguage, apply it only to natural-language prose you write in the artifact body - Follow the existing template structure exactly; do not invent a different layout because the prose language changes
- Keep template headings, IDs, schema keys, relation types, BDD keywords, file paths, commands, and code identifiers in their canonical form
- If no
docLanguageprojection is present, keep the default writing behavior for prose
- Show current progress
Display:
- Schema being used
- Progress: "N/M tasks complete"
- Remaining tasks overview
- Summary of prior CRITICAL verify issues when
.verify-result.jsonreportsFAIL_NEEDS_REMEDIATION - Summary of open remediation items grouped by
[code_fix]and[artifact_fix] - Dynamic instruction from CLI
- Phase 0: Implement tasks (loop until done or blocked)
For each pending task:
- Show which task is being worked on
- If the task was unmarked by verify, inject the matching CRITICAL issue and remediation item into the working context before editing files
- Prioritize unchecked remediation entries before unrelated polish work
- Make the code changes required
- For
[code_fix]remediation items, update code/tests until the missing behavior is implemented - For
[artifact_fix]remediation items, update the affected spec/design/tasks artifact instead of forcing code changes - Keep changes minimal and focused
- Mark task complete in the tasks file:
- [ ]→- [x] - Mark resolved remediation items complete in the
## Remediationsection - Continue to next task
Pause if:
- Task is unclear → ask for clarification
- Implementation reveals a design issue → suggest updating artifacts
- Error or blocker encountered → report and wait for guidance
- User interrupts
- Phase 1: Run canonical verification
After all implementation tasks and remediation items are complete:
- Spawn a clean-context reviewer subagent with change artifacts, git evidence, final file contents, and prior
.verify-result.jsonwhen present - Instruct the subagent to invoke the
openspec-reviewerskill, which loads the full reviewer contract (role, constraints, 6-step verification protocol, severity thresholds, three-dimension coverage, structured output schema) - Keep completeness, correctness, and coherence judgment inside the reviewer subagent
- If the reviewer returns
FAIL_NEEDS_REMEDIATION, write back only CRITICAL issues totasks.md, add typed## Remediationentries, and return to Phase 0 - If the reviewer returns
PASSorPASS_WITH_WARNINGS, persist Phase 1:
``bash openspec verify phase1 "" --input '' --json ``
Verify CLI JSON Schema Reference:
| CLI call | --input JSON | | --- | --- | | openspec verify phase1 "" --input '' --json | {"result":"PASS","issues":[],"evidenceFiles":["..."],"executionMode":"..."} | | openspec verify phase2 "" --type=optimization --input '' --json | {"status":"NO_OPTIMIZATION_NEEDED","summary":"..."} (summary is required, must be non-empty) | | openspec verify phase2 "" --type=optimization --files "" --input '' --json | {"status":"OPTIMIZATION_PROPOSED","summary":"..."} | | openspec verify phase2 "" --type=optimization --input '' --json | {"status":"SKIPPED"} | | openspec verify phase2 "" --type=verification --input '' --json | {"result":"PASS","issues":[]} | | openspec verify phase2 "" --type=verification --input '' --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 Phase 2 only when the user requested
--skip-optimizationoroptimization.enabled: false; recordSKIPPEDthroughopenspec verify phase2 - Read
optimization.optRetriesfromopenspec/config.yaml; default to2 - Before the first optimization attempt, create a checkpoint:
git stash push -u -m "apply-opt-checkpoint-r0" - Each complete proposal + patch + reviewer re-verify loop consumes one
optRetriesbudget, whether it passes or fails - Format or Search/Replace matching problems are handled by the main agent and do not consume retry budget
- Optimizer subagent: spawn and instruct to invoke the
openspec-optimizerskill (loads full optimizer contract: role, constraints, optimization principles, Search/Replace format, failed directions protocol). Proposes Search/Replace blocks only; it MUST NOT edit files - TIMING CONSTRAINT — hashFiles() samples disk state; the following order is mandatory:
- Main agent calls
openspec verify phase2 "" --type=optimization --files "" --input ''to recordOPTIMIZATION_PROPOSEDwith pre-patch file hashes (disk MUST still be in pre-patch state at this point) - Main agent applies Search/Replace blocks atomically (disk transitions to post-patch state)
- Main agent spawns the reviewer subagent for speculative Phase 1 re-verification
- On speculative PASS, record
verification PASS, and continue until no opportunities remain oroptRetriesis exhausted - On speculative FAIL, restore the latest checkpoint with
git reset --hard HEAD,git clean -fd, thengit stash apply stash@{0}; record the failed direction in.verify-result.json - When all attempts finish, consume all
apply-opt-checkpoint-*stash entries only after the final safe workspace state is confirmed
Simple Change Fast Path:
- You MUST spawn the optimizer subagent at least once for every change, including pure deletions, renames, or parameter removals
- The optimizer subagent (not the master agent) decides whether optimization opportunities exist
- If the optimizer subagent returns "No optimization opportunities found", record
NO_OPTIMIZATION_NEEDEDwith the optimizer's conclusion as thesummaryfield:
``bash openspec verify phase2 "" --type=optimization --input '{"status":"NO_OPTIMIZATION_NEEDED","summary":""}' --json ``
- The master agent MUST NOT self-determine that no optimization is needed without spawning the optimizer subagent
- The only conditions that bypass the optimizer subagent are:
--skip-optimizationflag oroptimization.enabled: falsein config
Verify CLI Error Recovery Guide:
- If the CLI says
Invalid JSON input: re-check that--inputis a JSON string, not a file path;issuesmust be an array andevidenceFilesmust be an array of strings - If the CLI says
status must be NO_OPTIMIZATION_NEEDED, OPTIMIZATION_PROPOSED, ABORTED_UNSAFE, or SKIPPED: fix the--input.statusvalue and confirm whetheroptimization.statusalready hasaffectedFileHashes - If the CLI says
result must be PASS, PASS_WITH_WARNINGS, or FAIL_NEEDS_REMEDIATION: fix the--input.resultvalue and keepissuesas an array when provided - If the CLI says
尚未提交优化结果,请先调用 phase2 --type=optimization: callphase2 --type=optimizationbefore retrying verification - If the CLI says
FILES_REQUIRED: add--files ""with the space-separated list of files the optimizer subagent declared as affected, then retry the same command
Verify 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: ``bash openspec verify seal "" --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:
- Tasks completed this session
- Overall progress: "N/M tasks complete"
- If remediation items were resolved, report that Phase 1 must pass before archive
- If all done: suggest archive
- If paused: explain why and wait for guidance
Output During Implementation
## Implementing: (schema: )
Working on task 3/7:
[...implementation happening...]
✓ Task complete
Working on task 4/7:
[...implementation happening...]
✓ Task complete
Output On Completion
## Implementation Complete
**Change:**
**Schema:**
**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:**
**Schema:**
**Progress:** 4/7 tasks complete
### Issue Encountered
**Options:**
1.
2.
3. Other approach
What would you like to do?
Guardrails
- Keep going through tasks until done or blocked
- Always read context files before starting (from the apply instructions output)
- If task is ambiguous, pause and ask before implementing
- If implementation reveals issues, pause and suggest artifact updates
- Keep code changes minimal and scoped to each task
- Update task checkbox immediately after completing each task
- Pause on errors, blockers, or unclear requirements - don't guess
- Use contextFiles from CLI output, don't assume specific file names
Fluid Workflow Integration
This skill supports the "actions on a change" model:
- Can be invoked anytime: Before all artifacts are done (if tasks exist), after partial implementation, interleaved with other actions
- Allows artifact updates: If implementation reveals design issues, suggest updating artifacts - not phase-locked, work fluidly
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: cp-yu
- Source: cp-yu/cc-switch-web
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.