tx0 for AI coding agents

A post-edit hook and a tool server give a coding agent tx0's findings after each change it makes: only what the change introduced, each with an id and, where one exists, a fix.

Checked after every agent edit

A post-edit hook runs tx0 hook after each change an agent makes. It reports only the findings the change introduced, each with an id and, where one exists, a fix the agent can apply.

  1. The agent rewrites pop and compares the length with is 0, which tests identity, not equality.

  2. The hook checks the edited file and prints what is new since the last commit: one finding, with its id and its fix as a diff. The three findings already in the tree stay out. Claude Code passes exit code 2 back to the model.

  3. tx0 fix --finding HQ4Y8YG86 applies this one fix. It may change behavior, so tx0 applies it only when it is named by id.

  4. After the fix, the same hook exits with 0 and prints nothing.

shoprecorded
# the agent's edit
--- jobs/queue.py
+++ jobs/queue.py
@@ -10,3 +10,5 @@ class Queue:
 
     def pop(self):
-        return self.items.popleft() if self.items else None
+        if len(self.items) is 0:
+            return None
+        return self.items.popleft()
$ tx0 hook
# --timings: how long each step took
load index: 0.0 ms
refresh: 67.7 ms
save index: 0.2 ms
check: 4.8 ms
tx0 found new problems in the edited files: 1 finding (1 warning) in 1 file
jobs/queue.py
  HQ4Y8YG86 12:12 warning tx0/python:is-literal `is` compares identity; use `==` to compare with the int `0`
    12 |         if len(self.items) is 0:
       |            ^^^^^^^^^^^^^^^^^^^^
    note: whether equal values are the same object depends on the interpreter
    fix (unsafe): write `==`
    @@ -12 +12 @@
    -        if len(self.items) is 0:
    +        if len(self.items) == 0:
next: tx0 fix --finding ID | tx0 explain ID | tx0 suppress ID --reason TEXT
exit 2
$ tx0 fix --finding HQ4Y8YG86 --diff
--- a/jobs/queue.py
+++ b/jobs/queue.py
@@ -9,6 +9,6 @@
         self.items.append(job)
 
     def pop(self):
-        if len(self.items) is 0:
+        if len(self.items) == 0:
             return None
         return self.items.popleft()
fixed 1 in jobs/queue.py
1 fixes applied in 1 files
exit 0
$ tx0 hook
exit 0

Recorded with tx0 0.1.0-alpha.3 on the eight-file sample project, on a laptop that was running other work: the hook took 67.7 ms to bring the index up to date and 4.8 ms to check the file. Set up the hook and the tool server

Set up Claude Code

Add tx0 as a tool server, then add the hook to .claude/settings.json. The hook runs after every edit; when the edit introduced a finding, tx0 prints it on standard error and exits with 2, which Claude Code passes back to the model.

tx0 init --agents prints all of this, for Claude Code and the clients below. MCP server and Claude Code hook have each setup on its own.

$ claude mcp add tx0 -- tx0 mcp
.claude/settings.json
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|MultiEdit|Write",
        "hooks": [{ "type": "command", "command": "tx0 hook" }]
      }
    ]
  }
}

Other clients

Clients that read mcpServers, such as Cursor, Gemini CLI and Claude Desktop, take the first block; Codex takes the second.

Any client that runs a command after an edit can call tx0 hook FILE..., or pass the hook's JSON on standard input with the edited path in tool_input.file_path. Exit code 2 means new findings are on standard error, 0 means nothing new, 1 means tx0 could not run.

mcpServers
{
  "mcpServers": {
    "tx0": { "command": "tx0", "args": ["mcp"] }
  }
}
~/.codex/config.toml
[mcp_servers.tx0]
command = "tx0"
args = ["mcp"]

Without a hook

An agent can ask for the same report itself. Add this section to the AGENTS.md or CLAUDE.md of the repository; it tells the agent to run tx0 check --changed --format agent after its changes.

The agent format starts with a summary line and the gate, then lists the findings by file, each with its id, the source line and its fix as a diff.

AGENTS.md
## Static analysis

This repository is checked with tx0. After changing files, run

    tx0 check --changed --format agent

