Execute Next Best Task
Orchestrator-of-orchestrators: select ONE ready item, delegate the whole execution to spec-execute / spec-continue (their rules apply verbatim - this skill adds only selection and cleanup), then reset the workspace. Designed for autonomous and scheduled runs - this is execution_mode: autonomous machinery; its queue is filled by spec-approve, and a supervised project does not schedule it.
Steps
- Preflight.
git status --porcelainclean (dirty - halt and surface; never sweep foreign work into a task).git switch <base> && git pull && git fetch --prune. - Inventory.
- Candidates:
approvedspecs in the project's spec area (profilespecs_dir; else detect) - the primary pool - plusin-progressspecs with no open PR (to finish; finishing beats starting). Neverproposed(unreviewed - the owner approves viaspec-approvefirst),completed,cancelled, orsuperseded. Skip idea-collection notes without a concrete ticket-sized item. - In-flight work:
gh pr list --state open --json number,title,headRefName,labels,updatedAt; per-PR file scope viagh pr view <n> --json files --jq '.files[].path'.
- Candidates:
- Select ONE.
- Value order: explicit priority marker - mid-flight spec with no open PR (finishing beats starting) - unblocks queued work - smaller effort at equal value. A focus-hint argument narrows the pool, never overrides the conflict gate.
- Conflict gate, skip the candidate if: it already has an open PR (
ai:processingmeans another run holds it;ai:manual/ai:failedneed the owner, not a re-run); its file scope overlaps any open PR's files; it needs a decision the spec leaves open (that isai:manualbefore even starting). - Interactive session - confirm the choice plus runner-up in one question. Autonomous run - proceed. No eligible candidate - report per-candidate skip reasons and stop (skip step 5's sync, still end clean).
- Execute until outcome. Mid-flight spec -
spec-continue; otherwisespec-execute. Run until the PR carries an outcome label (ai:completedwith every declared factor, orai:manual/ai:failed). Never merge. - Reset (runs regardless of outcome).
git switch <base> && git pull && git fetch --prune. Close any spec whose PR merged since the last run (spec-close) so the queue and docs reflect reality. Re-render the project's generated intelligence outputs when it has an engine that produces them, using the command that engine documents; skip when it has none. Report: task picked + why; PR URL + outcome label; what needs the owner; runner-up for the next run.
Verify
- Exactly one task progressed to an outcome label; workspace back on a clean, current base.
Scope / hand-off
- All execution rules -
spec-execute; the merge -git-merge-prafter owner accept. The approved queue this skill drains is filled byspec-approve(the owner's gate-1 decision).
Constraints
- ONE task per invocation; the next starts only after reset and fresh context.
- The conflict gate is non-negotiable - when in doubt about overlap, pick the next candidate.
- Never block other agents' open PRs.