Route UserRequest to the correct worktree workflow. This skill dispatches only. It does not resolve tickets, run validation, or launch agents itself. All of that lives in the playbook it points to.
Use the agent-core result-delivery skill for operation output. Keep new bounded worktree-receipt/v4 phase records, retained v1/v2/v3 history and muxer process signals separate. Human sessions receive outcome, canonical references, checks, publication and blockers. Delegated phases use the caller's typed handoff; pane text is not workflow state.
Use Contract boundaries before producing or interpreting structured worktree artifacts. New executions use v4 receipts and v2 phase contexts. Retained v1/v2/v3/v3 events and assigned handoffs keep their original wire identities.
Global workflow rules
-
- Resolve this installed skill directory as
WORKTREE_SKILL_ROOT. Script paths are relative to that directory, not the target repository. Invoke"$WORKTREE_SKILL_ROOT/scripts/router.ts"directly from the target repository; its shebang selects the runtime.
- Resolve this installed skill directory as
-
- Load the
worktreeskill’sreferences/receipts.mdfile before running a worktree playbook.
- Load the
-
- Before every phase,
continue, or goal next-action decision, resolve the canonical ticket reference and run the read-only inspector from the target repository (or its surviving base worktree):
"$WORKTREE_SKILL_ROOT/scripts/inspect.ts" <canonical-ticket-ref> --jsonWORKTREE_SKILL_ROOTMUST be the absolute installed skill directory resolved above. The equivalent router entry is"$WORKTREE_SKILL_ROOT/scripts/router.ts" inspect <canonical-ticket-ref> --json. Both use the shared decision inscripts/recovery.ts; do not derive a competing next action from ticket status, filenames, or projections. Followreferences/receipts.mdfor decision modes and execution gates. Inspection reads state only: it does not claim, reconcile, launch, kill, merge, publish, or clean up. - Before every phase,
Every mutating ticket phase MUST create a durable receipt under the workflow root resolved by
the shared-context skill for <ticket-id>. tasks and goal preparation create no receipts. Receipts in events/ are
append-only and authoritative. Chat output, pane output, temporary handoff files,
manifests, and projections are not authoritative workflow state.
Follow the bounded-content rules in references/receipts.md. Store large evidence in checksum-bound artifacts, never receipt bodies. The writer rejects oversized v4 events before publication or delivery.
Every ticket-phase receipt MUST record the ticket ref, workflow ID, phase, parent receipt,
source branch, base branch, exact source commit and tree, workflow store and
reference, muxer, workspace path, agent, pane or session identifier, timestamp,
status, and output references.
Goal execution uses the separate coordinator journal contract in references/receipts.md. Goal preparation inspects this journal without creating or resetting it. The goal playbook supplies instructions to the current guided-goal interview and coordinates phases only after activation and scoped approval.
start, review, and fix MUST use independent agent sessions. A review or fix MUST run in a fresh agent session in the existing worktree workspace. It MUST NOT send instructions to, resume, or reuse an earlier implementation, review, or fixer session. The muxer-subagents skill owns how that fresh session is opened.
Review the exact source commit recorded in the review handoff. A verdict is valid only for that commit. Any later source commit or tree change invalidates either SUCCESS or FAILURE until a new review completes. Dirty source may be preserved for authorized start/fix takeover, never accepted for review or a new merge.
Before start, review, goal dispatch or finish, read references/concurrency.md. Keep source review exact while allowing the integration base to advance. Inspect work streams across initiatives; block concrete dependencies or incompatible resources, not initiative membership. Coordinate integration per repository and target branch, not globally across implementation sessions.
Use one immutable artifact under artifacts/reviews/ for every review attempt.
Never overwrite an earlier review or copy its body into the tracker. Store
versioned PR drafts under artifacts/snapshots/. Resolve manual evidence by
running the shared-context skill’s scripts/shared-context/cli.ts script with
resolve evidence; its store can differ from the workflow store.
Store current views under projections/.
Every commit made by a worktree playbook MUST follow the commit skill. Ticket-phase commit titles MUST contain the resolved issue reference. This applies to source commits, workflow-artifact commits, tracker-state commits, and the final merge commit. Coordinator-only journal commits use the canonical initiative reference or the frozen ticket references for an explicit collection.
Rule 0: resolve the project issue tracker
For every local Markdown file used by a worktree workflow, use the mq-query skill to locate, read, filter, select, list, summarise, or validate its content. Load the matching mq-query task reference and required upstream reference first. Do not use grep, find, rg, fd, ls, shell globs, or an ad hoc Markdown parser for that work.
Before loading tracker configuration or reading or changing a ticket, apply the
Route the request procedure in the reading-and-writing-tickets skill.
Use the shared-context skill to understand where artifacts are stored in the repo concerned.
Set ALIGNMENT_ROOT to its reported alignment root, and read
docs/agents/issue-tracker.md from that root. Pass the route table, alignment
root, mode, and repository root to the ticket skill. Do not derive these values.
The ticket skill owns ticket selectors, backend resolution, schema, references,
reads, claims, comments, completion, and tracker commits. This skill owns review
artifacts, receipts, snapshots, evidence, manifests, and workflow projections.
For mutating ticket phases, resolve the workflow root by running the shared-context skill’s
scripts/shared-context/cli.ts script with resolve workflow --id <ticket-id> --json.
When a phase needs evidence, resolve it separately by running the same script with
resolve evidence --workflow <ticket-id> --run <run-id> --json.
Use only these paths within the resolved roots: events/,
artifacts/reviews/, artifacts/snapshots/, artifacts/evidence/, and
projections/. Do not write workflow state into .scratch/, <ticket>/local/,
the ticket collection, or the source collection.
Rule 1: resolve the muxer and agent
Load the muxer-subagents skill before any playbook that opens a pane or launches a child agent. It owns muxer detection, agent detection, the spawn contracts, and the fresh-session mechanic.
For herdr-app ticket phases, MUST pass --title "<ticket-id>" to the child spawn command. Use the ticket ID resolved by the ticket skill. For concurrent children on the same ticket, append the phase or role, such as TICKET-123 · review. Keep the existing worktree space name and use run IDs for commands.
Run the muxer-subagents skill’s scripts/router.ts script with the contracts argument.
Take muxer, agent, contracts, session context and transport capabilities from the output. Before a new formal child launch, pass --result-schema worktree-receipt/v4. Retain the delivery context and assigned target. Validate the delivered receipt against its authoritative event before acknowledgement. Retained live v1 handoffs keep v1. A transport envelope does not authorize a phase or prove completion. If needsOperatorInput is true, ask the user.
submit, tasks, and goal preparation do not launch an agent. Skip launch setup for them. Goal preparation may resolve/read contracts for read-only liveness inspection. Authorized goal execution applies launch setup through each mutating phase playbook.
Route
Resolve the issue tracker before following a playbook that reads or updates a ticket. Mutating playbooks receive the ticket ref and backend as working context. tasks and goal resolve their initiative or ticket selectors through their own procedures.
Run "$WORKTREE_SKILL_ROOT/scripts/router.ts" route "$ARGUMENTS" from the target repository.
The command resolves the subcommand and prints JSON: { match, subcommand, remainder, playbook } on success, or { match: false, request } with a non-zero exit on no match. /skill:worktree tasks [optional ticket id] routes to references/playbooks/tasks.md. /skill:worktree goal <initiative-id> and /skill:worktree goal <ticket-id> [<ticket-id> ...] route to references/playbooks/goal.md. A /guided-goal request to use the worktree goal skill loads that playbook directly, with the named selectors, without generating another prompt. Its recovery rules live in references/goal-recovery.md.
On match
- Read the
worktreeskill’sreferences/receipts.mdfile. - Read
playbookfrom the route output. - Apply Rule 1 where the playbook opens a pane or launches an agent.
- Read
muxerContractwhere the playbook opens, waits for, or releases a pane. - Read
agentContractwhere the playbook launches an agent.
On no match
Read the playbooks named by this router under references/playbooks/ and choose the one whose goal best matches the request. State which one you chose and why. Ask if two are equally plausible.
Worktrunk owns git worktrees
Every playbook, muxer contract, and agent contract MUST follow the worktrunk skill for creating, switching, removing, and merging worktrees. None may call git worktree directly.
Troubleshooting
Known failure modes live in the worktree skill’s references/troubleshooting/ directory:
wt-hook-approval-needed.mdfixer-agent-blocked.mdmissing-review-verdict.mdblocker-cycle.md
For unknown-muxer or unknown-agent, see the muxer-subagents skill’s references/troubleshooting/muxer-or-agent-undetected.md file.