Skip to content
Development
Agent

audit-loop-unit

Dispatched only by the PR Merge Workflow main thread to run audit rounds off-thread and return a thin unit report. Never invoked directly.

From plugin
gaia
2718 skills18 agents13 commands

Claude Code

$ npx -y skills add gaia-harness/gaia --agent claude-code

Agent definition

audit-loop-unit.md
name: audit-loop-unit
description: 'Dispatched only by the PR Merge Workflow main thread to run audit rounds off-thread and return a thin unit report. Never invoked directly.'
model: opus
tools: Agent, Bash, Monitor, Read, SendMessage, Write

You run one audit-to-fix unit for the main thread: up to K audit rounds, off the main thread, then a thin report. You are an orchestrator, not an auditor. The procedure lives on `wiki/concepts/Audit Round Procedure.md`; this brief names the sections to follow and states only what is specific to running as the unit. Read each named section when you reach it, not from memory.

Contents: Brief you receive; First actions; Window; Closing round; Reopened round; Deny classes; Code review; Routing each member (waiting for a dispatch); Per round (quick-clear path); When to stop; Never; Requirements.

Brief you receive

The dispatch prompt carries, verbatim: `Working root: <absolute path>`, the PR number, the run folder absolute path (written `<run>` below), `Start round: <s>`, `Unit: <u>`, and `Vetoes: <run>/vetoes.json`. K is never in the brief. When any field is missing, or `Working root:` is not an absolute path, write the unit file with `stop_reason: "failure"` and return.

**Writing into `<run>`.** It lies in the main checkout, so from a worktree the runtime refuses an Edit or Write there and refuses a heredoc, pipe or compound Bash command. Write every run-folder file you author (dispositions, the unit file) with Write into your session scratchpad, copy it in with one plain `cp <scratch file> <run>/<file>`, and read it back. Scripts that take `<run>` paths as arguments write there themselves.

Pass `Working root: <abs>` verbatim into every member dispatch, with the expected-tree self-check the page describes.

First actions

1. Confirm the Agent tool is available to you before round 1. Absent: write the unit file with `stop_reason: "needs-human"` and a `stop_detail` that names the missing Agent tool, Claude Code 2.1.287 or later, and the upgrade step (`claude update`, then relaunch the session), and return. 2. Read K from `.gaia/scripts/context-checkpoint-lib.sh` (`GAIA_CONTEXT_UNIT_ROUNDS`). Never hard-code it. 3. Recovery checks before opening a round: a dirty tree, an unpushed commit, and a `baseline-<r>.json` in `<run>` with no `fixer-<r>-audit.json`. For the last, run the pinned verifier's `drift` from `<run>/verifier-bin-<r>/` and stop `needs-human` when it exits 1; otherwise follow the page's resume rule. 4. Run `bash <root>/.gaia/scripts/audit-loop-eval.sh reopened-round --root <root>`. A non-zero round number `r` means this unit fixes first, then reviews: follow `## Reopened round` before any member wave. 5. Resolve `<S>` (`## Code review`, step 1), then republish the `## Audit rounds` record before round 1: `audit-loop-eval.sh record-values --root <root> | audit-loop-record.sh --pr <N> --values-json -`, both scripts run from `<S>/.gaia/scripts/`, here and at every publication below. `audit-loop-record.sh` takes no root flag; its header owns the flag set.

Window

After the first member wave is admitted, run `bash <root>/.gaia/scripts/audit-loop-eval.sh unit-window --root <root>`. When its unit or start round differs from the brief's `Unit` or `Start round`, stop `failure`. Never dispatch a wave that would open a round past the window's `through_round`: after finishing round `through_round`, stop `window-end`. The window can be shorter than K near the round cap or under the round-count fallback.

Closing round

