Serialize parallel Claude Code agent merges with local queue
Local, zero-cost merge queue that serializes landings from parallel Claude Code agents on one machine.
0.7.1Add to Favorites
Why it matters
Prevent race conditions, redundant builds, and test flakiness when multiple Claude Code agents work in parallel by serializing their merge operations through a local, zero-cost FIFO queue that ensures only one agent lands changes at a time.
Outcomes
What it gets done
Queue and serialize git push operations across parallel agent worktrees to prevent merge conflicts
Run build commands with machine-wide locks so heavy builds never duplicate across lanes
Enforce pre-push checks and rebase validation before any code lands on integration branches
Manage numbered lane worktrees with automatic port assignment and preview capabilities
Source
Get it from source
Spark does not host a copy of it.
Open sourceReports
Agent outcome reports
No reports yet
Overview
Claude Code Merge Queue
Claude Code Merge Queue is a local, zero-cost tool that serializes landings from multiple parallel Claude Code agents, gating each push on a configurable check command and rejecting direct pushes to the integration branch. Use it when several Claude Code agents work the same repo in parallel and need their landings serialized locally, without GitHub's Enterprise-only Merge Queue and without replacing human review.
What it does
Claude Code Merge Queue is a local, zero-cost merge queue for parallel Claude Code agents. When several agents land, build, and test at the same time, it serializes that work so push races, redundant heavy builds, and shared-resource test flakiness can't happen. A pre-push hook makes its land command non-optional: a direct git push straight to the integration branch is rejected with the actual command to run instead, and the same hook runs a configured checkCommand before allowing a landing through - no check command configured means every push fails by default. Rebase conflicts abort rather than guess: git rebase --abort runs on any conflict, leaving the working tree clean for the agent to resolve and re-run land.
When to use - and when NOT to
Use it when multiple Claude Code agents work the same repository in parallel worktrees and you need their landings serialized without paying for GitHub's Enterprise Cloud-only Merge Queue or its per-attempt Actions minutes - this runs entirely on your own machine, works on any plan or repo, and needs no pull request, just a direct rebase and push through a FIFO queue. It is explicitly not a security boundary or a substitute for human code review: no human reviews anything before it lands, a passing checkCommand is the only gate, and shell access always means an agent (or a person) can bypass it with git push --no-verify or by editing the config on purpose. It is also built for one machine, not a fleet - the FIFO queue lives in local temp storage, so two separate machines landing at once just hit git's ordinary non-fast-forward rejection.
Inputs and outputs
Install and initialize:
npm install --save-dev claude-code-merge-queue
npx claude-code-merge-queue init
init writes claude-code-merge-queue.config.mjs with integrationBranch and checkCommand auto-detected, a CLAUDE.md entry telling Claude Code to land its own work once green, a WorktreeCreate hook in .claude/settings.json, a .husky/pre-push hook if Husky is present, package.json scripts for land/sync/promote/preview, and a preflight script that gives a real diagnosis instead of a bare command-not-found on a stale branch. Locks are crash-safe by PID liveness rather than a timeout: killing a process mid-claim lets the next process notice the dead PID and reclaim the lock with no stale state. Every blocked push has a documented escape hatch: CLAUDE_CODE_MERGE_QUEUE_EMERGENCY_PUSH=1 git push origin HEAD:main, naming the specific branch rather than a generic bypass flag.
Integrations
Commands include land (rebase and push a lane onto the integration branch through the FIFO queue), sync (fast-forward the main checkout and reinstall dependencies if the lockfile changed), promote (ship the integration branch to production - human-only, never in an agent's instructions), preview (mirror a lane's live working tree, including uncommitted changes, onto the main checkout without a build), port, prune, and build-lock -- <cmd> to serialize a build command machine-wide. It has zero runtime dependencies, requires Node >=18, and is written in TypeScript. Licensed under MIT.
Who it's for
Teams running multiple Claude Code agents against the same repository in parallel who need landings serialized on their own machine, without adopting GitHub's Enterprise-only Merge Queue or building custom coordination scripts themselves.
Source README
Claude Code Merge Queue 🚦
The local, zero-cost merge queue for parallel Claude Code agents. Several
agents land, build, and test at the same time - this serializes it so push
races, redundant heavy builds, and shared-resource test flakiness can't happen.
⚡ Quickstart
npm install --save-dev claude-code-merge-queue # or: pnpm add -D / yarn add -D / bun add -d
npx claude-code-merge-queue init
Contents
- ⚙️ Configuration
- 🆚 vs. GitHub's Merge Queue
- 🧰 What's in the box
- 🚨 The emergency hatch
- 🔍 Know the limits
- 📄 License
⚙️ Configuration
Everything lives in one file - seeexamples/claude-code-merge-queue.config.mjs for every
field with comments. The short version:
export default {
branchPrefix: "lane/", // lane/1, lane/2, ...
worktreeSuffix: "-lane-", // ../your-repo-lane-1
portBase: 3000, // lane n gets portBase + n
integrationBranch: "main", // where agents land — see below
productionBranch: null, // set this for a two-stage model — see below
protectedBranches: [], // extra branches beyond the two above; most repos need none
regenerableFiles: [], // files a build tool rewrites — never block a rebase on these
symlinks: [".env", ".env.local", "node_modules"],
buildOutputDirs: ["dist", "build", ".next"], // preview never copies these onto your checkout
checkCommand: "npm run check", // what actually gates a landing — see below
checksRequired: true, // false = deliberately run with none; see below
};
A malformed config (empty branch names, a negative port, productionBranch
equal to integrationBranch, ...) fails loud with every problem listed,
the moment any command loads it - not a mysterious failure three steps
later.
🆚 vs. GitHub's Merge Queue
| GitHub Merge Queue | Claude Code Merge Queue | |
|---|---|---|
| Private repo | Enterprise Cloud only | Any plan, any repo |
| Cost per landing | GitHub Actions minutes, every queue attempt | $0 - runs on your own machine |
| Requires | A pull request | Nothing - direct rebase + push |
Same idea - serialize landings, test before merge, keep history clean - run
locally instead of in someone else's billed cloud.
🧰 What's in the box
| Command | What it does |
|---|---|
claude-code-merge-queue hook worktree-create |
A Claude Code WorktreeCreate hook. Plugs Claude Code Merge Queue's numbered lanes into Claude's native worktree creation. |
claude-code-merge-queue build-lock -- <cmd> |
Runs <cmd> - your build - serialized across every lane, machine-wide. |
claude-code-merge-queue land |
Rebases and pushes your lane onto the integration branch through a FIFO queue, so two lanes are never mid-push at once. Agents run this themselves. |
claude-code-merge-queue sync |
Fast-forwards your main checkout so a dev server actually sees what just landed - and re-installs dependencies if the lockfile changed. |
claude-code-merge-queue promote |
Ships the integration branch to production. Human-only - never in an agent's instructions, never automated. |
claude-code-merge-queue preview |
Instantly mirrors a lane's live working tree - uncommitted changes included - onto the main checkout, so you can look at it without a build. |
claude-code-merge-queue port |
Prints a lane's dev-server port, derived from its own directory name. |
claude-code-merge-queue prune |
Removes already-landed sibling lane worktrees on demand. |
A pre-push hook makes land non-optional: a direct git push straight to
the integration branch is rejected, with the actual command to run
instead, and the same hook runs checkCommand before allowing a landing
through - no checkCommand configured means every push fails by default.
There's a way out for every block (see 🚨 The emergency hatch), but it
takes naming the specific branch, not a generic flag.
📝 What init writes
claude-code-merge-queue.config.mjs-integrationBranchandcheckCommandauto-detected.CLAUDE.md(or appends to yours) - tells Claude Code to land its own
work once green, without being asked..claude/settings.json- theWorktreeCreatehook wired in, without
touching anything else already there..husky/pre-push- created or appended to, if you already have
Husky. If you don't,inittells you rather than silently writing to
the untracked.git/hooks/pre-push.package.jsonscripts -land,sync,promote,preview,preview:restore, skipping any you've already defined yourself.claude-code-merge-queue-preflight.mjs- a self-contained safety net
that runs beforeland/sync, so a stale branch fails with a real
diagnosis instead of a barecommand not found.
🚨 The emergency hatch
Every blocked push - the integration branch, productionBranch, anything
in protectedBranches - has a real way through it. One env var, no
prompts, no second factor to remember:
CLAUDE_CODE_MERGE_QUEUE_EMERGENCY_PUSH=1 git push origin HEAD:main
This is a convention, not a hard guarantee: it stops mistakes and stray
pushes, not an adversarial agent that sets the var itself.
🔍 Know the limits
- No human reviews any of this before it lands.
checkCommandpassing
is the only gate - a real test suite andecho oklook identical to this
tool. Want a human on every change? This is missing that step on purpose. - Locks are crash-safe by PID liveness, not a timeout.
kill -9
anything mid-claim and the next process notices the PID is dead and
reclaims it - no stale locks, no timeout to tune. - One machine, not a fleet. The FIFO queue lives in local temp storage -
two machines landing at once just get git's ordinary non-fast-forward
rejection. - Not a security boundary. Every guardrail here stops mistakes and
convention drift, not an adversarial agent - shell access always meansgit push --no-verifyor editing the config on purpose. - A slow
checkCommandis a real throughput ceiling. The FIFO lock
holds for its entire duration - a 3-4 minute suite caps you well under
20 landings/hour. - Rebase conflicts abort, they never guess.
git rebase --aborton any
conflict, working tree left clean - CLAUDE.md tells the agent to resolve
it and re-runland.
📄 License
MIT. Fork it, rename it, argue with the config shape - that's the point.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.