Skip to content

The gate and agent setup

The gate judges a change: pass or fail. The agent plugin assay-agent runs it at the end of each turn of an AI coding agent, on every file the session changed. While the gate fails, the agent cannot stop: it is told what fails, and works on.

The plugin works with Claude Code and Codex. You install it in the agent, apart from assay’s packages, and it runs the program assay installed on the machine. This page is the overview, written for Claude Code; Differences under Codex says what differs. Every case is on the reference pages: Claude Code and Codex.

In Claude Code:

/plugin marketplace add gundogduali/assay
/plugin install assay-agent@assay

In Codex, from a terminal:

codex plugin marketplace add gundogduali/assay
codex plugin add assay-agent@assay

A checkout of the repository works as a marketplace too: /plugin marketplace add /absolute/path/to/assay, or codex plugin marketplace add /absolute/path/to/assay.

Each person who works with an agent on the project installs the plugin in their own agent. Nothing is written into the project’s settings: the plugin brings its own hooks, and assay init writes none. The plugin follows Codex 0.172.0.

The plugin judges a project that has adopted assay: a preset included in analysis_options.yaml (Getting started). The machine needs:

  • The Dart SDK on the PATH of the agent’s hooks. The first hook after the plugin is installed or updated builds the plugin’s own program with dart compile exe. That takes some seconds, once per version, offline.
  • The program assay (Getting started). The plugin looks for it in this order:
    1. the command you set: the setting assay_command in Claude Code, the environment variable ASSAY_COMMAND under Codex;
    2. assay on the PATH;
    3. assay in the bin directory of the pub cache ($PUB_CACHE/bin, ~/.pub-cache/bin, or on Windows %LOCALAPPDATA%\Pub\Cache\bin), where dart pub global activate assay_cli puts it.

The plugin reads the result schema assay.result/3, which it asks for with assay version --json once a session. Update the program and the plugin together.

Updating. Both agents keep an installed plugin by its version. In Claude Code, update the marketplace and the plugin with /plugin. In Codex, run codex plugin marketplace upgrade assay, then trust the hooks again. One plugin version serves both agents (Versions).

A hook runs with the environment the agent was started with. A PATH that only ~/.zshrc sets up is not there, unless the agent was started from such a shell. The plugin looks in the pub cache itself, so an assay from dart pub global activate is found anyway. For an assay anywhere else, give the whole command line that runs it, for example:

dart pub global run assay_cli:assay
  • Claude Code asks for the setting assay_command when the plugin is enabled. Leave it empty to let the plugin look for assay itself.
  • Codex has no plugin settings. Set the environment variable ASSAY_COMMAND where Codex is started (export ASSAY_COMMAND='dart pub global run assay_cli:assay' before codex) or in your shell’s login profile. Codex hands its environment to the hooks and runs them in a login shell, so what the login profile puts on the PATH is there too.

The line is split into words without a shell: quotes group words, and nothing is expanded. Write a path whole, without ~ or a variable.

Then nothing is judged on that machine, and the agent is never held for it. The first turn end of the session tells you, once:

assay gate: COULD NOT RUN - The program assay is not on PATH and not in the directory of the programs of the pub cache, and the setting `assay_command` of the agent plugin is not set.
The change of this turn was not judged.
Next: install assay, or set the command that runs it in the settings of the agent plugin. This is said once in a session; the agent is not held while assay is missing.

Under Codex the first line ends with “and the environment variable ASSAY_COMMAND is not set.”, and the last says to set the command “in the environment variable ASSAY_COMMAND”.

  • A missing assay is looked for again at every hook, so one you install during the session is found by the next hook. The session is then first seen late.
  • An assay that writes another result schema than assay.result/3 is not asked again in that session: update it and start a new session.

Where dart is not on the PATH and the plugin’s program is not built yet:

assay-agent: dart is not on PATH, so the plugin cannot build its program and assay does not judge this session. Put the bin directory of the Dart or Flutter SDK on PATH and start a new session.

The plugin has three hooks. They run, and run assay, in the project Claude Code was started in ($CLAUDE_PROJECT_DIR); under Codex in the directory the session works in, so start Codex in the root of the package.

Hook What it does
At session start (SessionStart) Takes the session mark with assay mark --cross-file: the commit checked out (or that there is no git repository), the baseline and options files, and the whole-project results that already stand. This runs the cross-file and project-file checks once; the agent’s first answer waits for it. It also cleans up old sessions.
After each edit (PostToolUse after Edit and Write; under Codex after apply_patch) Records each touched file in the session ledger, with what a Dart file held before its first touch. It analyses nothing.
At turn end (Stop) Runs assay gate --scope changed --since <the session mark>, reads its JSON result, and decides what the agent is handed and what you are told.

