Six agents used git stash in their own worktrees. The stash stack is one per repository.

Running a multi-agent engineering programme, the same four things kept costing time or causing risk.

Six agents used git stash in their own worktrees. The stash stack is one per repository, shared by every worktree and every session, so a pop can take another agent's changes. Nothing was lost that day, but only an hour of forensic work proved it.

Every tranche merge was the same manual loop: cherry-pick the agent's commits, run the gate test files one at a time because the full suite hung, then work out by hand which failures were new and which were already red.

Agent worktrees were sometimes cut from a stale checkout instead of the branch head.

And agents cannot see their own token usage. The figure arrives only in the completion notification, so heavy agents went unnoticed until the bill.

Tranche Flow is that loop made mechanical and safe, for any session that orchestrates work through subagents in git worktrees.

The Tranche Flow repository on GitHub at its first release

What it does

Stash guard. git stash and git stash pop in any Bash call are refused with a message that names the alternative: a temporary WIP commit, or git diff <sha>. git stash list and git stash show stay allowed. The guard applies to the session and every subagent, and it fails closed if its own code errors. Set allowStash: true in the plugin's config to lift it.

Worktrees from the head. /worktree-new <name> [base] creates a worktree under the configured root on a new branch cut from the base branch's current head, never from whatever happens to be checked out.

A merge that classifies. /merge-tranche <branch> [extra test files...] refuses to run on a dirty checkout, cherry-picks the branch's commits and aborts cleanly on conflict, runs each gate test file with a timeout, and classifies every file as NEW, PRE-EXISTING, FIXED or GREEN against a stored baseline. Results go to a timestamped JSON file under .claude/. It never deletes anything and never force-pushes; a conflict leaves the checkout as it was.

An agent ledger. Every Agent launch and every task notification is recorded with its description, tokens, tool uses and duration. An agent over the token flag is notified at once. /agent-ledger prints the table, and the ledger is appended to .claude/agent-ledger.jsonl.

Setup

Per project, every key optional:

{
  "baseBranch": "dev",
  "worktreeRoot": ".claude/worktrees",
  "testCommand": "python -m pytest {file} -q -p no:cacheprovider",
  "testTimeoutSeconds": 300,
  "gateTests": ["tests/unit/test_binding.py", "tests/unit/test_composition.py"],
  "baselineFile": ".claude/tranche-flow-baseline.json"
}

The baseline file maps each test file to its known-good failed and errors counts. Without it, every red file reads as NEW. The token flag, 300,000 by default, and allowStash are set in the plugin's config menu. It needs git, sh and a timeout binary on the path.

Installing it

Install once, at the user scope, from a Claude Code session:

/plugin install tranche-flow --marketplace William-Harvey/tranche-flow

Answer yes to add the marketplace, then pick the scope. From a shell:

claude plugin install tranche-flow --marketplace William-Harvey/tranche-flow

In the desktop app, click the plus next to the prompt box, choose Plugins, add the marketplace William-Harvey/tranche-flow, then add the plugin. To try it without installing:

claude --plugin-dir <path to the plugin folder>

Commit the project's config file with the project so every session and subagent sees the same values. Start a session in the project and the commands appear under /, with the hooks active for the session and every subagent it launches.

Why I'm sharing it

Every team that lets Claude Code delegate to subagents in worktrees will hit the same three failures I did: a shared stash stack, red tests nobody classifies, and agent cost that is only visible after the fact. None of them is specific to my codebase. The plugin carries no project knowledge; the project supplies a six-line config. If it saves one team the hour of git forensics I spent proving nothing was lost, it has paid for itself.

It is on GitHub under the MIT licence at github.com/William-Harvey/tranche-flow.