ワンクリックで
spectra-apply-plus
Implement Spectra tasks with a sub-agent quality gate after completion
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Implement Spectra tasks with a sub-agent quality gate after completion
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Implement Spectra tasks with a sub-agent quality gate after completion
Create a Spectra change proposal with sub-agent quality gates
Create a Spectra change proposal with sub-agent quality gates
| name | spectra-apply-plus |
| description | Implement Spectra tasks with a sub-agent quality gate after completion |
| license | MIT |
| compatibility | Requires spectra CLI. |
| metadata | {"author":"spectra","version":"1.0","generatedBy":"Spectra"} |
Implement tasks from a Spectra change.
Input: Optionally specify a change name (e.g., /spectra-apply add-auth). If omitted, check if it can be inferred from conversation context. If vague or ambiguous you MUST prompt for available changes.
Task tracking is file-based only. The tasks file's markdown checkboxes (- [ ] / - [x]) are the single source of truth for progress. Do NOT use any external task management system, built-in task tracker, or todo tool. When a task is done, edit the checkbox in the tasks file — that is the only way to record progress.
Prerequisites: This skill requires the spectra CLI. If any spectra command fails with "command not found" or similar, report the error and STOP.
Steps
Select the change
If a name is provided, use it. Otherwise:
spectra list --json AND spectra list --parked --json to get all available changes (including parked ones). Parked changes should be annotated with "(parked)" in the selection list. Use the AskUserQuestion tool to let the user selectAlways announce: "Using change: " and how to override (e.g., /spectra-apply <other>).
Check status to understand the schema
spectra status --change "<name>" --json
If the command fails: show the error and STOP.
If the command succeeds, check whether the change is parked (status can succeed even for parked changes):
spectra list --parked --json
Look for the change name in the parked array of the JSON output.
If the change IS in the parked list (it's parked): Inform the user that this change is currently parked(暫存). Use the AskUserQuestion tool to ask whether to continue. Two options:
If the user chooses to continue:
spectra unpark "<name>"
Then mark it as in-progress:
spectra in-progress add "<name>"
This is a silent operation — do not show the output to the user.
Then re-run spectra status --change "<name>" --json and continue normally.
If there is no AskUserQuestion tool available (non-Claude-Code environment):
Inform the user that this change is currently parked(暫存)and ask via plain text whether to unpark and continue, or cancel.
Wait for the user's response. If the user confirms, run spectra unpark "<name>", then set spectra in-progress add "<name>", and continue normally.
If the change is NOT in the parked list: mark it as in-progress and proceed normally.
spectra in-progress add "<name>"
This is a silent operation — do not show the output to the user.
Parse the JSON to understand:
schemaName: The workflow being used (e.g., "spec-driven")Get apply instructions
spectra instructions apply --change "<name>" --json
This returns:
Handle states:
state: "blocked" (missing artifacts): show message, suggest using /spectra-propose to create the change artifacts firststate: "all_done": congratulate, suggest archive3b. Preflight check
If the apply instructions JSON includes a preflight field, act on its status:
"clean": silently continue — no output needed.
"warnings": display a brief summary, then continue automatically:
⚠ Preflight warnings:
- Drifted files (modified after change was created): <list paths>
- Change is <N> days old
Continuing...
Only show the lines that are relevant (skip drifted if none, skip staleness if not stale).
"critical": display missing files with their source artifact, then use the AskUserQuestion tool to ask the user:
⚠ Preflight: missing files detected
- <path> (referenced in <source artifact>)
- ...
These files are referenced in the change artifacts but no longer exist on disk.
Options: "Continue anyway" / "Stop" If the user chooses "Stop", end the workflow.
If there is no AskUserQuestion tool available: Display the same information as plain text and ask whether to continue or stop. Wait for the user's response.
If the preflight field is absent (blocked or all_done states), skip this step.
3c. Artifact quality check
Run spectra analyze <change-name> --json to check cross-artifact consistency (Coverage, Consistency, Ambiguity, Gaps).
Zero findings: silently continue.
Warning/Suggestion only: display a one-line summary (e.g., "⚠ Artifact analysis: 2 warnings found") and continue automatically.
Critical findings: display each Critical finding (summary + location + recommendation), then use the AskUserQuestion tool:
If there is no AskUserQuestion tool available, present options as plain text and wait for the user's response.
3d. Drift dormancy check (passive trigger for stale changes)
When the change has been dormant for more than 5 days AND the change directory has had zero commits in the past 3 days, surface a drift report before tasks begin — the change is likely out-of-sync with the current codebase.
Detect dormancy from .openspec.yaml created and git log -1 --format=%at -- docs/specs/changes/<name>/:
spectra drift <change-name>, display the report, then use the AskUserQuestion tool:
/spectra-ingest <change-name> to update artifacts, then resumeThe trigger is guidance only — it MUST NOT block apply from proceeding when the user chooses to continue. Hard-blocking on dormancy would punish legitimate "I came back after a long weekend" cases.
(Threshold reasoning: AI-assisted commits are daily-cadence. ≥5 days dormant + ≥3 days no commit ≈ genuine stagnation, not normal pacing.)
If there is no AskUserQuestion tool available, present options as plain text and wait for the user's response.
Read context files
Read the files listed in contextFiles from the apply instructions output.
The files depend on the schema being used:
Check project preferences
Read .spectra.yaml in the project root.
If tdd: true is set, apply TDD discipline throughout implementation:
spectra instructions --skill tdd, then follow the Red-Green-Refactor cycleIf audit: true is set, apply sharp-edges discipline throughout implementation:
spectra instructions --skill audit, follow the discipline checklist (not the standalone 3-agent workflow)If parallel_tasks: true is set, check whether consecutive pending tasks have [P] markers (format: - [ ] [P] Task description). You SHALL dispatch consecutive [P] tasks as parallel agents. Only fall back to sequential when tasks have a data dependency (one task's output is another's input) or when tasks modify overlapping regions of the same file. Targeting the same file alone is NOT a reason to skip parallel dispatch — if the modified regions are disjoint, dispatch in parallel. If the environment does not support parallel execution, ignore [P] markers and execute tasks sequentially.
Show current progress
Display:
Implement tasks (loop until done or blocked)
Reminder: Track progress by editing checkboxes in the tasks file only. Do not use any built-in task tracker.
For each pending task:
design.md exists and contains an ## Implementation Contract section (or contract content under another heading the design uses), read the part of it that covers this task's scope. The contract names the observable behavior, interface or data shape, failure modes, acceptance criteria, and scope boundaries you must satisfy. Treat the contract as the durable handoff — it is what the task will be measured against, regardless of who started the change.foo.rs", "update bar.svelte") with no behavior, contract, or verification target;##### Example: blocks, use them as concrete test cases:
spectra task done --change "<name>" <task-id>
This command marks the checkbox in tasks.md AND records which files were modified for this task.Parallel task dispatch: When consecutive [P]-marked tasks are found and parallel_tasks: true is configured (see Step 5), dispatch them as parallel agents in a single message. If any [P] task fails, pause and report.
Pause if:
| What You're Thinking | What You Should Do |
|---|---|
| "This task looks done, I'll mark it complete" | Re-read the task description first. Check whether your diff covers every part of it. Incomplete tasks marked done are the #1 source of rework |
| "This task is trivial, I don't need to re-read the design" | Re-read. Context compression loses details. 30s of reading saves 30min of rework |
| "I already know how this works, skip the code search" | Search anyway. Someone may have added a utility since you last looked |
| "The test is obvious, I'll add it after implementation" | If TDD is enabled, test first. If not, still write it before marking done |
| "This is just a small refactor, no test needed" | Small refactors are how regressions sneak in. Write the test |
| "The artifact says X but Y makes more sense" | Pause and suggest updating the artifact. Don't silently deviate |
| "I'll fix this other thing I noticed while I'm here" | Finish current task first. Address the other thing separately |
| "The example values are just illustrations, I'll pick better ones" | Use the spec example values exactly. They were chosen deliberately |
Surgical & Simplicity Discipline
在 step 7 的 task loop 期間,編輯任何來源碼之前必須套用以下兩項紀律。它們補充(而不取代)既有的 Reuse / Quality / Efficiency / No Placeholders / Examples as verification 檢查。
Simplicity First — 寫最少能解決任務的程式碼
tasks.md 任務描述與 design.md Implementation Contract 以外的功能。Surgical Changes — 只動該動的,且只清自己造成的殘骸
implementation-notes.md 以 open-question 條目記錄,交給使用者決定。tasks.md 中的某條任務或 design.md 中的 Implementation Contract 項目。Maintain Balance — Simplicity 不等於程式碼高爾夫
Simplicity First 與 Surgical Changes 的目的是「不寫不必要的東西」,不是「越短越好」。下列反例同樣違反紀律,被 review loop 視為 Critical:
if/else 或 switch 替代。判準:實作完成後重讀 diff,若 future-self 或 reviewer 需要花超過幾秒才能理解某行的意圖,那不是 simpler,是 cleverer。Cleverer 違反紀律。Clarity 永遠優先於 brevity。
若違反上述任一條(無論刻意或非刻意),視同 task 未完成 — 在執行 spectra task done 之前先修正。若是刻意 deviate(例如 contract 與既有程式衝突,需要動到鄰近區塊),依 step 11 Implementation Notes Protocol 寫一筆 deviation 條目,說明原因。
Keep verbatim (do not translate): shell commands, file paths, code identifiers, schema field names (applyRequires, outputPath 等), artifact IDs, capability slugs, and quoted source text. If the user explicitly requests another language later, follow the latest user instruction.
8. Final check
After completing all tasks, re-run:
spectra instructions apply --change "<name>" --json
Confirm state: "all_done". If not, review remaining tasks and complete them.
On completion or pause, show status
Display:
Sub-Agent Review/Rating/Fix Loop
Run this review/rating/fix loop once per change, after the normal workflow has completed its required artifact or task work.
Entry conditions
spectra-propose-plus, start this loop only after proposal, design, specs, and tasks artifacts required for apply are complete.spectra-apply-plus, start this loop only after all implementation tasks are complete and tasks.md 全 [x].Round limit and pass condition
quality_score > 9 and critical_gap == false.decision: aborted, print the unresolved findings, and end the plus workflow.decision: passed, stop the loop, and continue to the normal final validation or completion summary.Fresh sub-agent calls
design.md Implementation Contract, tasks.md task descriptions, and spec.md requirements; implementation-notes.md deviations are justified.##### Example: blocks.location + summary) and applies the confidence filter (see below) before passing the filtered set to the rater.quality_score, critical_gap, and rationale.Reviewer output requirements
severity: one of Critical, Warning, Suggestion (before filtering)confidence: integer 0–100, using the rubric belowlocation: artifact + section, or file path + line rangesummary: one-line description of the issuerecommendation: concrete action to resolvedecision: aborted instead of continuing fixes.Confidence scoring rubric (per finding)
0 — Not confident at all. False positive or pre-existing issue. SHOULD NOT be reported.25 — Somewhat confident. Could be a real issue but the reviewer was unable to verify against artifacts or code.50 — Moderately confident. Verified to be real, but minor / unlikely to hit in practice / outside the changed scope.75 — Highly confident. Verified to be real and will hit in practice. Use this when judgment-based impact assessment supports the finding but no direct artifact citation exists.100 — Certain. Evidence directly confirms the issue, OR the finding cites a specific artifact clause (a SHALL in spec.md, an Implementation Contract item in design.md, a task description line in tasks.md, a non-goal in proposal.md) that the artifact set or implementation provably does not satisfy.100. If a reviewer can name the exact SHALL / contract item / task line being violated, the finding is objectively verifiable and SHALL NOT be downgraded below 100. This invariant guarantees the confidence filter never demotes an artifact violation to Suggestion.Confidence filter (applied by main agent before rater)
confidence < 50. These do not appear in the round file.confidence ∈ [50, 80) to Suggestion regardless of original severity. They appear in the round file under Suggestion for visibility but do NOT count as Critical.confidence ≥ 80 may be classified as Critical or Warning in the final round file.critical_gap is true only when at least one finding survives filtering with severity == Critical AND confidence ≥ 80.Common false positives — do NOT flag The following SHOULD NOT be reported, or if reported MUST be scored ≤ 25:
tasks.md or design.md explicitly required the test, or a spec ##### Example: block is not exercised.design.md, implementation-notes.md, the proposal's Non-Goals section, or ## Alternatives Considered.## What Changes or ## Proposed Solution.Failure handling
decision: aborted and include the failure note in ## Decision.Rater output requirements
quality_score as a number from 0 to 10.critical_gap as true or false.Round file path
openspec/changes/<change>/reviews/.spectra-propose-plus, write openspec/changes/<change>/reviews/propose-r<N>.md.spectra-apply-plus, write openspec/changes/<change>/reviews/apply-r<N>.md.<N> as the 1-based round number.openspec/changes/<change>/reviews/<skill>-r<N>.md.Round file schema
# Propose Plus Review — Round <N> or # Apply Plus Review — Round <N>## Reviewer Findings — list aggregated, post-filter findings grouped under Critical / Warning / Suggestion. Each entry MUST include severity, confidence, location, summary, recommendation, and which reviewer raised it (A or B; A+B if both raised it independently).## Rating — quality_score, critical_gap, rationale paragraph.## Fix Actions## Decision — value MUST be exactly one of passed, next_round, or aborted.Fix actions
next_round, fix the concrete findings before starting the next round.## Fix Actions.None; pass condition met.Round file language
openspec/changes/<change>/reviews/<skill>-r<N>.md) prose content — Reviewer Findings, Rater rationale, Fix Actions descriptions, and the ## Decision explanation — MUST be written in Traditional Chinese.# Propose Plus Review — Round <N>, # Apply Plus Review — Round <N>, ## Reviewer Findings, ## Rating, ## Fix Actions, ## Decision.decision value: one of passed, next_round, aborted.quality_score (number 0–10), critical_gap (true / false), severity, confidence, location, summary, recommendation.spectra-propose-plus and spectra-apply-plus round files because they share this review-loop template.For spectra-apply-plus, ai 的回覆要用中文.
All user-facing AI responses during this workflow MUST be written in Traditional Chinese unless the user explicitly requests another language.
This includes:
This does not require translating:
If the user explicitly requests another language later, follow the latest user instruction.
Keep technical names exact even when the surrounding explanation is Chinese.
Do not mix languages for ordinary prose unless a command, path, symbol, or quoted artifact requires it.
The goal is predictable Chinese-facing interaction for apply-plus while preserving exact technical references.
Artifact modifications during apply-plus
When the apply-plus workflow modifies an artifact — during review-loop fix actions, or after spectra-ingest updates tasks.md / design.md / proposal.md — the updated artifact content MUST follow the same Chinese language rule as propose-plus:
tasks.md, design.md, proposal.md, and other non-spec artifacts under openspec/changes/<change>/: Traditional Chinese.openspec/changes/<change>/specs/**/spec.md and openspec/specs/**/spec.md): always English, regardless of any other language rule. Delta specs are merged into master specs and must use normative SHALL/MUST wording.Keep CLI commands, file paths, code identifiers, schema field names, artifact IDs, capability slugs, and existing quoted source text verbatim. If the user explicitly requests another language later, follow the latest user instruction.
During the apply-plus task loop, maintain a lightweight running log at openspec/changes/<change>/implementation-notes.md that captures only two categories of information:
spec.md, design.md, or tasks.md (because the spec was ambiguous, the codebase reality differs, or a discovered issue forced a different path).Design decisions that match the spec, ordinary tradeoffs, and small judgment calls do NOT belong here — they are already covered by design.md, tasks.md, and the review-loop round files. Keep this log narrow.
File creation rule (eager)
openspec/changes/<change>/implementation-notes.md if it does not already exist.<!-- apply-plus implementation notes | change: <change-name> | initialized: <YYYY-MM-DD HH:MM> | no entries below means no deviations or open questions were recorded -->
Entry format
Each entry MUST be appended (never rewriting earlier entries) using this exact structure:
## <YYYY-MM-DD HH:MM> — <short title>
- 類別:deviation | open-question
- 任務:<task-id or "n/a">
- 內容:<one-paragraph description of what happened or what needs answering>
- 原因:<why this path was chosen, or why the user needs to weigh in>
Prose (內容, 原因, title) is written in Traditional Chinese, matching the apply-plus response-language rule. CLI commands, file paths, code identifiers, capability slugs, and quoted source text remain verbatim in English.
When to write an entry
design.md Implementation Contract, tasks.md description, or relevant spec.md requirements — write a deviation entry before marking the task done.open-question entry naming the assumption.When NOT to write an entry
design.md or the round-<N> review files — no entry.Sub-agent reviewer requirement
The review-loop reviewer (Section 10) MUST, at the start of each round, read openspec/changes/<change>/implementation-notes.md.
deviation or open-question entry. No finding raised by virtue of emptiness alone.deviation entries are evaluated for whether the divergence is justified. An unjustified deviation is a Critical finding; a justified-but-undocumented-in-design.md deviation is at minimum a Warning recommending the divergence be back-filled into design.md during Fix Actions.open-question entries are surfaced as Warning findings with a recommended ## Fix Actions step naming how to obtain user confirmation before the round can pass.The rater (Section 10) does not read this file directly; it reads only the reviewer findings, which already incorporate the notes context.
Idempotence and ingest interaction
spectra-ingest may modify tasks.md / design.md / proposal.md. After ingest resolves an open question, the agent MUST append a follow-up entry noting the resolution (do not delete or rewrite the original open-question entry — the historical record is the point).open-question entry (i.e. one followed by a resolution entry) as no longer blocking.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! You can archive this change with `/spectra-archive`.
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: