Claude Code
The agent plugin assay-agent runs assay’s gate at the end of every Claude Code turn. While the gate fails, the agent cannot stop: it is told what fails and works on.
The plugin has three hooks:
| Hook | Runs | Does |
|---|---|---|
session start (SessionStart) |
when a session starts or starts again | takes the session mark with assay mark |
after each edit (PostToolUse, matcher Edit|Write) |
after the agent’s Edit or Write |
notes the file in the session ledger |
turn end (Stop) |
when the agent is about to hand control back | runs assay gate on the change since the mark, reads the JSON result and decides |
The agent is blocked once per state. If it stops again without changing anything, it is let go, and you are shown that the gate still fails.
The plugin does not contain assay. It runs the program assay of the package assay_cli, installed on your machine, and writes the message to the agent from its JSON result; assay_cli knows nothing of agents. The plugin’s source is plugins/assay-agent/ of assay’s repository, with its own readme. The same plugin works with Codex: see Codex for what differs there.
Installing the plugin
Section titled “Installing the plugin”assay’s repository is a Claude Code marketplace. In Claude Code:
/plugin marketplace add gundogduali/assay/plugin install assay-agent@assayA checkout of the repository works as a marketplace too: /plugin marketplace add /absolute/path/to/assay.
You need:
- A project that has adopted assay: a preset included in
analysis_options.yaml(Getting started). - The program
assayon the machine (install it once per machine). See How the plugin findsassay. darton the PATH, until the plugin has built its own program: the first hook of each plugin version builds it withdart compile exe, offline, in some seconds.
Good to know:
- The plugin writes nothing into the project’s settings. Its hooks come with it.
assay initwrites no hook either: it only adopts a preset. - Claude Code keeps an installed plugin by the version that
plugin.jsonnames, which is raised at each release. To get an update, update the marketplace and the plugin with/plugin. A session that started before the update can go on with the older version. See Versions. - The plugin has one setting,
assay_command. Claude Code asks for it when you enable the plugin. Leave it empty unlessassayis somewhere the plugin cannot find it.
How the plugin finds assay
Section titled “How the plugin finds assay”At every hook, the plugin looks in this order:
- the setting
assay_command, which Claude Code hands to the hooks asCLAUDE_PLUGIN_OPTION_ASSAY_COMMAND; assayon the PATH;assayin the pub cache’sbindirectory, wheredart pub global activate assay_cliputs it:$PUB_CACHE/binifPUB_CACHEis set, else~/.pub-cache/bin, or%LOCALAPPDATA%\Pub\Cache\binon Windows. On Windows the program isassay.exe,assay.batorassay.cmd.
A hook runs with the environment Claude Code was started with. A PATH that only an interactive shell sets up, such as in ~/.zshrc, is missing unless you started Claude Code from such a shell. The third place finds an activated assay without the PATH.
The setting assay_command is the whole command line that runs assay. For example:
dart pub global run assay_cli:assayIt is split into words without a shell. Quotes group words, and a backslash outside quotes stands for the next character (on Windows a backslash is a path separator, and only double quotes group). Nothing is expanded, so write a path whole, without ~ or a variable. A line that cannot be split, such as one with an unclosed quote, counts as a program not found.
The check. Once per session the plugin runs assay version --json and reads its last line, which names the version and the result schemas the program writes. The plugin needs assay.result/3. A program that could not be started is looked for again at the next hook. A program that writes another schema is not asked again in that session unless the setting changes: update it, then start a new session.
Running assay from a checkout
Section titled “Running assay from a checkout”To run assay from a checkout without activating it, set assay_command to the Dart program and the entry point, by absolute paths:
/path/to/dart /path/to/assay/packages/assay_cli/bin/assay.dartRun dart pub get at the checkout’s root first. Each call then compiles the program first; a kernel file built once (dart compile kernel packages/assay_cli/bin/assay.dart -o <file>) and named as /path/to/dart <file> starts faster.
Where assay cannot be used
Section titled “Where assay cannot be used”If no program is found, it cannot be started, or it does not write assay.result/3, the session-start and after-edit hooks take no mark and record nothing. The first turn end tells you once in the session:
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.For a program that writes another result schema, the first line names its version and the schemas it writes, and the last line says Next: install a version of assay that writes it, or set the command that runs one in the settings of the agent plugin. This is said once in a session; the agent is not held while assay cannot be used.
Later turn ends of that session answer nothing, and the agent stops. Nothing is judged on that machine, and the agent is never held for it.
The hook at session start
Section titled “The hook at session start”The hook reads hook_event_name, session_id and source from its input, and finds and checks assay. For a session it knows nothing of, it runs in the project root:
assay mark --out .dart_tool/assay_agent/marks/s-<identifier>.<number>.mark --cross-file<number> is the process that took the mark. The mark holds the session base (the commit checked out, or that the project is in no git repository), the Dart files git ignores, the baseline file and the options files as they are, and the whole-project results that stand already. See assay mark. A configuration in error does not stop the mark.
Taking the mark runs the cross-file and project-file checks once on the whole project. The agent’s first answer waits for it, so the mark is taken before the agent does anything, and what the agent commits during the session is judged too.
A session the plugin knows, such as a resumed one, keeps its mark. A resumed or compacted session the plugin knows nothing of gets a mark now, recorded as session-continued, and counts as first seen late. A new session (startup), the one after /clear and a fork are recorded as session-start.
Then the hook cleans up sessions that are over (see What the agent plugin keeps). It prints nothing, because Claude Code adds whatever this hook prints to the agent’s context, and exits with 0. A failure goes to .dart_tool/assay_agent/hooks.log; the next hook tries again.
The hook after each edit
Section titled “The hook after each edit”The hook reads tool_name and tool_input: for Edit, its file_path, old_string and new_string; for Write, its file_path, and from tool_response whether it created the file. Other tools are not recorded.
It records the first touch of each file in the session ledger, with the path relative to the project root, the time, and what the file was before:
- did not exist: a file
Writecreated; - its earlier text: a Dart file
Editchanged, recovered from the file and the edit where the new text stands in exactly one place; - earlier text not known: a Dart file
Writeoverwrote, or one whose text cannot be recovered; - not kept: a file that is not Dart source.
A later touch of the same file writes nothing. A file outside the project, links followed, is not recorded. The hook analyses nothing and does not start assay, except when it is the first hook to see the session: then it takes the mark as the session-start hook does, once the edit is in the file. It prints nothing and exits with 0; a failure goes to .dart_tool/assay_agent/hooks.log.
The ledger is only used in a project that is in no git repository. There git cannot say what changed, so the turn end hands assay the ledger’s files and what each was before (--changes): the change is what Edit and Write touched. A file that a shell command or another program wrote is not in it; what such a command adds to the baseline or changes in the configuration is still found, through the mark. A project whose .git git does not answer for, as a repository another user owns, is judged by its ledger too, and assay warns of it on standard error. In a repository, git says what changed, whatever wrote it.
The hook at turn end
Section titled “The hook at turn end”The hook reads hook_event_name (Stop) and session_id, nothing else. It finds and checks assay, takes the mark if this is the first hook to see the session, and runs in the project root:
assay gate --scope changed --since .dart_tool/assay_agent/marks/s-<identifier>.<number>.mark \ --reporter json:<temporary>/result.json \ --full-report .dart_tool/assay_agent/reports/gate-changed-s-<identifier>.txtIn a project with no git repository, --changes <temporary>/changes.json is added. The temporary directory is removed after the run.
The gate judges the change since the mark: in a repository, what differs from the mark’s commit, committed since or not, plus the untracked files git does not ignore; elsewhere, the files of the ledger.
- Every such file is a changed file, whoever changed it. 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.
- The change is that of the project’s own repository. The project root stays at
CLAUDE_PROJECT_DIRwhen the agent enters a git worktree, so files in a worktree outside the project are not part of the change, nor is anything in a submodule or a nested repository; the full report names a submodule or nested repository under “Changed files”. A session that started before the project was a repository stays on its ledger aftergit init, and the full report says so. - Ignored files. A Dart file that a new line in
.gitignore,.git/info/excludeor another ignore file hides during the session stays a changed file, and so does a file newly created under an ignore line that stood before, such as a generated file: exclude generated code in the configuration, whereassay.excludealready names the common patterns. What git ignored when the mark was taken, such as build output, stays out. A file marked “assume unchanged” or “skip worktree” is compared by its content.
The plugin then answers:
| The gate | The hook writes (exit code 0 in every case) | What follows |
|---|---|---|
| fails, or the change holds a new suppression or a new coverage-ignore comment | {"decision":"block","reason":"<message>"} |
The agent does not stop, and reads the message as the reason. |
| blocks again, and nothing has changed since the agent was last blocked | {"systemMessage":"<notice>"} |
The agent stops and is handed nothing more. Claude Code shows you the notice as a warning. |
| passes, with something new | {"hookSpecificOutput":{"hookEventName":"Stop","additionalContext":"<message>"}} |
The agent reads the message and goes on for one round. The transcript shows it as hook feedback, not as an error. |
| passes, with nothing new | no output | The agent stops. |
| could not be run | {"systemMessage":"<notice>"}, or no output if you were told before in the session; the notice also goes to standard error |
The agent stops and is handed nothing. Nothing was judged. |
Standard output holds that one JSON object on one line, or nothing. The object can also carry a systemMessage for you (see What you are shown). The gate’s warnings go to standard error, which Claude Code shows to nobody when a hook ends with 0: they are in its debug log.
The gate judges and writes the full report at every turn end. What the session records of the answer is written only once the answer is out: a hook ended before it answers stores nothing, and the next turn end answers the same again.
“Something new” is anything that does not fail the gate or block the turn end, and that this session was not told before: an advisory violation, a configuration change, a whole-project result. Each is handed over once, so a passing gate costs an extra round only when there is news.
A configuration error fails the gate: the agent is blocked with the error, its file and its key. If the packages are not fetched, as after flutter clean or in a fresh checkout, the message names the commands, which the agent can run itself:
Next: fetch the packages of the project with `flutter pub get` or `dart pub get` (the package `assay_lints`, which holds the presets, cannot be resolved). The gate judges again when the turn ends.The message is the same in both answers and is never longer than about 8,000 characters (Claude Code cuts additional context over 10,000 to a preview). Its parts come in this order:
- the head line, with the verdict and the counts, and a
Next:line; - configuration errors;
- compile errors of the files not judged;
- blocking violations, by file;
- baseline growth;
- new suppressions, new coverage-ignore comments and configuration changes;
- advisory violations in changed files;
- whole-project results;
- a foot line that names the full report, under
.dart_tool/assay_agent/reports/.
A rule’s message and fix are said once, with its first violation. A part that does not fit is cut to “+N more in the full report” and keeps its heading and count. Every line is one line: a line feed, an escape character or another control character is written as \n, \x1B and the like, in the message and in a notice to you. See The message to the agent for a full example.
What else blocks the turn end
Section titled “What else blocks the turn end”Two things the gate lists but never fails on still block the turn end. The plugin decides this from the JSON result (newSuppressions[] and newCoverageIgnores[]), so a CI run is not held by them:
- a new suppression in the session’s change, justified or not;
- a new coverage-ignore comment (
// coverage:ignore-line,-start,-end,-file), although the gate never judges coverage at turn end: the agent must not hide uncovered code from a coverage condition in CI.
The head line says so after the verdict (assay gate: PASS - blocked: new suppressions (1), new coverage-ignore comments (2) - scope: changed files - …). The agent is told to fix what each suppression hides, cover what each comment hides with a test, and delete it, or to leave one you asked for and tell you.
The next turn end in the same state lets the agent go and shows you that the gate still fails, so a suppression you want costs one round. See Suppressions.
Where assay gives no verdict
Section titled “Where assay gives no verdict”- It wrote its result, whatever its exit code: the answer follows the result. If it judged but could not write a baseline file or the full report (exit code 3), you may get a notice that starts with
assay gate: judged, but not all of it was written -and ends withThe agent was answered by the verdict of the gate all the same. - It refused the mark, for example because a version of
assayinstalled during the session cannot read it, or the mark file was removed. The plugin takes a new mark, once per session, lets the agent go and tells you, in a notice that starts withassay gate: the mark of this session could not be used -and ends withA new mark was taken now, so what the session changed before this turn end was not judged; the next turn ends judge the change since it. - It wrote no result otherwise, or one the plugin cannot read: the gate could not be run.
- It could not be started: see Where
assaycannot be used.
Cross-file results at turn end
Section titled “Cross-file results at turn end”At turn end the gate also runs the cross-file checks on the whole project (unused_code, unused_files, unused_l10n, unnecessary_nullable, duplicated_code; see Cross-file checks). So the agent hears about dead code its change caused in files it did not touch, such as a function whose last call it removed, and about code it copied. The results are the last section of the message, “Whole project”:
assay gate: PASS - scope: changed files - 0 blocking, 0 advisory, 1 whole-project result, 1 changed fileNext: nothing is required. What follows is new in this session and does not fail the gate.
Whole project (1 new) - in a file the change touched or in another; they do not fail the gatelib/greetings.dart 3:8 unused_code: Nothing in the project refers to the function `farewell`. fix: Delete the declaration if nothing needs it.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-abc123.txt- It never fails the gate or blocks the agent. An untouched file that does not compile is listed here as
lib/broken.dart (does not compile). A changed file that does not compile still fails the gate. - Only what the session left behind is handed over, once per session. A result that stood when the session was first observed is in its mark (
inMarkin the result) and is not handed over, nor is one the baseline holds. The full report lists them all, the baseline’s marked[in the baseline]. A standing result whose line the agent edits is news. A duplicated region is news only if it holds a code line the session wrote (see Duplicated code). - When the mark holds none, because every check was off, the configuration was in error or the pass failed, the first turn end that runs the checks hands over what they find, once.
- The checks run only when the change holds a Dart, YAML, JSON or ARB file and at least one check is on. Otherwise the full report says
cross-file pass not run. - A suppression comment does not silence a cross-file result; the check’s own
excludeunderassay.cross_filedoes. - A check that throws is a defect of assay: the gate goes on without its results, and the full report names it.
See Cross-file checks in the gate for the rest, the baseline among it.
Project-file results at turn end
Section titled “Project-file results at turn end”At every turn end, whatever the session changed, the gate also runs the project-file checks (secret_in_shipped_file, cleartext_traffic_allowed, debuggable_app, app_backup_allowed, exported_component_without_permission; see Project-file checks). So a session that only edits the Android manifest or the Info.plist is judged too. Their results go into the same “Whole project” section:
assay gate: PASS - scope: changed files - 0 blocking, 0 advisory, 1 whole-project result, 0 changed filesNext: nothing is required. What follows is new in this session and does not fail the gate.
Whole project (1 new) - in a file the change touched or in another; they do not fail the gateandroid/app/src/main/AndroidManifest.xml 4:9 cleartext_traffic_allowed: android:usesCleartextTraffic lets the app send any request over plain HTTP, which whoever is on the network can read and change. fix: Remove android:usesCleartextTraffic and use HTTPS; let a host that has no TLS have clear text alone, in a domain-config of a network security configuration.
Full report: .dart_tool/assay_agent/reports/gate-changed-s-abc123.txtThey behave like cross-file results: they never fail the gate, they pass through the baseline, and each is handed over once per session. Only what the session made is handed over:
- a result in a file the session wrote or created that the mark does not hold. A result is told apart by what it is and its own text, not by its line, so editing other text on the line of a standing result hands nothing over;
- after a change to
pubspec.yaml, a secret in any shipped file the mark does not hold, since a newly declared directory ships its.env; - after a change to the main or release manifest, a clear-text result in the network security configuration it names;
- a secret written into a shipped file git ignores, such as
.env: the mark keeps a digest of each.
A mark taken by a release before these checks holds none of their results: a standing result in a file the session touches is then handed over once. See Project-file checks in the gate.
The baseline at turn end
Section titled “The baseline at turn end”The baseline only covers whole-project judgements. At turn end it lets nothing pass:
- A blocking violation in a changed file fails the gate, even if the baseline holds it. Its line says
[in the baseline; blocks because its file was changed]. - Adding entries to the baseline fails the gate, with the reason
baseline_growth, however they got intoassay_baseline.json:assay baseline update --add, an edit, or a shell command. The message lists them under their growth records and tells the agent to remove them and fix the violations. - Removing entries is never growth. The gate itself removes the entries of a changed file it judged clean, of a cross-file result that is gone, and of a deleted file. The baseline is the only project file the gate writes, and it only removes from it, under a lock: what
assay baseline update --addwrites meanwhile stays, and counts as growth.
“Before the change” is the baseline file as the mark holds it. So an entry a shell command wrote is caught, and an uncommitted baseline that was there when the mark was taken is not growth. If the baseline could not be read when the mark was taken, no entry counts as added, and the full report says so. A baseline that cannot be read now is a configuration error.
In a session first seen late, entries added before that moment are in the mark and do not count as the session’s. They are still in the file’s growth records and in what assay gate prints in CI.
Configuration changes at turn end
Section titled “Configuration changes at turn end”The gate lists what the change did to the configuration, so that a rule the agent switched off does not go unnoticed. A configuration change never fails the gate. It is listed in the result (configurationChanges), in the message after the new suppressions and coverage-ignore comments, and in the full report:
Configuration changes (2) assay.rules.avoid_dynamic.enabled: true -> false assay.exclude: ["**/*.g.dart"] -> ["**/*.g.dart","lib/legacy/**"]Each line is the key, the value before and the value now. The gate compares the configuration in effect, as assay reads it from the root analysis_options.yaml and the files it includes:
| Key | What is compared |
|---|---|
preset |
the adopted preset |
plugins.assay.diagnostics.<rule> |
whether the preset switches a rule on; listed only when the preset keeps its name and its file changed |
assay.rules.<rule>.enabled and every other rule parameter, a rule’s own exclude among them |
<rule>: false and <rule>: {enabled: false} are the same change |
assay.exclude, analyzer.exclude |
each list whole; a new order alone is no change |
assay.cross_file.<check>.enabled and .exclude |
|
linter.rules.<lint> |
whether an SDK lint is on; a lint no file names is off |
analyzer.errors.<code> |
the severity under analyzer: errors: (error, warning, info, ignore; false is ignore), null where none is set |
analyzer.language.<mode> |
whether strict-casts, strict-inference or strict-raw-types is on |
Configuration changes (2) analyzer.errors.unused_import: warning -> ignore linter.rules.unawaited_futures: true -> falseThe SDK lints and severities are compared because switching them off is the easiest way to silence a blocking diagnostic of the standard analysis; assay’s own engine reads neither. They are read as the analyzer merges the files, so a line that drops what a preset set is listed as what was lost: linter: rules: none lists every SDK lint of the preset as true -> false, and analyzer: errors: none lists the preset’s six severities as warning -> null. What has no effect for the analyzer, such as a key with nothing after it, is not listed.
Another preset is one change of preset, plus the rule parameters, severities and strict modes the two presets set differently. From strict to recommended that is the preset, the three modes and seven limits: six that loosen and the cognitive one gone (assay.rules.max_cognitive_complexity.max: 15 -> null). Rules and SDK lints that only the presets switch differently are not listed one by one.
- “Before the change” is the options files as the mark holds them, a package’s preset included. So a change a shell command made is listed too, and a change that was undone is not.
- On a passing gate a change is handed to the agent once per session. The same key with another value is news again. On a failing gate every change is in the message.
- A configuration that has become invalid is a configuration error and fails the gate. Nothing is compared until it is valid again.
- If the root options file could not be read when the mark was taken, nothing is compared, and the run’s notes say: “Configuration: the root options file could not be read before the change, so it is not known what the change did to the configuration, and no configuration change is listed.”
- A configuration change is not part of the state an agent is blocked in, but an edited options file is a changed file, so an edit to it blocks again.
- In a session first seen late, what changed before that moment is part of the mark.
What you are shown
Section titled “What you are shown”What you are told, and not the agent, goes into the systemMessage field of the hook’s answer, which Claude Code shows you as a warning. A notice is a few lines, never longer than 1,500 characters; several notices of one turn end share the field.
A gate that could not run
Section titled “A gate that could not run”“Could not be run” is everything that is not a judgement: a hook input that cannot be read; a run of assay gate that wrote no result (a standard analysis command that could not start or did not end within its time limit of 300 seconds, git that stopped answering since the mark was taken, a usage error); a result or a session state the plugin cannot read; a session the plugin keeps no mark of; and a program assay that cannot be used.
It is no verdict, and nothing the agent could fix, so the agent is let go and handed nothing. A project without a pubspec.yaml is judged like any other. A rule of assay that throws on a changed file is not this case either: that file is not judged, which fails the gate.
If the gate ran, you are shown what assay said and how to judge the same change by hand:
assay gate: COULD NOT RUN - <what assay said on standard error>The change of this turn was not judged.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.The last line says what you can do: judge the change by hand, check how the hook is wired, or install assay or set its command. A hook input that cannot be read:
assay gate: COULD NOT RUN - The hook input is not a JSON object.The change of this turn was not judged.Next: check how the turn-end hook of the agent plugin is wired: it reads the hook input of the turn end from standard input.None of these ends with exit code 2, which in Claude Code would block the stop. One case has no notice: the plugin’s program started with an event it does not know prints its usage on standard error and exits with 1, which Claude Code treats as a hook error that blocks nothing.
A gate that still fails
Section titled “A gate that still fails”The plugin blocks the agent once per state. If the agent stops again with the same change and the same reasons to block, it has answered that it needs your decision, or that it leaves the violation in. Telling it again changes nothing, so it is let go, and you are shown:
assay gate: STILL FAILING - 1 blocking, 0 advisory, 1 changed fileThe 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-<identifier>.txtYou see this at every such turn end, not once per session. The full report holds what fails.
The state is a digest of the change (each changed file with its content, each deleted file) and of what made the gate fail (the reasons, configuration and compile errors, blocking violations with their places, baseline growth). Anything else blocks again:
- any edit to a changed file, even one that leaves what fails as it was;
- a file more or less in the change;
- a different failure.
Only the last block’s state is kept, so going back to an earlier state blocks. A passing gate forgets it. Files under .dart_tool/ are not part of the change, and a commit changes nothing: the change is what differs from the mark’s commit.
If the result cannot say what the change holds, as when a changed file cannot be read, or the configuration is in error and git does not name the changed files, there is no state to compare, and the plugin blocks at every turn end.
A session first seen late
Section titled “A session first seen late”The mark is taken when a session is first observed. If that was not the session’s start, commits made before it are outside the change. The gate judges all the same, and tells you once per session:
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`.In a project with no git repository it is the earlier edits, not commits, that were not judged.
The first line names the hook that saw the session first: “by the turn-end hook”, “by the hook after an edit”, or “by the session-start hook when the session was continued” (a resumed or compacted session the plugin knows nothing of). In that last case the second line is only “To avoid this, do not remove .dart_tool/assay_agent during a session.”
If the hook after an edit failed in this session before it was first seen, a line between the two says how often: “Before that, the hook after an edit failed 2 times in this session; .dart_tool/assay_agent/hooks.log says why.”
It happens when .dart_tool/assay_agent was removed during the session (as flutter clean does), the plugin was installed or enabled during the session, assay became usable only after the session started, or the session-start hook failed or did nothing. The notice says only which hook saw the session first; it does not guess why.
A failed hook after an edit
Section titled “A failed hook after an edit”The hook after an edit never reports its own failure. When .dart_tool/assay_agent/hooks.log holds new failures of it since the session was first seen, the turn end tells you:
assay gate: the hook after an edit failed 2 times since this session was first seen; see `.dart_tool/assay_agent/hooks.log`.The count is this session’s. Failures before the session was first seen are in the first-seen-late notice instead. A failure of the session-start hook is logged and not told; the session it left unobserved is first seen late, which is told.
How long the agent can be held
Section titled “How long the agent can be held”The gate judges at every turn end, also when the agent is already continuing because of an earlier block. The plugin does not read the input field stop_hook_active.
The agent is held as long as it changes something and the turn end blocks: each new state is blocked once. It is let go at the first turn end that blocks with nothing changed since the last block, with the still-failing notice. That works in the same turn, when the agent answers without touching a file, and in a later turn, after you have said the violation stays. Nothing is passed by it: the gate fails, and you are told so each time.
Claude Code has its own limit: after turn-end hooks have continued a turn eight times in a row, it overrides the next block and ends the turn, with a warning to you. The count starts again whenever the agent calls a tool. The plugin only reaches it when there is no state to compare and it blocks at every turn end. Claude Code’s environment variable CLAUDE_CODE_STOP_HOOK_BLOCK_CAP raises the limit.
The time limit. The gate stops the standard analysis command after 300 seconds, with the analysis server and every process it started (on Windows with taskkill /T /F), and ends as “could not be run”: the agent stops and you are told. A change too large for one command line is handed over in several runs that share the 300 seconds. Claude Code cancels a hook after 600 seconds unless it sets a timeout, and throws away what it printed. The plugin’s hooks set none, so the gate’s own limit comes first, with its notice.
No hook runs when you interrupt the agent, and a turn that ends in an API error runs another event. Nothing is judged then. A hook already running when you press Escape is cancelled: see Cancelled hooks and Ctrl-C.
Judging a change by hand
Section titled “Judging a change by hand”assay gate --scope changed runs the same judgement as the turn end:
assay gate --scope changed # what differs from the commit that is checked outassay gate --scope changed --base=main # the change since a commitassay gate --scope changed --since=.dart_tool/assay_agent/marks/s-<identifier>.<number>.markThe last one judges the session’s change since its mark, which is what the agent was judged on. In a project with no git repository a mark also needs --changes <file>, the list of files changed since it with what each was before: see assay mark. There is no option that names a session.
A run by hand prints the gate’s console report, not the agent’s message. It touches nothing the plugin keeps: it releases no agent, marks nothing as handed over, and fails as often as you run it. A new suppression or coverage-ignore comment does not fail it. Like every gate, it removes baseline entries that no longer match, and writes its full report under .dart_tool/assay/reports/ unless --full-report says where.
Troubleshooting
Section titled “Troubleshooting”Common problems
Section titled “Common problems”| Case | What happens | What to do |
|---|---|---|
| A shell profile prints a line on standard output | The answer is read as plain text, and a failing gate does not block, without any error. At session start the line becomes agent context. | Find and silence the line; Claude Code’s hook guide describes how. (What assay writes never reaches the answer: its result is read from a file.) |
assay missing, or writes another result schema |
Nothing is judged; you are told once per session. | Install assay or set assay_command (How the plugin finds assay); update the program and the plugin together. |
dart missing while the plugin’s program is not built, or the build failed |
Nothing is judged; you are told once per session. | Put the Dart or Flutter SDK’s bin on the PATH, or read build.log in the plugin’s data directory. A failed build is retried after 10 minutes. |
| A launcher waited more than 30 seconds for another’s build | That hook acts as if it had not run: a turn end judges nothing and says nothing; a session start leaves the session first seen late. | Nothing: the next hook finds the build done. |
.dart_tool/assay_agent removed during a session (flutter clean) |
The session ledger goes with it, and the next hook takes a new mark. In a repository, earlier commits of the session are not judged, uncommitted work still is; in no repository, the files touched before are no longer known. You are told. After flutter clean the turn end first blocks with the configuration error that names flutter pub get. |
Do not remove .dart_tool/assay_agent during a session. |
| A session left open more than 14 days without a write, while other sessions started | Housekeeping removed its state: as above. | |
The session started before the plugin was enabled, or before assay could be used |
The session is first seen late. You are told. | Enable the plugin and install assay before starting a session. |
| Hooks switched off | Claude Code runs no hook of a disabled plugin, runs a project’s hooks only after you accept the folder’s trust dialog, and runs none with disableAllHooks. |
Enable the plugin and trust the folder. |
Logs and reports
Section titled “Logs and reports”.dart_tool/assay_agent/hooks.log: why the session-start or after-edit hook failed.build.login the plugin’s data directory: why the plugin’s program did not build.- The full report,
.dart_tool/assay_agent/reports/gate-changed-s-<identifier>.txt: everything the gate found, uncut, with its timings. - Claude Code’s debug log: the gate’s warnings on standard error.
- Judging a change by hand: to see what the turn end saw.
Details
Section titled “Details”The hooks file and the launchers
Section titled “The hooks file and the launchers”The plugin’s hooks are in hooks/claude-code.json, which plugin.json names.
The hooks file, without its description
{ "hooks": { "SessionStart": [ { "hooks": [ { "type": "command", "command": "exec sh \"${CLAUDE_PLUGIN_ROOT}/scripts/run.sh\" claude-code session-start; powershell -NoProfile -ExecutionPolicy Bypass -File \"${CLAUDE_PLUGIN_ROOT}/scripts/run.ps1\" claude-code session-start; exit $LASTEXITCODE" } ] } ], "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "exec sh \"${CLAUDE_PLUGIN_ROOT}/scripts/run.sh\" claude-code after-edit; powershell -NoProfile -ExecutionPolicy Bypass -File \"${CLAUDE_PLUGIN_ROOT}/scripts/run.ps1\" claude-code after-edit; exit $LASTEXITCODE" } ] } ], "Stop": [ { "hooks": [ { "type": "command", "command": "exec sh \"${CLAUDE_PLUGIN_ROOT}/scripts/run.sh\" claude-code turn-end; powershell -NoProfile -ExecutionPolicy Bypass -File \"${CLAUDE_PLUGIN_ROOT}/scripts/run.ps1\" claude-code turn-end; exit $LASTEXITCODE" } ] } ] }}SessionStarthas no matcher, so it runs for every way of starting: new, resumed, after/clear, after a compaction, and a fork.Stoptakes no matcher.- On macOS and Linux,
shreads each command, and on Windows Git Bash does. Either runs the POSIX launcherscripts/run.shand never reaches the rest, sinceexecreplaces the shell with the launcher. On Windows without Git Bash, PowerShell does not find the first command and runs the PowerShell launcherscripts/run.ps1, written for Windows PowerShell 5.1. - No hook sets a
timeout: see How long the agent can be held. - The plugin’s program runs every
assaycommand in the directoryCLAUDE_PROJECT_DIRnames: the root of the project the session started in, which holdspubspec.yamland the rootanalysis_options.yaml. It stays put when the agent changes directory.
The launchers
Section titled “The launchers”Both launchers do the same. Each runs the plugin’s own program, built from its Dart source into the data directory Claude Code gives the plugin (CLAUDE_PLUGIN_DATA), and hands it the hook’s input as it came.
- The build. The executable is named by the plugin’s version and a digest of its sources, so it is built once per version, with
dart compile exe, offline: nothing touches pub, the network or the plugin’s directory. The output goes tobuild.login the data directory. Older executables are then removed, except the newest of another version, which a session started before an update may still run. - One build at a time. The builder holds
build.lock. A launcher that finds another building waits up to 30 seconds, then exits with 0 and does nothing. A lock whose owner has ended, or that is older than 5 minutes, is taken over. A failed build is not tried again for 10 minutes. - The launcher never exits with 2, the code that blocks the agent. If it cannot run the program, it tells you in a
systemMessage, once per session, at session start or turn end (never after an edit), and exits with 0. The markers of what a session was told are kept undertold/in the data directory for 14 days. Each notice starts withassay-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.could not build its program with dart compile exe; see <data directory>/build.log.CLAUDE_PLUGIN_DATA is not set, so the plugin has nowhere to build its program: the agent did not set it. Run the plugin from the agent that installed it.(The launchers readCLAUDE_PLUGIN_ROOTandCLAUDE_PLUGIN_DATAfor any first argument butcodex, for which they read Codex’sPLUGIN_ROOTandPLUGIN_DATA.)could not create <directory>.
What the agent plugin keeps
Section titled “What the agent plugin keeps”Everything the plugin keeps of a session is under .dart_tool/assay_agent/ in the project:
| File | What it is |
|---|---|
sessions/s-<identifier>.json, with its .lock |
The session’s state (assay_agent.session/1): when and by which hook it was first observed, its mark, the checked assay command and version, the ledger with the earlier text of each touched Dart file, what was handed over, the state of the last block, and what you were told. Each write holds the lock and replaces the whole file. An identifier with anything but lower-case letters, digits, - and _, or longer than 64 characters, becomes a digest: h-<digest>. |
marks/s-<identifier>.<number>.mark |
The session’s mark, written by assay mark. If two hooks observe a session at once, each takes a mark, and the one whose observation is recorded keeps its file. |
reports/gate-changed-s-<identifier>.txt |
The full report of the session’s last gate. |
hooks.log |
One line per failure of the session-start or after-edit hook, with the time, the hook and the session where known. |
*.<number>.new |
A file’s new text just before it replaces the old one; one left by a cut-short write is removed with its session. |
assay keeps its own files under .dart_tool/assay/: the baseline lock and the reports of a gate run by hand. The plugin’s built program, its build log and the launchers’ markers are in the plugin’s data directory, outside the project. Keep .dart_tool/ out of version control, as Dart and Flutter projects do.
Housekeeping. Once the session-start hook has observed its own session, it removes what is kept of sessions that are over. No other hook and no assay command removes anything.
- A session is over when none of its files in
sessions/,marks/andreports/was modified for 14 days. Its state, lock, mark and report go together. A session in use stays: every write touches its lock, and the session-start hook marks a resumed session as written. The period is fixed; there is no key for it. - It never removes the session that starts or one a hook is writing for, and never any file but those named above.
hooks.logis cut to its newest 128 KiB once it is longer than 256 KiB. A failure cut from it is no longer counted.- It fails nothing and says nothing.
Cancelled hooks and Ctrl-C
Section titled “Cancelled hooks and Ctrl-C”When the plugin’s program receives an interrupt (SIGINT, which Ctrl-C sends) or a request to terminate (SIGTERM) while it waits for assay, it passes it on:
assayends every process it started, the standard analysis command and its analysis server among them, and exits with 130 after an interrupt or 143 after a request to terminate.- If
assayhas not ended 10 seconds later, the plugin ends it and every process it started. - The plugin writes nothing, so no answer is cut short, and exits with 130 or 143. Nothing is recorded for the session, and the next turn end judges and answers again.
- On Windows the plugin hears only the interrupt.
On macOS and Linux the hook’s command replaces its shell with the launcher (exec sh …/run.sh), and the launcher replaces itself with the program, so a signal sent to the hook’s process reaches the program. Ctrl-C in a terminal reaches every process of the hook. If no signal reaches the plugin, assay runs on until it ends by itself, within the gate’s 300 seconds.