Skip to content
Episode 164 · Ninety-six pull requests a week

Parallel agents and quality gates

Wednesday, 11:00, week 7. Every engineer now runs two or three Claude Code sessions. Pull requests went from 31 to 96 a week. Twenty-three are waiting for review, main broke twice, and Atlantica just emailed Karim: a £200 London room shows as €274.

Several agents at once can write a lot of code. But people still review it, and changes that are fine alone can break together. Here's how to run them in parallel safely.

30 min advancedIsolating parallel agent sessions (branches, worktrees, boundaries)Review capacity as the real bottleneck (WIP limits)Required CI checks as merge gatesMerge discipline: main always green, tested togetherOne branch per agent taskPull requests, code review & small batches
  1. Problem

    Week 7 of StayHub for Chains. Each of 8 engineers runs 2–3 Claude Code sessions in parallel. Pull requests opened went from 31 to 96 a week; 23 are waiting for review, the oldest for 6 days, and main broke twice this week.

  2. Why the simple system fails

    More sessions produce more code, but review capacity stays at about 80 careful reviews a week, so the queue grows forever. Sessions working on the same concern in different files merge cleanly and break together; each PR was green alone, and main wasn't.

  3. Engineering concept

    Parallelism needs isolation (one task, one branch, one worktree, one area), automated gates that every merge must pass, review treated as the real bottleneck (WIP limits, smaller PRs, gates that remove mechanical review), and merge discipline (test changes together, main always green, revert first).

  4. Technology

    Git branches and worktrees, Claude Code sessions and sub-agents, CI with required status checks, branch protection, CODEOWNERS, merge queues, WIP limits.

  5. Trade-offs

    More parallel sessions raise output until review saturates, then only raise waiting time and risk. Strict gates slow each merge a little but keep main trustworthy; loose gates feel fast until the day main breaks under everyone.

01

The problem

2 min
Week 7, Wednesday, 11:00. Every engineer now runs two or three Claude Code sessions. Pilot in 5 weeks.
  1. You · Engineer at StayHub
    Pull requests opened went from 31 a week to 96.
  2. Omar · On-call SRE
    23 are waiting for review, the oldest for 6 days. Main was red twice this week.
  3. Karim · CTO
    Then give everyone five sessions. We need the speed.
02

The big idea

4 min
More sessions, more waiting
The big idea

Review capacity, not agents, sets your speed. Isolate sessions, let machines guard main, and keep work in progress below what people can review.

Five more cooks make dishes faster, but every plate still goes through one pass where the head chef checks it. Plates pile up and go cold, or get waved through. The pass is your review.

03

How it works

5 min

The sum first. A careful review takes ~30 minutes; eight engineers at ~1 hour a day: 8 × 5 × 1 h = 40 h ≈ 80 reviews a week. Then five rules.

Rules for parallel work
  1. 1
    Isolate by folder and concern

    A is a separate folder on its own branch of the same repository: one task card, one worktree, one session. And one owner per concern (currency, timestamps) each week, in any file.

  2. 2
    Research freely

    A researches with its own context and reports back. Read-only sessions create no PRs: run as many as you like.

  3. 3
    Cap work in progress

    A caps work in progress: at most 2 open PRs per engineer. A third editing session waits until one merges.

  4. 4
    Gate with machines

    Required CI, CODEOWNERS approval, branch protection. Mechanical checks leave reviewers: ~20 minutes per review, ~120 a week.

  5. 5
    Merge together, keep main green

    A tests each PR with those ahead of it before it lands. Staging deploys only from green main. Main red: stop merging, revert first.

04

Watch a decision being made

4 min
Worked example

You turn 23 waiting PRs into a flowing pipeline

Make parallel agent work safe and fast before the pilot.

  1. 1Measure the bottleneck

    Arrivals 96/week; capacity ~80/week; queue +16/week; 23 waiting, oldest 6 days.

    Why: Without the sum, "more sessions" sounds like more output. With it, it's obviously more waiting.

  2. 2Isolate sessions

    One task card → one branch → one worktree → one session. Each concern has one owning session this week.

    Why: Worktrees stop file clashes; owners per concern stop meaning clashes.

  3. 3Move mechanical review to gates

    Required CI on pull_request and merge_group: types, lint, boundaries, tests, migrations, log-PII. CODEOWNERS for src/rates, src/payments, db/migrations.

    Why: A review drops to ~20 minutes; capacity rises to ~120/week.

  4. 4Cap WIP and drain the queue

    2 open PRs per engineer; research unlimited. This week, reviews before new sessions; the two oldest PRs closed and re-cut smaller. Lina's only check: "And the 23 waiting now?"

    Why: Arrivals must stay below capacity, or nothing else matters.

