AGENT SKILL

openspec-agent-apply

Delegate OpenSpec implementation tasks from any AI agent harness (AGY, Claude Code, Codex, etc.) to headless OpenCode using the spec-coder primary agent.

License 许可
MIT
最近更新
2026-09-05
Stars
★ 0
Forks
0

01 前言 Front Matter

name
openspec-agent-apply
license
MIT
description
Delegate OpenSpec implementation tasks from any AI agent harness (AGY, Claude Code, Codex, etc.) to headless OpenCode using the spec-coder primary agent.
compatibility
Requires openspec CLI and opencode CLI.

03 SKILL.md 正文

Delegate OpenSpec task implementation to the low-cost headless OpenCode agent (spec-coder).

Input: Optionally specify a change name. If omitted, infer from context or list active changes.

Steps

  1. Select the change

    • If provided, use it. Otherwise run openspec list --json to inspect active changes.
    • Announce: "Using change: <name>".
  2. Get apply instructions

    openspec instructions apply --change "<name>" --json
    

    Inspect total tasks, complete tasks, remaining tasks, and contextFiles.

  3. Delegate Implementation to Headless OpenCode spec-coder Execute headless OpenCode using the spec-coder primary agent profile:

    opencode run --agent spec-coder --auto "Implement pending tasks for OpenSpec change '<name>'. Work through remaining tasks in tasks.md sequentially, perform minimal code modifications, run verification commands, and update checkboxes from - [ ] to - [x]."
    

    ⚡ Agent Model Hierarchy & Fallback Protocol:

    1. Default (OpenCode Go Subsidized): Standard execution via opencode run --agent spec-coder ... (runs opencode-go/deepseek-v4-flash).
    2. Fallback 1 (Direct DeepSeek API Pay-As-You-Go): If OpenCode Go quota or rate limit (429) is hit, re-execute with direct DeepSeek API:
      opencode run --agent spec-coder --model deepseek/deepseek-v4-flash --auto "Implement pending tasks for OpenSpec change '<name>'. Work through remaining tasks in tasks.md sequentially, perform minimal code modifications, run verification commands, and update checkboxes from - [ ] to - [x]."
      
    3. Fallback 2 (Free Zero-Cost Tier): If direct DeepSeek API limits are reached, re-execute with free model:
      opencode run --agent spec-coder --model opencode/deepseek-v4-flash-free --auto "Implement pending tasks for OpenSpec change '<name>'. Work through remaining tasks in tasks.md sequentially, perform minimal code modifications, run verification commands, and update checkboxes from - [ ] to - [x]."
      

    💡 Developer Tip: Agent Monitoring & Debugging To inspect live agent progress, tool execution, and code diffs:

    • Mini TUI (Terminal): opencode --mini --continue
    • Full TUI (Terminal): opencode --continue
    • Web GUI (Browser): opencode web
    • Formatted Log Stream: tail -f <log-path> | glow - (or bat -l markdown)
  4. Verify & Sync Specs

    • Once spec-coder completes execution, automatically run verification using the openspec-verify-change skill (or /opsx:verify).
    • If verification passes with no CRITICAL issues:
      • Sync specs: openspec specs apply --change "<name>"
      • Suggest archiving via openspec archive <name>.
  5. Single-Pass Automated Repair (Max Retries = 1)

    • If CRITICAL issues or failed test verification errors are detected on the first pass:
      1. Announce: "Verification failed on initial pass. Attempting a single bounded repair pass..."
      2. Execute a single-pass repair agent with the verification failure context:
        opencode run --agent spec-coder --auto "Fix the specific verification failures and test errors reported for change '<name>'. Refer to the error log, make minimal targeted patches to resolve the failures, run verification commands, and update tasks.md."
        
      3. Re-run verification (openspec-verify-change).
      4. If verification passes after repair:
        • Sync specs: openspec specs apply --change "<name>"
        • Suggest archiving via openspec archive <name>.
      5. If verification STILL fails after the single repair pass:
        • HALT: Do NOT loop or execute again. Present the Verification Report and remaining blockers to the user for manual guidance.

04 同仓库更多 Skills