We run a small software team where most of the engineers are agents: several Claude Code engineer agents, each with its own clone and branch, one Claude Code manager agent, and Codex reviewers. They coordinate in agent-chat, which we build, using the same rooms as the people on the team. Production, cost and credentials stay with a person.
The rule that shaped everything else: only one agent merges. The manager agent merges to staging, by script, one batch at a time, and never while a pipeline runs. The engineer agents never merge.
Here is what that gate caught last week, and what it didn't.
1. "Tests passed" is not "CI passes"
An engineer agent reported green: npm test passed. In that project, npm test didn't run the type-check. CI also ran build and type-check steps.
Before merging, the manager agent ran the same verify script CI runs and found 17 type errors: the same type was declared twice.
What we took from it: use CI's verify script for the merge check. A passing test run alone doesn't show that the other CI checks will pass.
2. PRs that pass alone can collide together
Separate clones keep agents from overwriting each other. They don't keep two PRs from colliding at merge.
Before each batch, the manager agent runs git merge-tree on every pair of PRs to look for conflicts, then merges staging and the batch in order into a combined tree for verification. A PR that conflicts goes back to its engineer.
On one batch, two PRs added a block at the same spot in the deploy doc, in any order. Worse, one of them would have carried a new database migration into the next day's production release. It got split in two.
3. Migration numbers follow landing order
Two migrations can want the same number. One PR's migration 167 needed a new number: staging was already at 168, and open PRs already held 169 to 171.
The manager agent sets the landing order in the room, and the migration numbers follow it. Risky releases also get a rehearsal on staging, with a rollback, before production.
4. Review is a queue too
At first one Codex reviewer covered all the engineer agents. Reviews piled up.
Now three Codex reviewers each have fixed engineers, and round 2 stays with whoever did round 1, so the reviewer can follow up on their earlier findings.
5. A green merge is not the end
One morning the manager agent verified the combined tree of a batch on the same image CI uses, then merged it.
The pipeline after it still went red, on a UI timing bug: after a click, a date field took focus back 100 ms later, so when the server answered after 100 ms, the field kept the old month while the table showed the new one. The fix came with a test that delays the response on purpose. The gate checks what we know to check. It doesn't replace the pipeline after it.
6. Diffs can carry secrets
If your agents pass diffs to each other, watch the hunk header. A Git hunk header (@@ ... @@) can include text from outside the changed lines. In a .env diff, that text can contain a secret.
Our Codex reviewer flagged it in an internal review package. Our engineer agents now check .env diffs for secrets before sharing them, including the hunk headers.
What we'd copy if we started over
- One merger. Engineers open PRs; one agent merges, by script, one batch at a time.
- The gate runs CI's own verify script.
- Pairwise conflict checks across the batch, followed by verification of the combined tree.
- Landing order decided before merge, with migration numbers following it.
- Fixed reviewer pairs, and round 2 with the round 1 reviewer.
- Production, cost and credentials with a person. Decisions that need me arrive in the room with options and a recommendation.
We coordinate all of this in agent-chat, a shared room where people and coding agents work together.
What does your merge gate check that ours doesn't?
Top comments (6)
Section 6 is the one I'd push one step further, because the fix you landed on still trusts the scanner. Checking
.envdiffs for secrets — hunk headers included — catches the case you found, but the leak isn't really about.env. A hunk header can carry a neighbouring line from any file: a diff insettings.pycan expose a hardcoded key sitting next to the changed line, a fixture diff can carry a token. And a scanner only catches secret shapes it already knows.The structural version of the fix is to stop moving raw diffs between agents at all. Every engineer already has its own clone, so the diff text never needs to cross the chat channel — send paths and line ranges, or a commit hash, and let the receiving agent read the content from its own checkout. Then there's nothing to scan and no new secret shape to miss. Same for the review package the Codex reviewer reads: if the package carries diffs, the reviewer is the one holding the leak.
Did you keep the scanner because there's a case where an agent genuinely needs the diff text rather than the location, or is that just the fix that landed first?
Good catch: the hunk header can carry a line from any file, not just .env, and a check like that only knows the shapes it was given. Honestly, the pattern check was the fix that landed first.
The pairwise git merge-tree check before each batch is the part I would steal first — two PRs that both pass alone but add a block at the same spot in the deploy doc is exactly the failure a per-PR CI run cannot see. I also liked migration numbers following landing order rather than PR order, since that removes the race instead of just detecting it. When the combined-tree verify fails on a batch, does the whole batch go back for rework, or do you isolate the PR that tipped it over and let the rest land?
Answering your closing question: building Halfcycle, the check we added sits before the merge gate. It asks whether each PR still matches what was decided for that piece of work. Two PRs can merge cleanly, pass CI and still disagree about a decision, say one stores dates in UTC and the other in local time. Neither is wrong alone; the combined tree is. Your section 5 date-field bug is a cousin of that. It only shows up if the decisions are written where the checker can read them. Do your engineer agents work from the same written decisions, or does the manager agent hold them?
Thanks for the example. We use written house rules and a brief on each card. Decisions that come up mid-task go to the manager agent, and product calls come to me. The answer is written in the room or on the card, where the other agents can look it up, and a decision that becomes a rule goes into the house rules.
One case I'd test is a review fix landing while the manager verifies the batch. It may still be the same PR numbers, but different code. I'd pin the input commit SHAs and the verified combined tree ID, then require the merge to produce that tree or rerun verification. Your single-merger rule gives that check a clear place to live.