The whole thing in one line: Review, not agents, limited delivery. Isolate by worktree and concern, gate with machines, cap WIP below capacity, and make main's health non-negotiable.
05

In real life

3 min
People as the gate, or machines first?

Linux kernel: maintainers

  • Maintainers per subsystem
  • Patches reviewed by people
  • Passed up a chain of trust

Human judgment is the main gate.

Google: checks + owners

  • One huge repository
  • Automated checks on every change
  • Code owners must approve

Machines first, then owners.

06

What goes wrong

3 min
Two sessions on one concern

No conflict, combined bug.

Instead

One owner per concern each week.

PRs tested only against old main

Green alone, red together.

Instead

A merge queue, or up-to-date branches required.

Deploying before CI, merging on red

Partners test a broken build; the cause gets buried.

Instead

Deploy only from green main; stop and revert first.

07

Trade-offs

3 min
ParallelismFits whenYou pay
Maximum sessionsRead-only research, or idle reviewersQueue explodes; collisions
Matched to review capacityAlmost always for code that shipsSome idle agent time
One session eachVery risky areas, teams new to agentsLeverage unused
Week 7, Wednesday, 14:00. You present the rules.
  1. Karim · CTO
    Two open PRs per person? Five weeks left. Five sessions each, let CI sort it out.
  2. Omar · On-call SRE
    After Tuesday? One session each and no merges without me watching.
  3. Karim · CTO
    That's a freeze five weeks before the pilot.
08

Your job as tech lead

4 min

Claude Code can write the code for this. You still own the decisions, and you have to know what good looks like to accept or reject its work.

Decisions you own
  • How many editing sessions run at once, set by review capacity (2 open PRs per engineer).
  • Which session owns each concern this week, so no two change the same meaning in different files.
  • Which checks are required, merge queue on, staging only from green main, and who reverts when main goes red.
Tell Claude Code
You're in worktree ../stayhub-ari-14 on branch chains/ari-14, task card ARI-14.md. You own only src/chains/ari; currency conversion belongs to another session this week, so don't add or change any conversion; tell me instead. First, a sub-agent lists where src/chains parses CRS timestamps. Then plan, implement, run pnpm check and pnpm test:chains. Open a PR only when both pass, listing every changed file.
Check before you accept
  • Each session has its own worktree, branch and task card naming one area.
  • The PR touches only its card's area; anything in another concern is reverted or flagged.
  • Fridays: PRs waiting, oldest age, arrivals vs reviews. Over capacity? Lower WIP before adding sessions.
Red flags
  • A session "helpfully" fixing something in another session's concern.
  • PRs merged while main is red, or staging deploying before CI finishes.
  • Open PRs and wait times rising while more sessions start.
09

Check yourself

2 min
Q1/3Debugging
Session A added GBP→EUR conversion in the mapper; session B added the same conversion in the batch applier. Different files, both PRs green, merged 40 minutes apart. What happens?
How confident are you?

Next: rewind to week 5, when chain invoicing ran into StayHub's oldest code, written years ago by people who have left. First, understand it with an agent.

Finished?

Mark it complete to update your skill map.

Go deeper (optional)You don't need this to understand the lesson. Open it when a project needs the details: Technical deep dive, Visual diagram, Analogy, Why it matters, Check your understanding, Practice ladder, Explain it yourself.
10

Technical deep dive

Isolation and gates
Worked example

From 23 waiting PRs to a flowing pipeline

Make parallel agent work safe and fast for the chains squads before the pilot: isolate sessions, gate merges, and fit work to review capacity.

  1. 1Measure the bottleneck

    Arrivals 96/week; careful review ~30 min; ~1 h/day per engineer → ~80/week. Queue grows ~16/week; 23 waiting, oldest 6 days.

    Why: Without the sum, "more sessions" sounds like more output. With it, it's obviously more waiting.

  2. 2Isolate sessions by folder and concern

    One task card → one branch → one worktree → one session. Each week, every concern (currency, timestamps, hotel mapping) has one owning session. Task cards already name one area.

    Why: Worktrees stop file clashes; owners per concern stop meaning clashes like Tuesday's double conversion.

  3. 3Move mechanical review to gates

    Required CI on pull_request and merge_group: check (types, lint, boundaries), full tests, migrations:verify, log-PII. CODEOWNERS for src/rates, src/payments, db/migrations. Branch protection on main.

    Why: Reviewers stop checking what machines can; a careful review drops to ~20 min, capacity rises to ~120/week.

  4. 4Cap work in progress

    Max 2 open PRs per engineer; research sessions and sub-agents unlimited. This week: reviews before new sessions; the two oldest PRs closed and re-cut smaller.

    Why: Arrivals must stay below capacity, or nothing else matters.

  5. 5Set merge discipline

    Merge queue on. Staging deploys only from green main. Main red → stop merging, revert, then fix on the branch with a test for the failure.

    Why: Tuesday's cascade came from staging before CI and three merges on a red main.