It reports the findings that are new in your uncommitted changes, each with an id,
the line, and a fix where one is known. Findings that existed before your change are
not yours to fix unless you are asked to.

- `tx0 fix --finding ID` applies the fix of one finding; `tx0 fix --dry-run --diff`
  shows every safe fix as a diff.
- `tx0 explain ID` says what a finding means and how to fix it.
- If a finding is wrong or intended, run `tx0 suppress ID --reason "why"`. Do not
  write suppression comments by hand.
- Exit codes: 0 passed, 1 findings fail the gate, 2 usage or configuration error,
  3 tx0 could not run.
$ tx0 check --changed --format agent
tx0: 1 finding (1 warning) in 1 file; gate failed: findings 1 > 0
jobs/queue.py
  HQ4Y8YG86 12:12 warning tx0/python:is-literal `is` compares identity; use `==` to compare with the int `0`
    12 |         if len(self.items) is 0:
       |            ^^^^^^^^^^^^^^^^^^^^
    note: whether equal values are the same object depends on the interpreter
    fix (unsafe): write `==`
    @@ -12 +12 @@
    -        if len(self.items) is 0:
    +        if len(self.items) == 0:
next: tx0 fix --finding ID | tx0 explain ID | tx0 suppress ID --reason TEXT
exit 1

The tools

tx0 mcp speaks the Model Context Protocol over standard input and output. Results come as structured content and as text in the agent format. The server tells the agent how to use them:

tx0 is a static analyzer. Call check with changed: true after editing files: it reports the findings that are new in the uncommitted changes, each with an id, and a fix where one is known. Findings that existed before your change are not yours to fix unless asked. Apply a fix with fix (ids, apply: true), read about a finding with explain, and if a finding is wrong or intended, call suppress with a reason instead of writing suppression comments yourself. For content not saved yet, use check_text.
check
Check the tree and report findings: a summary line, then findings grouped by file, each with an id, line:column, level, rule, message, the source line, and its fix as a diff when one is known. Use changed: true after editing to see only what your uncommitted changes introduced.
check_text
Check content that is not saved yet, as if it were the file at path. Returns the findings of that content in the same form as check.
fix
Preview or apply the fixes of findings named by id, safe or unsafe. Nothing is written unless apply is true; the result always includes the diff.
explain
Describe a rule (what it finds, its tier and level, how to configure and suppress it) or a finding by id (the finding, its fix, and the card of its rule). With rule and path, also say why the rule runs on that file or not.
suppress
Suppress one finding with a comment in the syntax of its file, placed and checked so that it suppresses only that finding. Use it when a finding is wrong or intended; the reason is kept in the code.
rules
List the rules with their tier, level and summary, one JSON object per line, and whether each runs on path.
status
Say which tree and configuration the server uses, and the counts and gate of the last check.
metrics
Measure the tree or some paths: lines of code, comment lines, complexity, nesting (complexity weighted by depth), length and parameters of functions, with totals, the functions that rank highest, and duplicated code. Read-only.
coverage
Line coverage from lcov, Cobertura or JaCoCo reports, mapped to the files of the tree: the total, the files with the most lines not run and, with changed or since, the coverage of the changed lines with the lines not run. Read-only.
gate
Evaluate the quality gate of tx0.toml: conditions on new code (with changed or since) and on the whole tree for findings by level, duplication, function complexity and coverage. Says which conditions fail and what makes them fail: functions over the complexity limit, new lines not covered, files with duplicated lines. Read-only.

What counts as new

The hook compares with the last commit. A finding is new when its file changed and the same finding, compared by rule and identity rather than by line, was not there before. Code that was moved or reformatted keeps its old findings out of the report, so an agent is not asked to fix what it did not write.

Each finding keeps its id across edits, so the agent can name it in tx0 fix --finding ID, tx0 explain ID or tx0 suppress ID --reason "...".

How long the hook takes

In Kubernetes (18 328 files checked), checking the edited file took 3 ms. The whole hook took 0.8 s, most of it bringing the index of the tree up to date. Measured with tx0 0.1.0-alpha.2, default tier, on a ThinkPad T14s Gen 1 (AMD Ryzen 7 PRO 4750U, 16 threads, 30 GB) that was running other work at a load average of 24 to 33, measured on 27 November 2026. Speed has the method.