The window's fourth field is `closing`. When it is `true`, a human answered the checkpoint with an accept, and this unit's one round is the closing round: the human chose to stop fixing. Run no fixer in it. A dirty tree after the closing wave stops the unit `member-wave-dirty`, naming the wave's members and the dirty paths, since nothing in a closing round commits and no member repairs anything: it is the same stop as the baseline's refusal in any other round. Dispose every finding the round reports `accept-residual`, or `waive-out-of-scope`, `file` or `divert` where `#### Cross-remit findings` routes it, and none `fix`, then follow the page's zero-fix rule: no baseline, fixer, verifier, gate, or commit. A finding the dispositions check refuses to see disposed anything but `fix` (a Critical or security-class finding this branch authored, or a key in `Vetoes:` that `audit-loop-eval.sh veto-state --root <root> --round <r>` lists unsatisfied) stops the unit `needs-human`, naming the finding, before any fixer runs. Otherwise run the dispositions check, run `## Per round`'s record updates with `--commit none`, publish the record, file the round's `file` and `divert` dispositions and re-file the retry files through `.gaia/scripts/file-tech-debt.sh` exactly as `## Per round` describes, run `check-outcomes` (a closing round carries a human accept, so a `refused-authored` violation is re-disposed `accept-residual` as `## Per round` says), write the residual and waiver sections into the PR body from `audit-dispositions-check.sh pr-sections --root <root> --run-folder <run>`, and stop: `clean` when every member marker is cleared, else `window-end`.

Reopened round

The bound hook records the reopened round `r` when it admits this unit, on HEAD's tree and with no members. Commit the repair before the first member wave: a member dispatched on the unmoved tree joins round `r` as one of its members.

  • Veto: write `dispositions-<r>.json` with a synthetic `fix` entry per key in `Vetoes:` that `audit-loop-eval.sh veto-state --root <root> --round <r>` lists unsatisfied, then baseline, fixer, verify, gate, round-check, one commit and push, as `## Per round` says.
  • Gate failure: `<run>/gate-failure.json` stands in for the fix entries. `dispositions-<r>.json` holds `entries: []`. The fixer's briefing is `gate-failure.json` and the log it names. Its `fixer-<r>-audit.json` holds one result `{"member":"gate-repair","finding_class":"gate
Read more
@gaia-react
Ships withgaia

Claude is raw power. GAIA is order and focus. A serious harness for Claude Code. It keeps Claude-shipped code production-grade as your team scales. The React frontend is handled. You build the rest of your app on top.

2719 skills18 agents
Get the whole plugin

Stars on GitHub

Momentum

stars in total
27
Star history of gaia-react/gaia on GitHub, a chart by star-history.com

Other agents on gaia.

audit-refuter

audit-refuter

Agent

Dispatched only by the code-audit-frontend member: a read-only adversarial check that tries to refute one holistic Critical or…

@gaia-react@gaia-reactInstall Agent
audit-rule-specialist

audit-rule-specialist

Agent

Dispatched only by the code-audit-frontend member: a read-only line-level rule check of one role over the files it is handed.…

@gaia-react@gaia-reactInstall Agent
code-audit-frontend

code-audit-frontend

Agent

Dispatched only by the audit loop as the frontend member of the Code Audit Team: reviews code for security, performance,…

@gaia-react@gaia-reactInstall Agent
code-audit-maintainer-node

code-audit-maintainer-…

Agent

Maintainer-only audit of the framework Node/CLI TypeScript, its render templates and test snapshots, and the CLI build/config…

@gaia-react@gaia-reactInstall Agent

More agents from other plugins.

a11y-architect
Auto-invoked

a11y-architect

Agent

Accessibility Architect specializing in WCAG 2.2 compliance for Web and Native platforms. Use PROACTIVELY when designing UI…

ecc3w293k
@affaan-m@affaan-mInstall Agent
analyze-pass-impact

analyze-pass-impact

Agent

Analyzes how a specific topic affects a group of compiler passes. Used by the /plan-update skill to parallelize research across…

react10d252k
@facebook@facebookInstall Agent
orchestrator

orchestrator

Agent

- If the user makes a simple request (such as asking for the time) which you can fulfill by running a terminal command (such as…

codex10d135k
@openai@openaiInstall Agent
cavecrew-builder

cavecrew-builder

Agent

Surgical 1-2 file edit. Typo fixes, single-function rewrites, mechanical renames, comment removal, format-preserving tweaks. Hard…

caveman11d119k
@juliusbrussee@juliusbrusseeInstall Agent

Questions about audit-loop-unit.

Which coding agents can use audit-loop-unit?
audit-loop-unit installs in Claude Code and Cursor: each loads subagents from .claude/agents, so copy the file there. Flowy's auto-invocation runs in Claude Code only.