AGENT SKILL

openspec-apply-change

Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.

License 许可
MIT
最近更新
2026-11-09
Stars
★ 6
Forks
1

01 前言 Front Matter

name
openspec-apply-change
license
MIT
metadata
{ "author": "openspec", "version": "1.1", "generatedBy": "1.3.0" }
description
Implement tasks from an OpenSpec change. Use when the user wants to start implementing, continue implementation, or work through tasks.
compatibility
Requires openspec CLI.

03 SKILL.md 正文

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

  1. Write apply-session start marker (required, added v1.1)

    Before reading any context files or performing implementation, signal that this apply session is skill-orchestrated. The PreToolUse hook installed per docs/rules/apply-skill-enforcement.rule.md BLOCKS the first Edit/Write on a slice's write_paths unless this marker exists for the current session.

    python .ai-playbook/scripts/openspec_apply_marker.py start --change-id "<name>" --skill-version 1.1
    

    The marker is appended to openspec/changes/<name>/.apply_log.jsonl (one JSONL record per session start; committed to git for audit). If the helper script is missing (consumer pre-v0.14.0 of ai-playbook), the hook is also missing — proceed; older consumers see no enforcement. Inform the user that their playbook bump is overdue.

    See: docs/rules/apply-skill-enforcement.rule.md §1 (marker contract) and §3 (break-glass via AIPLAYBOOK_APPLY_ENFORCE_OVERRIDE env).

  2. 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 --json to get available changes and use the AskUserQuestion tool to let the user select

    Always announce: "Using change: <name>" and how to override (e.g., /opsx:apply <other>).

  3. 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")
    • Which artifact contains the tasks (typically "tasks" for spec-driven, check status for others)
  4. Get apply instructions

    openspec instructions apply --change "<name>" --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: "all_done": congratulate, suggest archive
    • Otherwise: proceed to implementation
  5. Read context files

    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

4b. Preflight re-grep cited identifiers (added v0.11.0)

Per release-management.md §6.5 (pre-flight rebase) the worktree base is fresh, but proposal.md may have been written days earlier. Identifiers cited in the proposal (class names, function names, file paths, migration slot numbers, fact-kind enum values, ADR numbers) may have changed on main since the proposal landed. Apply silently against stale citations produces silent divergence.

Before starting implementation, re-grep every identifier the proposal/design/tasks cites:

  1. Walk proposal.md + design.md + tasks.md and extract:

    • Quoted file paths (apps/api/src/.../foo.py).
    • Backticked class / function names (`IBClient`, `place_order`).
    • Migration slot numbers (0007_*, 0010_*).
    • ADR numbers (ADR-021).
    • Enum values mentioned in citations.
  2. For each, run git grep -n "<identifier>" (or Grep tool) on main.

  3. If any cited identifier returns 0 hits, surface as a divergence warning:

    ⚠ Citation drift detected
    proposal.md cites `FactKindEnum.MOMENTUM_SCORE` but no occurrence found on main.
    Likely renamed or removed in a parallel slice merged after this proposal landed.
    
    Options:
    1. Re-read the current main code to find the new name; update tasks.md citations.
    2. Re-open Gate D for design refresh (recommended for ≥3 drifted citations).
    3. Override with --skip-preflight-grep (logs deviation in retro carry-forward).
    
  4. If 1-2 identifiers drifted, show the diff and let the user decide (small drift is normal across week-old proposals).

  5. If ≥3 identifiers drifted OR a critical surface (migration slot, FK, public API) drifted, refuse to proceed without explicit --skip-preflight-grep flag.

This catches the failure mode (proposals written before parallel slices renamed cited classes) — without preflight grep, the worker AI would silently apply against drifted state and either fail at typecheck (best case) or ship broken code (worst case).

  1. Show current progress

    Display:

    • Schema being used
    • Progress: "N/M tasks complete"
    • Remaining tasks overview
    • Dynamic instruction from CLI
  2. Implement tasks (loop until done or blocked)

    For each pending task:

    • Show which task is being worked on
    • Make the code changes required
    • Keep changes minimal and focused
    • Mark task complete in the tasks file: - [ ] → - [x]
    • 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
  3. On completion or pause, show status

    Display:

    • Tasks completed this session
    • Overall progress: "N/M tasks complete"
    • If all done: suggest archive
    • If paused: explain why and wait for guidance

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! 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

  • 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

04 同仓库更多 Skills

Wizarck
Wizarck/ai-playbook

sweep

Use when the user wants to find code that has quietly stopped being used — types /sweep, asks for a "dead code sweep", "repo entropy", "what can we delete", "orphan files", "unused code", or asks to review a sweep ledger. Adjudicates candidates a deterministic scanner already produced; it never deletes anything and never re-derives findings from raw source. Pairs with ponytail, which gates what gets written rather than what rots.

★ 6
Wizarck
Wizarck/ai-playbook

ponytail

Use when the user wants the laziest solution that actually works — types /ponytail, says "be lazy", "lazy mode", "simplest solution", "minimal solution", "yagni", "do less", or "shortest path", or complains about over-engineering, bloat, boilerplate, or unnecessary dependencies. Supports intensity levels lite, full, ultra (default). Pairs with caveman, which compresses prose, not code.

★ 6
Wizarck
Wizarck/ai-playbook

ponytail-review

Use when the user wants a code review focused exclusively on over-engineering — says "review for over-engineering", "what can we delete", "is this over-engineered", "simplify review", or invokes /ponytail-review. Complements correctness/security review; this one only hunts complexity in the current diff. Gated by the ponytail review_ponytail component.

代码审查
★ 6
Wizarck
Wizarck/ai-playbook

ponytail-debt

Use when the user wants to harvest every `ponytail:` comment in the codebase into a tracked debt ledger — says "ponytail debt", "/ponytail-debt", "what did ponytail defer", "list the shortcuts", "ponytail ledger", or "what did we mark to do later". One-shot report, changes nothing. Gated by the ponytail debt_ponytail component.

★ 6
Wizarck
Wizarck/ai-playbook

ponytail-audit

Use when the user wants a whole-repo audit for over-engineering — says "audit this codebase", "audit for over-engineering", "what can I delete from this repo", "find bloat", or invokes /ponytail-audit. Like ponytail-review but scans the entire tree, not a diff. One-shot report, applies no fixes. Gated by the ponytail audit_ponytail component.

★ 6
Wizarck
Wizarck/ai-playbook

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.

★ 6