agentleFS
arcasilesgrouparcasilesgroup/ai-engineering/skills/ai-adversarial-loop/SKILL.md

ai-adversarial-loop

Skill65 starsChanged 2 months agoApache-2.0View on GitHub

Coordinate a multi-round debate between two agents until the code is clean. adversarial-reviewer (the critic) assumes everything is wrong; fixer implements fixes or disputes them with evidence. They exchange findings through a shared thread file, and each keeps its memory across rounds. Use as the orchestrator's review gate, or when the user asks for an adversarial review-and-fix loop on recent changes (e.g. "/ai-adversarial-loop", "have the critic and fixer go at checkpoint 3").

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 2 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Critic, round 1: start adversarial-reviewer with the scope, the thread path and "Debate mode, round 1".

    line 19
  2. Very specific:

    Fixer, round N: start fixer with the thread path, the scope and "round N".

    line 20
  3. Very specific:

    Round cap: after 4 critic rounds without a PASS, stop the loop.

    line 29
  4. Distinctive:

    Re-check after fixes: if the fixer changed any code, the orchestrator re-runs Gate 1 (behavior) and Gate 2 (UI) before it marks review …

    line 42
  5. Distinctive:

    Read by: ai-orchestrator, humans Dies: when the review gate passes or the loop stops Next: none

    line 48

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Adversarial loop

You are the coordinator. You run in the main session because only the main session can start and resume agents. Subagents can't launch other agents, and agent-team teammates can't be the lead. You never review code or fix it yourself, and you never read the thread file. You pass turns between the two agents and act on their short returns.

Setup

  • Thread file: under /ai-orchestrator, it's .ai-engineering/workflow/reviews/<slug>-<id>.md. Standalone, it's .ai-engineering/workflow/reviews/<topic>-<YYYY-MM-DD>.md. Create it with a header: the checkpoint's goal and acceptance criteria (or the user's scope), the changed_files, and the verify commands. Nothing else.
  • Scope: the checkpoint slice and changed_files. Run from the selected checkout, whether that is the current checkout or its chosen worktree. Standalone, it's git diff HEAD plus untracked files, and the verify commands are the full test suite, lint and build from the Project config section of AGENTS.md.
  • Under /ai-orchestrator, prompts start with the gate markers: [checkpoint <slug>#<id> review] for the critic and [checkpoint <slug>#<id> fix] for the fixer.

Rounds (at most 4)

  1. Critic, round 1: start adversarial-reviewer with the scope, the thread path and "Debate mode, round 1". Keep its agent ID. If it returns VERDICT: PASS, you're done; go to the end.
  2. Fixer, round N: start fixer with the thread path, the scope and "round N". On later rounds, resume the same fixer with SendMessage and its ID: "Round N: the critic has ruled, see the thread." Add its FILES to changed_files.
  3. Critic, round N+1: resume the same critic with SendMessage: "Round N+1: the fixer has responded, see the thread. Verify, rule, and attack the new changes."
  4. VERDICT: PASS ends the loop. Otherwise repeat from step 2.

Unlike the orchestrator's "fresh workers" rule, each role here keeps its context: the critic remembers what it flagged, and the fixer remembers what it changed. They stay isolated from each other and from you, and the thread file is the only thing they share.

Deadlock and the round cap

  • Deadlock: if a finding is upheld twice after a dispute, the two agents disagree. The critic flags this in its return as DEADLOCK: F<n> (you never read the thread, so that line is how you know). Start a fresh general-purpose arbiter. Give it only that finding's block from the thread, the files it cites, AGENTS.md and DECISIONS.md. It rules critic or fixer and writes **Arbiter:** <ruling, why> into the thread. If it rules for the fixer, it marks the finding withdrawn. If it rules for the critic, the fixer must fix it next round and can't dispute it again.
  • Round cap: after 4 critic rounds without a PASS, stop the loop. Under /ai-orchestrator, that's a failed review attempt, so hand back to its failure path. Standalone, report the open findings to the user.

At the end

  • Learnings: for every LESSON: line the fixer returned, and every arbiter ruling, append a Log entry to LEARNINGS.md with gate review. Disputes the critic withdrew are learnings for the critic; tag them review-noise.
  • Commit (under /ai-orchestrator, per its Commits table): the thread file and the fixer's FILES. Use fix(<slug>#N): adversarial round <k> after each fixer round, and gate(<slug>#N): review passed at the end.
  • Return (to the orchestrator, or tell the user), in at most 6 lines:
    • PASS or FAIL;
    • the number of rounds;
    • resolved, withdrawn and arbitrated counts;
    • the open findings, only if it failed;
    • changed_files;
    • the thread path.
  • Re-check after fixes: if the fixer changed any code, the orchestrator re-runs Gate 1 (behavior) and Gate 2 (UI) before it marks review passed. The critic has already verified these changes, so the loop isn't re-run unless one of those gates fails.

Lifecycle

Lane: standard, full Writes: .ai-engineering/workflow/reviews Read by: ai-orchestrator, humans Dies: when the review gate passes or the loop stops Next: none

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.