Every file that differs from the session base is a changed file, whoever changed it. The session base is the commit checked out when the session was first observed. In a git repository the changed files are the files of the working tree that differ from it, committed during the session or not, and the untracked files git does not ignore. So your own uncommitted work, from before the session or beside the agent, holds the agent like a file it wrote: commit or stash it before the session, or let the agent clean it. Dead code, a shipped secret or a weak platform setting that stood before the session is never handed to the agent.

In a project with no git repository, the changed files are those the hook after each edit recorded in the session ledger, and the gate gets their list with --changes <file>. A file that a shell command or another program wrote is not in the ledger; what such a command adds to the baseline or changes in the configuration is still found, through the mark.

The turn end records and compares no snapshot. The hooks set no timeout: the gate stops the standard analysis command after 300 seconds and ends as could not run.

Four things, and nothing else:

  1. A blocking violation in a changed file: of a blocking assay rule, of a blocking SDK lint, or an analyzer warning. Every violation in a changed file counts, on a changed line or not, also one the baseline knows.
  2. A changed file that is not judged: a Dart file that does not compile, or one on which an assay rule throws. Its compile errors (or the reason) are reported, and its rule violations arrive once it compiles.
  3. Baseline growth: the change added entries to assay_baseline.json, however they got there.
  4. A configuration error, so that breaking the configuration is never a way through. Where the packages are not fetched, as after flutter clean, the message tells the agent to run flutter pub get or dart pub get.

These never fail it, at turn end, by hand or in CI: advisory violations, new suppressions, new coverage-ignore comments, configuration changes, and the whole-project results. Those are the results of the cross-file checks and the project-file checks, and compile errors in files the change did not touch.

The project-file checks run at every turn end, so a session that edits only the Android manifest or the Info.plist is judged. The cross-file checks run where the change holds a file they read.

Gate conditions (a floor on coverage, a ceiling on duplicated code) are never judged at turn end: the plugin passes neither --coverage nor --duplication, so they are listed as not judged and cost no time. In CI, or by hand with assay gate --coverage coverage/lcov.info --duplication, one that is not met fails the gate (failedBecause: gate_condition). See Coverage in the gate and Duplicated code in the gate.

