skills/opencode/cleanup/SKILL.md
Post-merge workflow resolution. Verifies PR merge status, backfills synthesis metadata, force-resolves review statuses, transitions to completed, and cleans up worktrees/branches. Use when the user says 'cleanup', 'resolve workflow', 'mark as done', or runs /cleanup. Do NOT use before PRs are merged.
npx skillsauth add lvlup-sw/exarchos cleanupInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
This skill uses VCS operations through Exarchos MCP actions (list_prs, get_pr_comments, etc.).
These actions automatically detect and route to the correct VCS provider (GitHub, GitLab, Azure DevOps).
No gh/glab/az commands needed — the MCP server handles provider dispatch.
Resolve merged workflows to completed state in a single operation. Replaces the manual multi-step process of navigating HSM guards after PR stacks merge.
For bulk cleanup of accumulated stale or abandoned workflows (as opposed to resolving a single merged workflow), use @skills/prune-workflows/SKILL.md. That skill invokes exarchos_orchestrate prune_stale_workflows in dry-run mode, displays candidates, and applies after user confirmation. Safeguards automatically skip workflows with open PRs or recent commits.
Rule of thumb: cleanup is per-workflow (one merged feature → completed); prune is bulk (N inactive workflows → cancelled). They are complementary, not alternatives.
Activate this skill when:
/cleanup commandRead workflow state to get current phase and metadata:
mcp__exarchos__exarchos_workflow({ action: "get", featureId: "<id>" })
If featureId not provided, use pipeline view to list active workflows:
mcp__exarchos__exarchos_view({ action: "pipeline" })
For each PR associated with the workflow, verify it is merged.
Primary method — VCS MCP action:
exarchos_orchestrate({ action: "list_prs", state: "merged" })
For individual PR details, use exarchos_orchestrate({ action: "get_pr_comments", prId: "<number>" }) or the VCS provider's native API.
Collect from merged PRs:
prUrl: The PR URL (or array of URLs for stacked PRs)mergedBranches: The head branch names that were mergedSafety check: If ANY PR is not merged, abort with clear error message.
For detailed verification guidance, see references/merge-verification.md.
After verifying merge status, run the post-merge regression check:
exarchos_orchestrate({
action: "check_post_merge",
featureId: "<id>",
prUrl: "<url>",
mergeSha: "<sha>"
})
This check is advisory — findings are reported but do not block cleanup. If findings are detected, log them for the user's awareness before proceeding.
Call the MCP cleanup action with collected data:
mcp__exarchos__exarchos_workflow({
action: "cleanup",
featureId: "<id>",
mergeVerified: true,
prUrl: "<url-or-array>",
mergedBranches: ["branch1", "branch2"]
})
This single call:
synthesis.prUrl and synthesis.mergedBranchesapprovedcompleted via universal cleanup pathworkflow.cleanup event to event storeReclaim all worktrees associated with the workflow through the governed
garbage-collector prune_worktrees — not ad-hoc git worktree remove.
GC cadence — after synthesize (INV-12). Governed worktrees become reclaimable once a workflow reaches synthesis; cleanup runs post-merge (after synthesize completes), so this is the natural point to apply the reclamation. The
next_actionsprojection surfaces the sameprune_worktreesdry-run affordance from synthesis onward.
prune_worktrees runs the fail-closed safety ladder (it refuses to destroy a
worktree with unsaved work) and auto-emits the worktree.remove.requested /
worktree.remove.executed pair per deleted worktree. Dry-run first (the default
— reports candidates + reclaimable bytes + grouped skip reasons, deletes
nothing), then apply:
// Dry-run (default) — preview candidates, delete nothing
mcp__exarchos__exarchos_orchestrate({ action: "prune_worktrees", repoRoot: "<repo-root>" })
// Apply — reclaim the delete-eligible candidates
mcp__exarchos__exarchos_orchestrate({ action: "prune_worktrees", repoRoot: "<repo-root>", dryRun: false })
Handle gracefully if worktrees are already removed. If the GC skips a worktree (e.g. uncommitted work), resolve the reported reason before re-applying — never force-remove a dirty worktree by hand.
Remove merged local branches:
git fetch --prune
git branch -d <merged-branch-1> <merged-branch-2> ...
Output summary:
## Cleanup Complete
**Feature:** <featureId>
**Transition:** <previousPhase> → completed
**PRs merged:** <count>
**Worktrees removed:** <count>
**Branches synced:** ✓
Use dryRun: true to preview what cleanup would do without modifying state:
mcp__exarchos__exarchos_workflow({
action: "cleanup",
featureId: "<id>",
mergeVerified: true,
dryRun: true
})
| Error | Cause | Resolution | |-------|-------|------------| | STATE_NOT_FOUND | Invalid featureId | Check pipeline view for active workflows | | ALREADY_COMPLETED | Workflow already done | No action needed | | INVALID_TRANSITION | Workflow is cancelled | Cannot cleanup cancelled workflows | | GUARD_FAILED | mergeVerified is false | Verify PRs are merged before cleanup |
| Don't | Do Instead | |-------|------------| | Use cleanup as escape hatch during implementation | Only use after PRs are merged | | Skip merge verification | Always verify via GitHub API | | Manually navigate HSM guards post-merge | Use /cleanup | | Leave worktrees after cleanup | Include worktree removal in process |
The cleanup action auto-emits events — do NOT manually emit:
workflow.cleanup — emitted by the MCP cleanup action for the phase change to completedtesting
Create pull request from completed feature branch using GitHub-native stacked PRs. Use when the user says 'create PR', 'submit for review', 'synthesize', or runs /synthesize. Validates branch readiness, creates PR with structured description, and manages merge queue. Do NOT use before review phase completes. Not for draft PRs.
testing
Shepherd PRs through CI and reviews to merge readiness. Operates as an iteration loop within the synthesize phase (not a separate HSM phase). Uses assess_stack to check PR health, fix failures, and request approval. Triggers: 'shepherd', 'tend PRs', 'check CI', or /shepherd.
development
Single adversarial review pass over the integrated branch diff — spec-compliance, code quality, and test adequacy judged together by one fresh-context reviewer. Triggers: /review, 'review the changes', or after delegation completes. Emits one verdict (reviews.review.status). Do NOT use for plan-review (that is its own dispatched gate) or for debugging.
testing
Restore and read workflow state after a context break — re-inject workflow phase, task progress, and behavioral guidance into the current session, reconcile state against git reality, and verify whether a workflow exists. Use when the user says 'resume', 'rehydrate', 'where were we', or runs /rehydrate, or when the agent has drifted after context compaction. Do NOT use for saving or mutating state (that is /checkpoint).