Adversarial loop
SkillFiles & storageCoordinate 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").
Instructions available. Your AI can read the instructions. Execution depends on the setup they require.
Account requirements not reviewed. Check the skill instructions before use; ahel provides instructions and does not run this skill.
Add ahel to your AI once: Claude, ChatGPT, Cursor, Claude Code or Codex. Then ask it to use this.
Then ask your AI: use the Adversarial loop skill
What this skill tells your AI
The instructions your AI receives, as published by arcasilesgroup/ai-engineering in skills/ai-adversarial-loop/SKILL.md and read by ahel’s review.
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), thechanged_files, and the verify commands. Nothing else. - Scope: the checkpoint slice and
changed_files. Standalone, it'sgit diff HEADplus untracked files, and the verify commands are the full test suite, lint and build from the Project config section ofAGENTS.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)
- Critic, round 1: start
adversarial-reviewerwith the scope, the thread path and "Debate mode, round 1". Keep its agent ID. If it returnsVERDICT: PASS, you're done; go to the end. - Fixer, round N: start
fixerwith 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 itsFILEStochanged_files. - 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."
VERDICT: PASSends 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
upheldtwice after a dispute, the two agents disagree. The critic flags this in its return asDEADLOCK: F<n>(you never read the thread, so that line is how you know). Start a freshgeneral-purposearbiter. Give it only that finding's block from the thread, the files it cites,AGENTS.mdandDECISIONS.md. It rulescriticorfixerand writes**Arbiter:** <ruling, why>into the thread. If it rules for the fixer, it marks the findingwithdrawn. 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 toLEARNINGS.mdwith gatereview. Disputes the critic withdrew are learnings for the critic; tag themreview-noise. - Commit (under
/ai-orchestrator, per its Commits table): the thread file and the fixer'sFILES. Usefix(<slug>#N): adversarial round <k>after each fixer round, andgate(<slug>#N): review passedat 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
Signals
- GitHub stars
- 59
- Forks
- 3
- Last commit
- Oct 2026
Advanced
- Item type
- skill
- Key
ai-adversarial-loop- Source
- github.com/arcasilesgroup/ai-engineering
github.com/arcasilesgroup/ai-engineering