Adversarial Code Loop for Openclaw

A Git-native multi-agent pipeline that builds, reviews, fixes, verifies, and optionally arbitrates code changes before delivery.

chpomob
v0.1.0
Aug 4, 2026
0
0
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install adversarial-code-loop

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install adversarial-code-loop using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Adversarial Code Loop?

Adversarial Code Loop orchestrates a sequential BUILD → REVIEW → (FIX → VERIFY)^N → ARBITER workflow for code that needs independent model review. A developer agent writes and commits the implementation, a separate reviewer inspects the real Git diff, and fixer and verifier roles iterate until findings are resolved or the loop is rejected.

Each run uses an isolated loop// branch, preserves recoverable commits, records machine-readable evidence, and squash-merges approved work into the parent branch. As an Openclaw Skills automation, it helps reduce model echo chambers and is especially valuable for security, authentication, financial, and multi-file refactoring tasks.

Adversarial Code Loop Use Cases

  • Require an independent AI code review before merging a critical change.
  • Validate security-sensitive code involving authentication, authorization, secrets, or payments.
  • Review well-scoped multi-file refactors of up to approximately 15 files.
  • Pair different models or providers for builder, reviewer, fixer, verifier, and arbiter roles.
  • Add build and test gates before approval or merge.
  • Resume an interrupted pipeline from its persisted state.json file.
  • Preserve rejected work on a branch for manual inspection and recovery.
  • Generate review evidence and retrospective failure logs for engineering teams using Openclaw Skills.

How Adversarial Code Loop Works

  1. The pipeline detects or initializes a Git repository, records the parent branch and branch-point SHA, stashes dirty files, bootstraps Git identity, and creates an isolated loop branch.
  2. The DEV or BUILDER agent implements the supplied specification. The orchestrator stages the resulting files and creates a build commit.
  3. An optional build command runs as a quality gate.
  4. The REVIEW or CRITIC agent examines the cumulative Git diff from the branch point and returns structured findings with severity, file, line, evidence, and verdict data.
  5. The DEV or FIXER agent addresses the findings, and the orchestrator commits each fix as a separate round.
  6. The VERIFY agent checks every finding against the current diff and marks it resolved, rejected, or disputed.
  7. Steps 5 and 6 repeat until all findings are settled, approval is reached, or --max-loops is exhausted.
  8. An optional ARBITER or JUDGE resolves remaining disputes after the final review cycle.
  9. An optional test command runs before delivery. Approved work is evidence-tagged and squash-merged, while rejected work receives a [REJECTED] marker and remains on its loop branch.
  10. The pipeline restores the original stash on every exit path and writes final.json as the authoritative machine-readable result.

Adversarial Code Loop Setup

The skill supports Linux and macOS and requires the adversarial-common sibling repository, which provides the shared subprocess, provider, JSON, and Git engine.

Install the skill and its dependency with:

curl -fsSL https://raw.githubusercontent.com/chpomob/adversarial-code-loop/main/scripts/install.sh | bash

Or install from an existing checkout:

bash scripts/install.sh

Both methods place adversarial-code-loop and adversarial-common side by side under ~/.hermes/skills. Set a custom target with the installer argument or HERMES_HOME.

Run a basic loop with a required specification and project directory:

python3 ~/.hermes/skills/adversarial-code-loop/scripts/adversarial_loop.py \
  --spec /tmp/spec.md \
  --workdir /path/to/project

Configure model commands with flags or the supported environment variables:

export ACL_DEV_CMD='codex exec --skip-git-repo-check --sandbox workspace-write'
export ACL_REVIEW_CMD='pi --provider zai --model glm-5.2'
export ACL_ARBITER_CMD='pi -p --provider gemini --model gemini-3-pro'

Add build and test gates, bounded retries, and a longer timeout when needed:

python3 ~/.hermes/skills/adversarial-code-loop/scripts/adversarial_loop.py \
  --spec /tmp/spec.md \
  --workdir /path/to/project \
  --feature secure-auth \
  --build-cmd 'cargo build' \
  --test-cmd 'cargo test' \
  --max-loops 3 \
  --timeout 1800

Use --no-merge when reviewing the branch manually, and --resume to continue a run from its artifact state. Only ACL_DEV_CMD, ACL_REVIEW_CMD, and ACL_ARBITER_CMD are currently read from the environment; workdir, timeout, loop count, and output directory must be passed as flags. Do not run concurrent loops against the same worktree.

Adversarial Code Loop Data Schema & Taxonomy

Artifacts are written below //, with .adversarial-loop used by default and automatically added to .gitignore.

File Lifecycle stage Purpose
state.json Git setup Stores completed phases, loop number, branch, branch-point SHA, stash ID, and findings for resume support.
00_spec.txt Build Verbatim copy of the implementation specification.
01_build.json Build Build result and commit SHA.
01_build_gate.json Build gate Result of the optional --build-cmd command.
02_review.json Review Findings array and REQUEST_CHANGES, APPROVE, or REJECT verdict.
03_fix_.json Fix Result metadata for each fix round.
04_verdict_.json Verify Per-finding resolved, rejected, or disputed statuses and verdict.
05_arbiter.json Arbitration Arbiter decision and any recorded conditions.
06_test_gate.json Test gate Result of the optional --test-cmd command.
final.md Completion Human-readable summary and evidence-tag annotation.
final.json Completion Machine-readable contract containing verdict, reason, loops, branch, merged state, conditions, arbitration status, and artifact directory.

Review findings use a structured schema with an id, severity of blocker, major, minor, or nit, file, integer line, summary, and evidence. Missing IDs receive deterministic auto_ identifiers. Approval requires an APPROVE verdict and every finding to be resolved or rejected; disputed findings remain open.

Git metadata follows a predictable taxonomy: loop// branches, build commits for BUILD, fix commits for each FIX round, annotated approved evidence tags, squash commits for accepted changes, and [REJECTED] marker commits for rejected work. Failures are also appended to _retrospective/ISSUES.md with phase, branch, error, timestamp, feature, and workaround context.

Adversarial Code Loop Advanced Features

  • Multi-role orchestration with distinct BUILDER, CRITIC, FIXER, VERIFIER, and JUDGE personas.
  • Provider-agnostic command configuration for Codex, pi, Claude through claude-tmux, DeepSeek, GLM, Gemini, and other compatible CLIs.
  • Quota-aware provider selection through --provider-config, --force, and repeatable --force-provider role:alias options.
  • Git-native isolation, cumulative diff review, stash restoration, branch preservation, squash merging, and annotated evidence tags.
  • Resumability from state.json after interruptions, timeouts, or partial phase completion.
  • Optional build and test gates that convert failed validation into a controlled rejection.
  • Robust JSON parsing that handles raw JSON, markdown-fenced JSON, surrounding prose, and extracted arrays, with one retry for malformed review output.
  • Privilege reduction for review commands by stripping known dangerous flags, while clearly documenting that this is not OS-level sandboxing.
  • Configurable per-subprocess timeouts for long-thinking models and multi-phase execution.
  • English-only internal specs, personas, findings, verdicts, and commit metadata to keep role handoffs consistent.
  • Automatic retrospective logging for diagnosing provider, timeout, Git, and workflow failures.
  • Compatibility with Openclaw Skills workflows that need auditable, repeatable, multi-agent code quality controls.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*