Agentic Pattern Libraryby Vikas Goyal
← All patterns
60

PR Steward Loop

Also known as: PR babysitter, post-PR watch, PR shepherd

After a pull request is opened, an agent watches it and handles the follow-up work (failing checks, conflicts, review comments) while escalating anything that needs the author's judgment.

TrackAI-native software delivery FamilyVerify Maturity Emerging ChangesVerificationDecision
01

Problem

Opening a pull request is rarely the end of the work. Checks fail, the base branch moves and causes conflicts, and reviewers leave comments, often hours apart. Each item is small, but each one pulls the author back from other work and costs a context switch. With coding agents producing more PRs, this follow-up becomes a large hidden share of an engineer’s day, and PRs sit waiting for the author instead of for review.

  • Follow-up tasks are small but arrive at unpredictable times.
  • Some comments are mechanical; others are design questions only the author can answer.
  • An agent working unattended must not merge, force-push or widen the change.
  • Repeated failed fixes waste money and hide a wrong approach.
02

Solution

Hand the open PR to an agent that watches it for a bounded period, such as up to a week, and stops when the PR is merged or closed. On each event it acts within strict limits. Failing checks are reproduced and fixed. Conflicts are resolved by merging the base branch and rerunning tests. Review comments are answered with a fix or a reply, and comments from bots are treated as claims to verify against the code, not instructions. Anything larger, such as a redesign, a new API, wider scope or an unresolved security concern, is escalated to the author. The agent tries at most a few pushes per issue, then reports what it tried. It never approves or merges, and the author stays responsible for the change.

03

Diagram

Open PRwatch ≤ 7 days failing check base conflict review comment Stewardsmall or large?≤ 3 tries Fix + test + pushlint · conflicts · small fixes Escalate to authorredesign · new API · security Human approvessteward never merges push updates the PR

The steward handles small follow-up work on its own and escalates anything that needs judgment. Approval and merge stay with people.

04

When to use

Use it when

  • Engineers lose time to CI failures, conflicts and small review fixes
  • PRs often wait on the author rather than the reviewer
  • Repos have reliable tests and branch protection
  • Everyone who can change the base branch is trusted

Avoid it when

  • PRs in the middle of a design debate the team must settle
  • Repos where untrusted people can land code the agent will run
  • Projects without tests, where "fixed" can't be checked
05

Trade-offs

Latency PR is already updated when the author returns
Cost Agent turns for every event over days
Complexity Event watching, limits, escalation rules
Reliability Tests gate every fix; escalation on hard cases

Gains

  • Fewer context switches for the author
  • PRs stay green and up to date while waiting for review
  • Repeated failures surface as a report instead of a silent loop

Costs

  • Runs with the author's credentials, so trust boundaries matter
  • Spend accumulates over a multi-day watch
  • Authors may stop reading what was changed on their behalf
06

Worked example

Scenario
An engineer opens a PR adding CSV export to the Linkwatch reports page, then goes to a 3-hour planning session. The steward (for example, a `/ship` or `/steward` command) watches the PR.
  1. CI failsA lint rule flags an unused import. The steward removes it, runs the fast checks locally and pushes.
  2. Base movesAnother PR changes the same reports module. The steward merges the base branch, resolves a small conflict, reruns the tests and pushes.
  3. Bot commentA security bot claims the export leaks user emails. The steward checks the code, finds emails are already masked, and replies with the file and line.
  4. ReviewerA reviewer asks for streaming instead of building the whole CSV in memory. That changes the design, so the steward escalates to the author with a short summary.
  5. Author returnsThe PR is green and conflict-free. The author decides on streaming, makes the change, and a human approves and merges.
07

Failure modes

FailureSymptomMitigation
Scope creepSteward rewrites large parts of the PR to satisfy a commentSize limits per fix; escalate redesigns and new APIs
Fix loopSame check fails after push after pushCap attempts per issue (for example, 3) and report what was tried
Trusting comment textA bot or outsider comment steers the agent into a bad changeRead comments only from trusted authors; verify bot claims against code
Agent mergesChange lands with no human approvalBlock merge and force-push in tooling; require human approval in branch rules