This skill executes an OpenSpec change from proposal to merge by coordinating design, planning, worktrees, review, tests, and final integration.
npx playbooks add skill denki-san/exec-openspec-change --skill execute-openspec-change
Automates the complete execution workflow for OpenSpec proposals/changes. This skill orchestrates multiple Superpowers skills to provide a seamless execution experience from proposal to merged code.
Core principle: Orchestration + State Management + Superpowers Integration = Reliable Execution.
Announce at start: "I'm using the execute-openspec-change skill to execute the [change-id] proposal."
| Pattern | Example | Match Rule |
|---------|---------|------------|
| Command | /execute add-subagent-display | Prefix /execute or /exec |
| Command | /exec add-sub | Short form |
| Natural | 执行 add-subagent-display | Contains 执行 + change-id |
| Natural | 帮我完成这个变更 | Contains 完成/实现 + change-id |
| Natural | 开始实现 fix-permission | Contains 开始 + change-id |
| Context | 执行这个 change | Infer from conversation history |
1. Extract change-id
├─ Explicit: Use directly
├─ Context infer: From conversation history/recent files
└─ Interactive: List options if uncertain
2. Safety checks
├─ Verify change-id exists in openspec/changes/
├─ Warn if change is archived
└─ Check if tasks.md exists
3. Parse parameters
├─ Mode: auto | guided | debug
├─ Test failure strategy: prompt | auto_fix | abort
└─ Parallel strategy: serial | parallel+detect | domain-isolated
/execute <change-id> --mode=auto # Fully automated (default)
/execute <change-id> --mode=guided # Pause at each checkpoint
/execute <change-id> --mode=debug # Verbose output,随时介入
PENDING → DESIGNING → PLANNING → EXECUTING → REVIEWING → TESTING → READY → MERGED/ABANDONED
| Current | Trigger | Next | Action |
|---------|---------|------|--------|
| PENDING | Start | DESIGNING | Check design.md |
| DESIGNING | design.md complete | PLANNING | Enter planning |
| DESIGNING | design.md incomplete | DESIGNING | Run brainstorming |
| PLANNING | tasks.md complete | EXECUTING | Create worktree |
| PLANNING | tasks.md incomplete | PLANNING | Run writing-plans + merge |
| EXECUTING | All tasks done | REVIEWING | Auto trigger code review |
| REVIEWING | Review pass | TESTING | Run tests |
| TESTING | Tests pass | READY | Wait for user acceptance |
| READY | User confirms merge | MERGED | Merge to main |
| READY | User aborts | ABANDONED | Cleanup worktree |
| ANY | User aborts | ABANDONED | Keep state for resume |
// openspec/changes/<id>/.exec-state.json
{
"change_id": "add-subagent-display",
"status": "EXECUTING",
"mode": "auto",
"worktree_path": "/worktrees/server-add-sub",
"domain": "server",
"current_task": 15,
"total_tasks": 20,
"checkpoints": [
{"task": 5, "timestamp": "2026-02-01T10:30:00Z", "summary": "..."},
{"task": 10, "timestamp": "2026-02-01T11:15:00Z", "summary": "..."}
],
"test_failure_strategy": "prompt",
"dependencies": ["another-change-id"],
"created_at": "2026-02-01T10:00:00Z",
"updated_at": "2026-02-01T11:20:00Z"
}
Check if changes/<id>/design.md exists:
├─ Not exist → Run brainstorming skill
├─ Exists but empty → Run brainstorming skill
├─ Exists but incomplete → Check missing sections, run brainstorming to supplement
└─ Exists and complete → Skip to next phase
design.md must contain these sections to be complete:
## Context [Required]
## Goals / Non-Goals [Required]
## Decisions [Required]
## Risks / Trade-offs [Optional but recommended]
## Migration Plan [If needed]
## Open Questions [If any]
Action: If incomplete, use superpowers:brainstorming to generate/supplement the design.
1. Read existing tasks.md
2. Run writing-plans skill to generate new plan
3. Merge strategy:
├─ Keep completed [x] tasks from existing tasks.md
├─ Add unique tasks from new plan
├─ Update overlapping task descriptions
└─ Maintain tasks.md format and structure
4. Show merge diff to user, confirm before writing
1. Completed [x] tasks → Keep
2. New plan tasks → Merge
3. Manual tasks → Keep
4. Conflict tasks → Ask user
Action: Use superpowers:writing-plans to generate plan, then intelligently merge with existing tasks.md.
| Domain | Typical Files | Conflict Risk |
|--------|---------------|---------------|
| server | server/.py, server/*/*.py | Medium (shared state machine) |
| frontend | server/static/.html, server/static/.js | Medium (shared API) |
| openspec | openspec/**/*.md | Low (doc conflicts easy) |
| config | .json, .plist, .env | High (global config) |
| tests | test_.py, */*test.py | Low |
/worktrees/<domain>-<change-id-short>/
Example: /worktrees/server-add-sub, /worktrees/frontend-fix-icon
Action: Use superpowers:using-git-worktrees to create isolated workspace.
1. Create Worktree
┌─ Call superpowers:using-git-worktrees
├─ Smart directory selection
├─ Safety verification
└─ Get worktree path
2. Start Subagent
┌─ Call superpowers:subagent-driven-development
├─ Pass tasks.md as task list
├─ Set checkpoint interval (default: 5 tasks)
└─ Set interaction level based on mode
3. Monitor Execution
┌─ Listen to subagent output
├─ Update .exec-state.json progress
├─ Handle subagent help requests
└─ Guided mode: pause at each checkpoint
4. Completion Detection
┌─ All tasks.md items marked [x]
└─ Or subagent reports completion
5. Auto Code Review
┌─ Call superpowers:requesting-code-review
├─ Compare against proposal.md requirements
└─ Generate review report
{
"task_source": "openspec/changes/<id>/tasks.md",
"checkpoint_interval": 5,
"mode": "auto",
"error_handling": "pause_on_error",
"review_trigger": "on_completion",
"max_retries": 3
}
Auto-triggered after execution completion using superpowers:requesting-code-review.
Comparison:
1. Requirements in proposal.md
2. Actual implementation
3. tasks.md completion status
Verify:
- All requirements implemented
- Code follows project standards
- No obvious bugs or security issues
- Test coverage adequate
# Code Review Report: <change-id>
## ✅ Pass Items
- All tasks.md tasks completed (N/N)
- Code follows standards
- Core functionality correct
## ⚠️ Improvement Suggestions
- file:line - specific suggestion
## 🔴 Blocking Issues
- critical issues that must be fixed
## Conclusion
✅ PASS / ❌ FAIL - Ready for testing / Needs fixes
# 1. Automated tests
- Run project test suite (if exists)
- Code style checks
- Static analysis
# 2. Functional verification
- Verify each scenario from proposal.md
- Generate verification report
# 3. Integration tests (if needed)
- Test interaction with other modules
- Test API contracts
| Strategy | Behavior |
|----------|----------|
| prompt | Pause, show test failure log, let user decide |
| auto_fix | Let subagent attempt to fix (max max_retries) |
| abort | Stop immediately, keep worktree for manual fix |
# Verification Report: <change-id>
## Automated Tests
✅ Test Suite: N/N passed
✅ Lint: No issues
✅ Type Check: No issues
## Functional Verification
✅ Scenario 1: description
✅ Scenario 2: description
✅ Scenario 3: description
## Issues
- Any issues found
## Conclusion
✅ READY - Can merge to main / ❌ NOT READY
┌─────────────────────────────────────────┐
│ 📋 Pre-Merge Report │
├─────────────────────────────────────────┤
│ Change: <change-id> │
│ Status: READY ✅ │
│ │
│ Changed files: │
│ path/to/file (+N, -M) │
│ │
│ Affected modules: │
│ - Module A │
│ - Module B │
│ │
│ Conflict detection: │
│ ✅ No conflicts with other worktrees │
│ ✅ No breaking changes │
│ │
│ Dependencies: │
│ - None / List │
│ │
│ Blocked: │
│ - None / List │
└─────────────────────────────────────────┘
Choose:
[A] Merge to main now
[B] View detailed diff
[C] Stash (keep worktree)
[D] Abort (delete worktree)
1. Create backup tag
git tag before-merge-<change-id>-<timestamp>
2. Attempt merge
git merge worktree-branch
3. If conflict → Pause, let user resolve
4. Merge success → Run quick verification
5. Update status to MERGED
6. Prompt to archive change
/rollback before-merge-<change-id>-<timestamp>
Keep worktree until user confirms delete (default: 24 hours).
/status # Show all active worktrees
/status <change-id> # Show specific change progress
/status --all # Include completed
📊 OpenSpec Execution Status
Active Executions:
server-add-subagent [████████░░] 80% (16/20 tasks)
├─ Status: EXECUTING
├─ Mode: auto
├─ Subagent: Working
└─ Last activity: 2 min ago
frontend-fix-icon [███░░░░░░░░] 30% (3/10 tasks)
├─ Status: EXECUTING (paused)
├─ Mode: guided
├─ Waiting: User input
└─ Checkpoint: Waiting confirmation
Ready for Acceptance:
fix-thinking-bug [██████████] 100% ✅
├─ Status: READY
├─ Tests: Pass
└─ Code Review: Pass
Recently Completed:
add-config-timeout ✅ Merged (2 hours ago)
refactor-session ✅ Merged (yesterday)
/cleanup # Detect and clean orphan worktrees
/cleanup --dry-run # Preview what will be deleted
/cleanup --force # Force cleanup all inactive worktrees
| Condition | Action |
|-----------|--------|
| Worktree inactive > 7 days | Mark ABANDONED, ask to delete |
| .exec-state.json ABANDONED > 3 days | Auto delete |
| Change archived | Ask to delete worktree |
| Merged > 24 hours | Auto delete worktree |
~/.claude/openspec-exec-logs/
├── 2026-02-01-<change-id>/
│ ├── exec.log # Main flow log
│ ├── subagent.log # Subagent output
│ ├── review.log # Code review results
│ ├── test.log # Test results
│ └── metadata.json # Execution metadata
└── archive/ # Old logs archive
Log retention:
## Dependencies
- depends_on: add-subagent-display
- blocks: multi-session-support
## Conflicts With
- May conflict with exclusive-state-change (both modify state_machine.py)
1. Parse dependencies
2. Check dependent change status:
- MERGED → Can execute
- Not complete → Prompt to complete first, or batch execute
3. Check blocks
- If changes waiting for current → Prompt when complete
/execute add-sub fix-perm --auto-resolve-deps
# Execute multiple changes in dependency order automatically
/execute <change-id> --resume
# Resume from interrupted point
| Exception Type | Handling |
|----------------|----------|
| Subagent crash | Save state, report error, wait for user |
| Worktree conflict | Pause, show conflict details, provide options |
| Test failure | Handle per test_failure_strategy |
| Network/resource | Retry (max 3), pause on failure |
| User interrupt | Save state, support --resume |
❌ Execution Interrupted: <change-id>
Error Type: Subagent abnormal exit
Error Message: ...
Location: checkpoint 3, task 1.4
Suggested Actions:
[R] Retry current task
[S] Skip current task, continue next
[A] Abort execution, keep state
[L] View detailed logs
# Check for file conflicts
git diff --name-only worktree-A | sort > /tmp/A.files
git diff --name-only worktree-B | sort > /tmp/B.files
comm -12 /tmp/A.files /tmp/B.files # Output conflict files
# Check if modifying same functions/classes
# Check if modifying same spec requirements
# Detect introduced breaking changes
| Conflict Type | No Conflict | File Conflict | Semantic Conflict |
|---------------|-------------|---------------|-------------------|
| Parallel strategy | Allow | Warn | Block |
// .worktree-registry.json
{
"active_worktrees": [
{
"change_id": "add-subagent-display",
"path": "/worktrees/server-add-sub",
"domain": "server",
"status": "EXECUTING",
"pid": "subagent-xxx",
"created_at": "2026-02-01T10:00:00Z",
"last_activity": "2026-02-01T11:20:00Z"
}
]
}
| Phase | Superpowers Skill | Purpose |
|-------|-------------------|---------|
| Pre-trigger | superpowers:brainstorming | Generate/supplement design.md |
| Plan | superpowers:writing-plans | Generate execution plan |
| Worktree | superpowers:using-git-worktrees | Create isolated environment |
| Execution | superpowers:subagent-driven-development | Run implementation tasks |
| Review | superpowers:requesting-code-review | Verify code quality |
| Acceptance | superpowers:verification-before-completion | Final verification |
| Command | Purpose |
|---------|---------|
| /execute <id> | Start execution |
| /execute <id> --mode=guided | Guided execution |
| /execute <id> --resume | Resume interrupted execution |
| /status | Show execution status |
| /status <id> | Show specific change status |
| /cleanup | Clean up orphan worktrees |
| /rollback <tag> | Rollback merge |
Never:
Always:
User: /execute add-subagent-display
You: I'm using the execute-openspec-change skill to execute the add-subagent-display proposal.
[Detect change exists, check safety]
[Read .exec-state.json - doesn't exist, fresh execution]
[Check design.md - complete]
[Check tasks.md - incomplete, run writing-plans]
[Merge plan with tasks.md]
[Create worktree using using-git-worktrees]
[Start subagent using subagent-driven-development]
[Monitor execution, update checkpoints]
[Execution complete, auto-trigger code-reviewer]
[Review passes, run tests]
[Tests pass, show pre-merge report]
[User selects A: Merge]
[Create backup tag, merge to main]
[Update status to MERGED]
[Archive change]
✅ Execution complete: add-subagent-display
- Merged to main
- Worktree cleaned up
- Change ready for archival
---
This section provides concrete implementation steps for the AI agent following this skill.
First, determine if the user wants to execute a change:
# Pseudo-code for trigger detection
user_input = get_user_message()
# Check for command-style triggers
if user_input.startswith("/execute") or user_input.startswith("/exec"):
# Extract change-id and parameters
parts = user_input.split()
change_id = parts[1] if len(parts) > 1 else None
# Parse flags (--mode, --resume, etc.)
return detected_intent("command", change_id, flags)
# Check for natural language triggers (Chinese/English)
execute_keywords = ["执行", "完成", "实现", "开始", "execute", "complete", "implement", "start"]
if any(keyword in user_input.lower() for keyword in execute_keywords):
# Extract potential change-id from message
change_id = extract_change_id_from_message(user_input)
return detected_intent("natural_language", change_id, {})
# Check for context inference
if "这个" in user_input or "this" in user_input.lower():
change_id = infer_from_conversation_history()
return detected_intent("context", change_id, {})
def extract_change_id_from_message(message):
# Try to match known change patterns
known_changes = list_openspec_changes()
# Direct match
for change in known_changes:
if change in message:
return change
# Partial match (e.g., "add-sub" for "add-subagent-display")
for change in known_changes:
if message.split()[-1] in change:
return change
return None
# Verify change exists
if [ ! -d "openspec/changes/$CHANGE_ID" ]; then
# Check if it's archived
if [ -d "openspec/changes/archive/*/$CHANGE_ID" ]; then
echo "⚠️ This change is archived. Are you sure you want to execute it?"
# Ask user confirmation
else
echo "❌ Change not found: $CHANGE_ID"
# List available changes
openspec list
exit 1
fi
fi
# Check if tasks.md exists
if [ ! -f "openspec/changes/$CHANGE_ID/tasks.md" ]; then
echo "⚠️ No tasks.md found. This change may not be ready for execution."
echo " Please create tasks.md first using openspec workflow."
exit 1
fi
import json
from pathlib import Path
exec_state_path = Path(f"openspec/changes/{change_id}/.exec-state.json")
if exec_state_path.exists():
with open(exec_state_path) as f:
state = json.load(f)
# Ask user if they want to resume
if state["status"] in ["EXECUTING", "REVIEWING", "TESTING"]:
print(f"⚠️ This change has an acWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.