Skip to skill documentation
dotfilesGitHub

developer / skill instructions

worktree

Route worktree phases and dependency views to their playbooks. Use the goal workflow in a guided-goal interview to complete an initiative or explicit ticket collection.

Invoked by user and agentCategory: git
No how-to guide publishedView SKILL.md ↗

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

    1. 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.
    1. Load the worktree skill’s references/receipts.md file before running a worktree playbook.
    1. 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> --json
    

    WORKTREE_SKILL_ROOT MUST 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 in scripts/recovery.ts; do not derive a competing next action from ticket status, filenames, or projections. Follow references/receipts.md for decision modes and execution gates. Inspection reads state only: it does not claim, reconcile, launch, kill, merge, publish, or clean up.

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

  1. Read the worktree skill’s references/receipts.md file.
  2. Read playbook from the route output.
  3. Apply Rule 1 where the playbook opens a pane or launches an agent.
  4. Read muxerContract where the playbook opens, waits for, or releases a pane.
  5. Read agentContract where 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.md
  • fixer-agent-blocked.md
  • missing-review-verdict.md
  • blocker-cycle.md

For unknown-muxer or unknown-agent, see the muxer-subagents skill’s references/troubleshooting/muxer-or-agent-undetected.md file.

Worktree workflow

Who coordinates the work, how sessions hand off, when a review is valid, and which records prove completion.

04 diagramsOwnership → handoffs → review gates → recordsFull-width maps · scroll locally on narrow screens
01

Who owns what

Ownership map
Who owns whatYou invoke the worktree playbook. It coordinates shared-context for paths and records, muxer-subagents for fresh sessions, Worktrunk for Git worktrees, and the ticket skill for the issue reference.YouSelect a phaseWorktree playbookCoordinate the phaseshared-contextResolve storage routesmuxer-subagentsCreate fresh sessionsWorktrunkOwn Git lifecycleTicket skillResolve issue referenceRecordsResolved locationsNew agentIndependent contextGit worktreeSource workspaceCoordination is not ownership of storage, sessions, or Git.

The playbook coordinates; shared-context, muxer-subagents, Worktrunk, and the ticket skill retain their own responsibilities.

02

Start and review handoffs

Sequence
Start and review handoffsStart launches an implementation agent. Review launches a different reviewer session in the same source worktree. A signal is transient; the parent verifies persisted receipts after each completion.YOUWORKTREE PLAYBOOKFRESH AGENT SESSIONstart(ticket)Implementation handoffCompletion signal + durable receiptreview(ticket)Different reviewer · same source worktreeVerdict for the frozen commit01 / Request02 / Verify receipts after each signal03 / Never reuse the implementer

The implementation and review use separate agent sessions in the same source worktree. The parent checks receipts after completion signals.

03

Review and finish gates

State machine
Review and finish gatesImplementation becomes reviewable and is reviewed. FAILURE leads to a fix, a new commit, and review again. SUCCESS approves only the frozen commit. An approved source can finish directly or optionally submit a pull request before finishing. A new commit invalidates the approval.ImplementingFresh implementationReviewableFreeze source commitReviewIndependent reviewerApprovedCommit-bound verdictNeeds fixFix → new commitSubmittedOptional pull requestFinishedFinish directly or after PRSUCCESSFAILUREReview againSubmitFinishFinishNew commit invalidates the previous verdict

FAILURE requires a fix and another review. SUCCESS applies to the reviewed commit. Submission is optional before finish; a new commit invalidates the verdict.

04

Where records go

Provenance graph
Where records goPhase-start, phase-result, and phase-complete receipts populate events, the append-only authoritative log. Reviews and snapshots are immutable artifacts; manifests and projections are replaceable views. Evidence paths are resolved separately.Phase-startBefore the child runsPhase-resultPersist the outcomePhase-completeParent verificationevents/ · append-onlyAuthoritative phase receiptsReviews + snapshotsImmutable outputs / referencesManifest + projectionsReplaceable current viewsEvidence referenceResolve its route separatelyImmutableReplaceable

Append-only events are authoritative. Reviews and snapshots remain immutable; manifests and projections are replaceable. Evidence uses its separately resolved route.