Post plan workflow

From jpicklyk/task-orchestrator · View interactive version

Post plan workflow is an AI agent skill from the GitHub repository jpicklyk/task-orchestrator. Internal, hook-triggered when a plan is approved: materializes MCP items from the plan and dispatches implementation.

How to use this skill

Skill file

Post-Plan Workflow - Materialize and Implement

Plan approval is the green light for the full pipeline. Run all three phases without stopping; the one expected stop is the turn that ends when a run-wave Method A launch hands control to its async notification (Phase 2, Route). Shapes are in CODE0; ids below are 8-hex shorts.

Phase 1: Materialize

Finish materialization before any implementation begins.

Prefer the stashed plan. The plan-capture hook stashes the approved plan as a plan document when ExitPlanMode fires and reports the slug in its context (plan stashed as plan document '<slug>' (root <rootId>)). Confirm it and read it:

{"tool": "docs_read", "select": "list", "args": {"rootId": "9f3a1c22", "kind": "plan"}}

A plan with no adoptedBy is still pending. docs_read get with kind: "plan" and the slug returns the body. Quote or anchor its sections instead of retyping them; with no stashed document (stdio setups, hook failed open) use the plan text in context.

  1. Create the items with one create_tree call per parent; each call is all-or-nothing, so one tree never leaves partial state. Materialize one parent per PR the plan names, one create_tree each, in PR order; a plan naming one PR keeps a single tree. With more than one tree, the first parent's tree takes the plan document (docRef) and its noteAnchors; each later parent's tree writes its notes explicitly with notes[], since a second docRef on an adopted document answers duplicate. The trees are separate calls: if a later tree fails, the earlier parents stand and only the failed tree is retried. Hold each later tree behind the parent just before it (the later tree's items build on the earlier PR's changes: always under split reasons 2, 3 and 6, each of which names that dependency; under 1, 4 and 5 only when they do, otherwise no cross-tree edge) with the cross-tree blocks edges described below the example, so the later PR's work does not read as ready before the earlier PR merges. Every item needs a declared type (read config effective types; see create-item Step 4); traits and tags are arrays. Anchor the root under the project: set parentId to the project rootId (or a category container beneath it) when known. Dedup first, once per new root or feature (children inherit): one unscoped items_read search (kinds: ["item"], limit: 5); unscoped on purpose so legacy depth-0 and other-root items show. Show close matches as one FYI line and keep going; never auto-link, auto-skip or auto-cancel.
{"tool": "items_write", "op": "create_tree", "args": {"root": {"title": "Add retry layer", "type": "feature-implementation"}, "parentId": "9f3a1c22", "docRef": {"slug": "retry-layer"}, "children": [{"ref": "t1", "title": "Backoff policy", "type": "feature-task", "noteAnchors": [{"noteKey": "task-scope", "role": "queue", "anchor": "backoff-policy"}]}, {"ref": "t2", "title": "Retry tests", "type": "feature-task"}], "deps": [{"from": "t1", "to": "t2"}]}}

docRef plus noteAnchors cut plan sections into notes and the root adopts the document (the first tree only, when the plan names several PRs); notes[] writes explicit bodies. The result is {ok, id, version, items, deps, notes} and carries no expectedNotes.

Holding a later tree. A blocks edge into the later parent would not hold its children: an item's readiness counts only the blocks edges into that item itself, and an ancestor passes down claims only. So each earlier parent blocks every entry item of the next tree, the items with no blocker inside their own tree; items below the entry items are held by their in-tree edges. These edges join two trees and create_tree deps refs are tree-local, so wire them with deps_write fan_out once the later tree's items[] gives its ids, from the earlier parent to the entry items, leaving a lifecycle-free entry item out of the fan_out toIds (fan_out is all-or-nothing, and a blocks edge with a lifecycle-free endpoint is refused). Each cross-tree edge takes the Depends on <short>: <reason> line on its entry item's spec note, carrying the boundary reason. Keep the default unblockAt (terminal), because the earlier parent completes after its PR merges.