The plugin also holds the agent on two things the gate lists but never fails on:

  • a new suppression in the session’s change, justified or not, whatever the project’s options say of justifications;
  • a new coverage-ignore comment (// coverage:ignore-line, -start, -end or -file), although the gate never judges coverage at turn end.

An agent told what fails is not to hide it. The head line says what blocks, after the gate’s own verdict:

assay gate: PASS - blocked: new suppressions (1), new coverage-ignore comments (1) - scope: changed files - 0 blocking, 0 advisory, 1 new suppression, 1 new coverage-ignore comment, 2 changed files
Next: fix what each new suppression hides and delete the suppression, and cover what each new coverage-ignore comment hides and delete the comment. The gate judges again when the turn ends.

The agent is told not to add one to pass, and to tell you about one you asked for and leave it. The next turn end in the same state lets the agent go (A gate that still fails), so a comment you want costs one round.

What counts as new:

  • One committed before the session is not new. One written before the session and not committed is, since the session base is the commit that was checked out (What happens in a session). One you write during the session cannot be told from one the agent wrote.
  • A coverage-ignore region or ignore-file that stood before the session is listed too where it covers a line the session wrote, so widening a region over new code is seen (Coverage-ignore comments at the gate). A file only moved with git mv holds none new.

A gate run in CI or by hand is not held by them.

The plugin writes the message to the agent from the gate’s JSON result, in about 8,000 characters at most. Its sections come in a fixed order:

  1. a head line (the verdict, what else blocks, the scope and the counts) and a Next: line;
  2. configuration errors, then compile errors and the files not judged;
  3. blocking violations by file, each with its place, rule, message and one-line fix;
  4. baseline growth, with the growth records and what to do: remove the entries and fix the violations;
  5. new suppressions, new coverage-ignore comments, and configuration changes;
  6. advisory violations in changed files, then whole-project results (Cross-file checks, Project-file checks);
  7. a foot line with the path of the full report, uncut, under .dart_tool/assay_agent/reports/.

A violation the baseline knows is marked [in the baseline; blocks because its file was changed], and one with a fix [fix available]. A section that does not fit is cut to “+N more in the full report” and keeps its count. A line feed or a control character in a name is written as \n, \x1B and the like, so every line of the message stays one line.

A block, as the agent reads it:

assay gate: FAIL - scope: changed files - 1 blocking, 1 advisory, 1 configuration change, 2 changed files
Next: fix the blocking violations. The gate judges again when the turn ends.
Blocking violations (1)
lib/prices.dart
14:58 avoid_non_null_assertion [in the baseline; blocks because its file was changed]: The '!' operator throws at run time when the value is null.
fix: Handle the null case: test for null, or use '??', '?.' or a null-check pattern.
Configuration changes (1)
assay.rules.no_magic_number.enabled: true -> false
Advisory violations in changed files (1) - they do not fail the gate
lib/prices.dart
4:3 no_commented_out_code [fix available]: This comment is code that was commented out: nothing compiles or tests it, and nothing says whether it is still right.
fix: Delete the comment; version control keeps the code that stood here.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-demo-1.txt

What the agent and the person see at turn end

Section titled “What the agent and the person see at turn end”

The turn-end hook exits with 0 and writes one JSON object, or nothing, on standard output.

The gate The hook answers What follows
fails, or the change holds a new suppression or coverage-ignore comment {"decision":"block","reason":"<message>"} The agent does not stop, and reads the message.
blocks again, and the agent changed nothing since it was last blocked {"systemMessage":"<notice>"} The agent stops. You are shown that the gate is still failing.
passes, with something new {"hookSpecificOutput":{"hookEventName":"Stop","additionalContext":"<message>"}} The agent reads it and goes on for one round.
passes, with nothing new nothing The agent stops.
could not be run {"systemMessage":"<notice>"} The agent stops and is handed nothing. Nothing was judged; you are shown why.

A notice to you goes into systemMessage, which the documentation of both agents describes as a warning shown to the user.

“New” is what does not fail the gate, does not block the turn end, and this session was not told before:

  • an advisory violation, or a configuration change;
  • a cross-file result that neither the baseline nor the session mark holds: dead code the change left behind, or code it copied (Cross-file checks, Duplicated code);
  • a project-file result in a file the session wrote: a secret it put into a shipped .env (also one git ignores), android:usesCleartextTraffic="true" it added to the manifest, or a secret in a file it made ship by declaring its directory in the pubspec (Project-file checks).

Each is handed over once in a session, so a passing gate costs one extra round only when there is news:

assay gate: PASS - scope: changed files - 0 blocking, 1 advisory, 1 changed file
Next: nothing is required. What follows is new in this session and does not fail the gate.
Advisory violations in changed files (1 new) - they do not fail the gate
lib/greeting.dart
5:15 no_magic_number: This number has no name: the code does not say what the value stands for.
fix: Declare a constant whose name says what the number is and use the constant here.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-demo-1.txt

The agent is blocked once in a state. It may stop again with the same changed files and the same reasons to block, because it needs your decision or leaves the violation in. Telling it the same again would change nothing, so it is let go, and you are shown, at every such turn end:

assay gate: STILL FAILING - 1 blocking, 0 advisory, 1 changed file
The agent stopped without changing anything since it was last told what fails, and was not held again.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-demo-1.txt

Any edit, also one that leaves what fails as it was, is a new state: the next failing turn end blocks again.

The agent is never held by something that is not a verdict. That covers a hook input or a session state that cannot be read, an assay that cannot be used (above), and a gate run that wrote no result the plugin can read: the standard analysis command could not start or did not end within 300 seconds, git stopped answering since the mark was taken, or a usage error.

Where the gate ran and wrote no result, the notice holds what assay said, and its last line names the command that judges the same change by hand: Next: run `assay gate --scope changed --since .dart_tool/assay_agent/marks/s-<identifier>.<number>.mark` in the project to judge the change by hand.

A session is first seen by the first hook that can use assay. If that was not the session start, the mark is taken then: earlier commits are outside the change, and what stands then, the agent’s work so far included, is not handed over. That happens when:

  • .dart_tool/assay_agent was removed during the session, as flutter clean removes it with the session ledger: in a project with no git repository the files touched before are then no longer known;
  • the plugin was installed or enabled, or assay was found, only after the session started;
  • the hook at session start failed;
  • a resumed or compacted session is one the plugin keeps nothing of.

The gate judges all the same, and tells you once:

assay gate: this session was first seen at 2026-11-22 09:05:07 UTC, by the turn-end hook, so commits made earlier in this session were not judged.
To avoid this, enable the agent plugin and install assay before a session starts, and do not remove `.dart_tool/assay_agent` during a session; a hook at session start that failed says why in `.dart_tool/assay_agent/hooks.log`.

For a resumed or compacted session the first line says “by the session-start hook when the session was continued”, and the second only “To avoid this, do not remove .dart_tool/assay_agent during a session.” Where the hook after an edit failed before the session was first seen, a line between the two says how often, and that .dart_tool/assay_agent/hooks.log says why.

  • The mark could not be used, as after another version of assay was installed during the session or the mark file was removed. The plugin takes a new mark, once a session, lets the agent go, and tells you that what the session changed before that turn end was not judged.

  • A hook failed. The hooks at session start and after an edit never report a failure themselves: they write it to .dart_tool/assay_agent/hooks.log. When the hook after an edit has failed, the next turn end tells you how often, in the same answer that blocks the agent or lets it stop:

    assay gate: the hook after an edit failed 2 times since this session was first seen; see `.dart_tool/assay_agent/hooks.log`.

    A failure of the plugin’s launchers, as a build of its program that failed, is told once a session.

The plugin judges a Codex session with the same gate and the same message. A gate that fails blocks the agent with the same answer, and Codex makes the message the prompt of a continuation of the turn. What differs:

Claude Code Codex
The hook after an edit after Edit and Write, one file each after apply_patch, each file the patch adds, updates, moves or deletes
A gate that passes with something new the agent is handed the message and goes on for one round you are shown the message as a warning (cut at the end of a line to 1,500 characters, with the path of the full report); the agent is handed nothing and stops
Blocks where the plugin cannot tell whether the agent changed anything Claude Code ends the turn after eight continuations in a row; the count starts again whenever the agent calls a tool Codex has no limit, so the plugin lets the agent go at the ninth such turn end in a row of one turn and tells you; your next prompt starts the count again
Windows Git Bash or PowerShell runs the one command cmd.exe runs the Windows command, which runs the PowerShell launcher

Also under Codex:

  • News goes to you. What the warning showed counts as handed over: the agent is not told of those advisory violations, and you may pass them on. A gate that fails later hands the agent the whole message.
  • The login shell. A line your login profile prints before the hook’s answer spoils it, and a failing gate then does not block.
  • Outside the sandbox. A trusted hook runs outside Codex’s sandbox: the plugin and assay write .dart_tool/ and the baseline file whatever the session’s sandbox allows.
  • A moved file in a git repository. Git sees a patch’s move as a removed file and a new untracked one, so the moved file’s standing suppressions and coverage-ignore comments count as new and block the turn end once. Track the new path before the turn end (git add or git add -N) and nothing new is found. A file moved with mv in a shell is the same under Claude Code.
  • No git repository. The ledger holds the files of each patch that apply_patch applied whole, as the hook after it records them (After each edit).
  • Nothing runs until you trust the hooks (again after each update), under a policy that admits managed hooks only, and in codex exec unless they were trusted before. The plugin cannot tell anyone.
Terminal window
assay gate --scope changed # what differs from the commit checked out
assay gate --scope changed --base=main # the change since a commit
assay gate --scope changed --since=.dart_tool/assay_agent/marks/s-demo-1.48213.mark # the change since a session's mark

The change since a session’s mark is what the agent is judged on; the mark files are under .dart_tool/assay_agent/marks/. assay gate has no option for a session. In a project with no git repository, add --changes <file>, the list of the files changed since the mark (assay mark). Every option of the command is on assay gate.

A run by hand prints the gate’s console report, not the agent’s message, and touches nothing the plugin keeps: it never releases an agent or marks anything as handed over. A new suppression or coverage-ignore comment does not fail it. Like every gate, it removes the baseline entries that no longer match, and writes its full report under .dart_tool/assay/reports/ unless --full-report says where.

Under .dart_tool/assay_agent/ in the project:

Path What it is
sessions/s-<identifier>.json, with its .lock One session’s state: its ledger, what was handed over, the state it was last blocked in.
marks/s-<identifier>.<number>.mark The session mark.
reports/gate-changed-s-<identifier>.txt The full report of the session’s last gate.
hooks.log The failures of the hooks at session start and after an edit. Cut to its newest 128 KiB once it is longer than 256 KiB.

The hook at session start removes what is kept of a session once none of its files was modified for 14 days. A session left that long without a write is observed anew when it goes on, as after flutter clean. The plugin’s own program is built into the data directory the agent gives the plugin, outside the project.

Keep .dart_tool/ out of version control, as Dart and Flutter projects do.

When you interrupt the agent, Claude Code runs no turn-end hook, and that turn is not judged; nor is a turn that ends in an API error. Escape while a hook runs cancels it.

On Ctrl-C or a request to terminate, the plugin passes it on to assay, which ends every process it started, the analysis server among them; after 10 seconds the plugin ends what is left. It writes nothing and exits with 130 or 143. Under Codex, a hook that runs out of time or is cancelled is ended with its processes by SIGKILL. Either way nothing is recorded, and the next turn end judges again.