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").
In this repository41 other files it gives its agents.
- AGENTS.mdAGENTS.md
- a11y-auditSkill
- ai-agents-mdSkill
- ai-architectSkill
- ai-audit-codeSkill
- ai-audit-designSkill
- ai-audit-docsSkill
- ai-brainstormSkill
- ai-codegraphSkill
- ai-config-to-projectSkill
- ai-debugSkill
- ai-design-md-plannerSkill
- ai-exploreSkill
- ai-git-cleanupSkill
- ai-issue-reportSkill
- ai-noteSkill
- ai-orchestratorSkill
- ai-prototypeSkill
- ai-prSkill
- ai-read-docsSkill
- ai-researchSkill
- ai-review-uiSkill
- ai-securitySkill
- ai-stress-testSkill
- ai-test-plannerSkill
- ai-triageSkill
- ai-verifySkill
- ai-visual-recapSkill
- ai-writeSkill
- ai-writing-behaviorSkill
- build-checkSkill
- code-auditSkill
- design-checkSkill
- feature-verifySkill
- full-reviewSkill
- perf-auditSkill
- review-routerSkill
- second-opinionSkill
- security-auditSkill
- spec-extractSkill
- verify-featureSkill
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
- Very specific: line 19
Critic, round 1: start adversarial-reviewer with the scope, the thread path and "Debate mode, round 1".
- Very specific: line 20
Fixer, round N: start fixer with the thread path, the scope and "round N".
- Very specific: line 29
Round cap: after 4 critic rounds without a PASS, stop the loop.
- Distinctive: line 42
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 …
- Distinctive: line 48
Read by: ai-orchestrator, humans Dies: when the review gate passes or the loop stops Next: none
≈ “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.
Files
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), thechanged_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'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
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
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.