The whole thing in one line: You found that review, not agents, limited delivery; isolated sessions by worktree and by concern; moved mechanical checks into required gates; capped work in progress below capacity; and made main's health non-negotiable.
Tuesday's failureGate or rule that stops it
Two sessions on the same concernOne owner per concern each week
Each PR tested against old mainMerge queue (merge_group CI)
Staging deployed before CI finishedStaging deploys only from green main
Three merges on a red mainRed main → stop merging, revert first
Long queue, rushed reviewsWIP limit of 2 open PRs per engineer
11

Visual diagram

Click a component

Parallel sessions, isolated, flowing through gates into a main that stays green.

12

Analogy

  • Restaurant with one passMore cooksParallel agentsMore agent sessions
  • Restaurant with one passOwn station eachParallel agentsOwn worktree and branch
  • Restaurant with one passThermometer and scalesParallel agentsAutomatic checks
  • Restaurant with one passHead chef at the passParallel agentsHuman review
  • Restaurant with one passTaste dishes togetherParallel agentsMerge queue

Where it breaks: a cold plate is obvious. A broken combination of code changes can look perfectly fine until a guest sees the wrong price.

13

Why it matters

Waiting code isn't progress. Twenty-three changes waiting six days lose their context and start conflicting with each other.

Fine alone isn't fine together. Two sessions each added a currency conversion in different files. No warning from Git. A £200 London room showed as €274 to Atlantica.

A broken main stops everyone. Every new branch starts broken, and people learn to ignore red.

Rushed reviews let bugs through. When the queue is long, people skim. That's when incidents slip in.

14

Check your understanding

Q1/3Design
Why run each parallel Claude Code session in its own git worktree?
How confident are you?
15

Practice ladder

Step 1 · Trace

Which sessions collide?

Debugging Warm-up

Tomorrow's sessions, each in its own worktree:

  • A: in src/chains/ari/mapper.ts, parse CRS timestamps as the hotel's local time (Atlantica sends local times).
  • B: in src/chains/ari/mapper.ts, normalise room codes to upper case.
  • C: in src/chains/applier/batch.ts, drop an update if it's older than the stored one, comparing timestamps as UTC.
  • D: a read-only sub-agent listing every place src/chains parses or compares timestamps.
  • E: a new monthly report in src/chains/reports.

Trace each pair that could clash: textual (Git conflict), semantic (merges cleanly, breaks together), or safe. What do you change in the plan?

Step 2 · Complete

Complete the gates

Design Practice

Fill the blanks in the rules for main.

RuleSetting
No direct pushes___
CI on every PR and on the combined changesCI triggers: ___ and ___
CI jobspnpm check, ___, ___, ___
Payments, rates and migrations reviewed by their experts___ + required review
Changes tested together before landing___
Partners never see a broken buildStaging deploys only ___
Main red___, then ___, then fix on the branch
Arrivals below review capacity___ open PRs per engineer
Step 3 · Solve

Capacity after the pilot

Estimation Stretch

After the pilot, two engineers join: 10 in total. Each runs agent sessions; PRs arriving are forecast at 140 a week for the rollout to 420 hotels. A careful review takes ~30 minutes today; each engineer can spare ~1 hour a day for reviews.

Without help: (1) compute review capacity and the gap; (2) propose at least three changes and estimate their effect; (3) say what you'd tell Karim about adding more sessions.

Step 4 · Decide

Turn off reviews for the last week?

Decision Stretch

Week 11, pilot next Thursday. 31 PRs are waiting. Karim: "Turn off required review for src/chains until the pilot. CI is green on all of them, and the gates you built catch the mechanical stuff."

The 31 PRs: 12 are needed for the pilot (S5 bookings back, S6 hardening), 19 are improvements for later (reports, refactors, M2 prep). Options: (1) Karim's: disable required review for src/chains for a week; (2) keep reviews, freeze non-pilot PRs, review the 12 first, borrow two reviewers from the Search team for the week; (3) delay the pilot by a week.

Write your decision: "We chose X over Y because…, accepting the risk of…".

16

Explain it yourself

Karim asks: "Agents are cheap. Why not give every engineer ten sessions?" Answer with the numbers from week 7.

0 words