Existing items. An item the plan covers that already exists is moved under the new parent with items_write update (id, parentId) and left out of the create_tree children, never recreated. A queue note it already holds is amended with notes_write upsert under expectedVersion (its version from notes_read list) and never overwritten; an unfilled required note is filled as in step 3. Its edges to the new tree's items go through deps_write once items[] gives the ids, since create_tree deps refs are tree-local.

{"tool": "deps_write", "op": "fan_out", "args": {"from": "9f3a1c22", "toIds": ["4b7d0e19", "6e21c0aa"], "type": "blocks"}}
  1. Dependencies. A blocks edge (the deps array, or deps_write later) is for a semantic dependency only: the dependent cannot start meaningfully until the other item is done.
  1. Fill queue notes. Read the schema (a create returns no expectedNotes):
{"tool": "items_read", "select": "schema", "args": {"itemId": "4b7d0e19", "fields": ["guidance"]}}

data is {schemaFree: true} for a schema-free item. Otherwise fill each required queue note (feature-summary, task-scope, ...) from the plan, in one notes_write call with an upsert element per note. Keep pre-filling planner-stage notes: run-wave adopts them under the planner seat after assign (run-ops --phase adopt-notes), so a later run does not recreate them by hand.

  1. Verify the graph. Confirm every id in items[] exists:
{"tool": "items_read", "select": "overview", "args": {"itemId": "4b7d0e19"}}

Do not dispatch implementation agents until materialization is complete; they need the item ids to report progress.

Phase 2: Implement

Route: run-wave or hand-dispatch

Hand off to /task-orchestrator:run-wave only when ALL four conditions hold. Each is a concrete probe:

  1. Two or more unblocked leaf items. At least two leaves (no children) were materialized and none appears in the blocked list:
{"tool": "items_read", "select": "blocked", "args": {"ancestorId": "4b7d0e19"}}
  1. A rootId resolves (project or personal), in run-wave Step 1's order: session context (Active project: or Personal root: line), then project.rootId from the file on that context's Config: line, then .taskorchestrator/config.yaml.
  2. Queue notes are filled. For each leaf, items_read context with its itemId shows no missing queue notes in gateStatus.missing, or its schema read is {schemaFree: true}.
  3. Protocol rules are served. This lists protocol.entry-seat, protocol.in-phase-seat and protocol.read-only-agent (a seed made earlier this session by init or the run-wave repair shows up):
{"tool": "config", "op": "rules", "args": {"rootId": "9f3a1c22"}}

If all four hold, invoke /task-orchestrator:run-wave <materialized root id> and follow it. Plan approval counts as run-wave's Checkpoint 1. When a degradation forces a human look (meta.excluded or meta.degradations non-empty, or an empty run), show the explain table and end the turn; never use AskUserQuestion. A Method A launch ending the turn is expected. run-wave's post-run replaces Phase 3, which then applies only to the hand-dispatch path.

If any condition fails, hand-dispatch and add one line naming the failed condition(s); for conditions 2 and 4 point at /task-orchestrator:init.

Hand-dispatch

{"tool": "advance", "op": "transition", "args": {"itemId": "4b7d0e19", "trigger": "start"}}

Do not use AskUserQuestion between phases.

Phase 3: Verify

After all agents return:

  1. List items still in queue (agents that failed leave their items there; the role: "work" list is what you review and advance next) and diagnose them with /status-progression:
{"tool": "items_read", "select": "list", "args": {"ancestorId": "4b7d0e19", "role": "queue"}}
  1. Run the health check to see what completed, stalled or is blocked: items_read context with the same ancestorId.
  2. For each stalled item, items_read context with its itemId shows gateStatus.missing.
  3. Address blockers or incomplete work. An agent that returned awaiting_decision needs a decision raised per decisions.md (when it had no seat token); do not re-dispatch it until the decision is answered and the item resumed.

Workflow complete

Report the final status: what completed, what needs attention, what is still in progress.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.