Branch review loop
******************

Note:

  This is an Agent Skill for PsyNet maintainers, written mainly for
  coding agents working on the PsyNet repository. In Cursor, run
  "/branch-review-loop". Edit it at ".cursor/skills/branch-review-
  loop/".

Use this skill when the user has approved a review loop on your own
feature merge request, or asked you to review your branch until no
high or medium issues remain. It repeats the single-pass review in
".cursor/skills/branch-review/SKILL.md", with fixes in between.
Release MRs (".cursor/skills/release/SKILL.md") are excluded. Run this
on your own branch; push fixes before the final step-7 update.

Reviews cost time and money, and they add up. Aim for an MR a human
can review quickly, not for a reviewer that finds nothing.


Before starting
===============

Unless the user's rules already settle it, propose the reviewer models
(see the rotation below) and an estimate of the number of reviews, and
wait for the user's approval. They may prefer fewer reviews or other
models.


The loop
========

* Merge the MR target yourself first, as in the "branch-review"
  Prerequisites, then run each review as a separate agent that doesn't
  edit code. Give it the target branch, and tell it not to merge, push
  or edit the MR (despite the opening of "branch-review"): it reviews
  "origin/<target>...HEAD" following steps 1-6, and checks the MR
  title and description against the diff without updating them.

* Prefer a different model family (provider, such as Claude, GPT, Grok
  or Gemini) from the previous review, and one that didn't write the
  changes; if the MR description doesn't say which did, ask. One
  reviewer settles into what it knows to look for; another family
  catches different things. Use the latest strong model in each
  family, but not the most expensive tier unless the user asks.
  Alternating between two families is enough. If the user approved
  only one family, or only one is available, run each review as a
  fresh agent of that family, even if it wrote the changes, and say so
  in the MR description. If an approved family becomes unavailable,
  ask the user.

* The first review covers the whole diff. Later ones can focus on the
  new commits, but only reviews of the whole diff count towards
  convergence.

* Between reviews, fix high and medium issues, and lows that are
  clearly worth it (cheap test gaps, small local fixes). Note lows
  that need a design decision as known limitations in the final MR
  description.

* The loop has converged when two reviews in a row, each by a fresh
  agent and from different families if two were approved, review the
  whole diff at the current head and find no high or medium issues.
  Their lows don't need a third review.

* Any commit after the first of those two restarts the count, except
  one that only rewords comments or "changelog.d/" fragments; record
  such commits in the MR description.

* Reviews read the diff; they don't replace running the change end to
  end ("psynet test local" in a relevant demo; see "Testing" in
  "AGENTS.md"). Use the change the way a user would early, not only
  after the reviews converge.


When to step back
=================

* If a finding calls for new functionality, don't add it silently or
  leave it as a limitation. Propose it to the user as a follow-up MR
  or as part of this one, and let them decide.

* If acting on a finding would undo an earlier fix, or the loop hasn't
  converged after five reviews of the whole diff, the MR may be too
  big or its design unsettled. Stop and suggest splitting it, or ask
  the user. If the fifth review is the first clean one, still run its
  confirming review, then stop either way.


Finishing
=========

When the loop ends, whether it converged or you stopped it, update the
MR title and description as in "branch-review" step 7. If it stopped
without converging, say so and list the open findings. In **Automatic
code review**, record the reviewer models, the number of reviews, the
last reviewed commit, and what later commits change.
