Skip to content

jouet stats ​

jouet stats reports what jouet saved and what it cost, and the difference. It keeps two kinds of figure apart:

  • Measured figures are counted from the ledger that jouet setup's hooks write: jouet command runs, rule decisions from each rule's current revision, the sessions each rule fired in and how many of them it fired in more than once, what the agent did after a denial, the test, lint and build runs the checks rule recorded, sessions stopped from finishing after a failed check, and failing CI logs returned as the failing step's excerpt.
  • Estimated figures price those runs, and what jouet added, by your own Claude Code and Codex history from before setup, read the way jouet audit reads it.

The savings are what the runs would have cost at your rates before setup. That is an assumption, not a measurement: nothing records what an agent would have done without jouet. The costs are closer to measured, since the ledger records each block, denial and failure, but pricing them is an estimate too.

text
jouet stats [--since TIME] [--harness claude|codex|all] [--session ID] [--summary] [--json]

The flags are listed in the CLI reference. --since limits the ledger entries counted; the history before setup is the same whatever it says. The ledger keeps 30 days of rotated files, so measured figures reach back about that far.

Whether a rule changed what the agent did ​

A warning lets the call run and shows the agent a message, so the ledger cannot say directly whether the agent took the advice. What it can say is whether the same rule fired again later in the session. In the rules table, sessions counts the sessions a rule denied or warned in, and again those in which it did so more than once.

The table counts each rule only from its current revision: the ledger records with each decision a hash of the rule's [[rule]] table and script (see the ledger), and jouet stats compares it with the rules loaded in the directory it runs in. A rule that has changed since is counted afresh, so the table does not mix what an old version did with what the current one does. Decisions of an older revision, and those from before the ledger recorded revisions, are left out with a count, and rules the ledger names that are not loaded there (removed ones, or another repository's) are left out by name. What their denials and warnings cost is still counted. In --json, these are older_decisions and rules_not_loaded. A warning that fires again in most of its sessions is not changing what agents do there: its message may need rewording, or the rule may suit deny better, or none at all. The count is per session, so one agent repeating a command many times counts once.

overridden counts the same command run again soon after a deny or warning, and then jouet, then other and then nothing say what the agent ran next after a denial.

How the estimates work ​

A request re-reads the whole context, so a request avoided saves its whole input. For each kind of work, the history before setup gives how many requests a run of it took and how much context each request read:

jouet commandPriced by
jouet wait ci, wait run, wait prCI waits before setup: the requests after the first in each run of CI polls
jouet wait file, log, port, http, pid, cmdlinked runs of short, quiet checks of the same still-running process
jouet pr statusruns of PR status reads
jouet pr threadsruns of review-thread calls
jouet editthe share of edits that failed and were redone, less jouet edit's own failure rate
jouet testthe output a test, lint or build call gave the agent before setup, less what jouet test gave

Each harness is priced by its own history, which ends at that harness's first ledger entry. Every estimate shows its basis, such as "6,450 CI waits before setup, averaging 1.7 requests each at 305k tokens per request". A kind of work with fewer than 20 runs before setup is not estimated, and the report says so instead of guessing. Time saved is not estimated yet.

jouet edit is credited only for failing less often than edits did before setup: its runs times the difference in failure rate, at that history's tokens per request, assuming each failed edit before setup was redone once. When it failed as often or more, it is credited nothing, and the extra failures are a cost. Its own failure rate comes from the runs that recorded their own exit code (see own exit codes); without any, it is not estimated.

jouet test is credited for the output it keeps out of the context. Before setup, test, lint and build calls gave the agent some number of bytes of output on average. The credit is that average less what jouet test gave, over the calls that recorded their output size, at four bytes a token. The hooks record the size from Claude Code's tool_response, and only for a call that ran nothing but jouet test, since output shared with another command is not its alone. The credit counts that output once, though it stays in the context of every later request in the session, so it is a lower bound. A baseline saved before output sizes were kept asks for jouet stats --rescan.

Own exit codes ​

The hooks see the exit code of the whole call, so a call such as jouet edit replace ... && cargo test that fails on its tests looks like a failed edit. To tell the two apart, every jouet command run in an agent's session (one with CLAUDE_CODE_SESSION_ID, CODEX_THREAD_ID or JOUET_SESSION_ID set) appends a jouet-run line to the ledger with the command's name and its own exit code, never its arguments. Its harness is its session's, from the hooks' lines; a run in a session the hooks never saw is left out. Turning the ledger off ([hooks] ledger) turns this off too.

In the table of commands, calls failed counts the calls that ran a command and failed, on it or on whatever else they ran, and own runs and own failed count its runs that recorded their own exit code, and its own failures among them.

How the costs work ​

Each cost is priced the way the savings are, at the harness's average request before setup (its input tokens over its requests with token counts, which needs at least 20), and shows its basis:

CostCounted fromPriced as
finishing blocked, then finished with no check passingverify blocks in the ledger after which no test, lint or build passed before the session next stoppedone more request each
finishing held until a check passedverify blocks a passing check followed before the session next stoppednot priced: a correct change needs that check to pass anyway
calls a rule denieddenials in the ledgerone more request each, for the call again or another
failed jouet runsjouet commands that failed by their own exit code; in a session from before jouet recorded it, calls that ran nothing but jouet and failedone more request each
jouet edit failures beyond the rate before setupjouet edit's own failure rate, over all its runs, against edits before setupone more request for each failure past the old rate
requests carrying the session-start primerevery request in your history after setup, read each timethe primer's size, at four characters a token, on every request
rule warningswarnings in the ledgernot priced: a warning adds no request, but its text stays in the context

One request per event is an assumption, not a measured minimum: an agent may recover from several failures in one request, or spend several requests on one failure. The ledger alone does not show how many requests an event added. A failed run whose exit code is a check's answer is not a cost, since it fails without jouet too: exit 1 (or 124, or pr next's 10 and 20) from jouet test, wait, ci, secrets, http, pr status or pr next. A jouet search exit 1 means no matches and is not priced as a failure; search usage, missing-path and other errors still are. Older hook records that did not retain the search subcommand cannot be identified as searches. A search chained with another jouet command in a record without command-specific exits also remains ambiguous and is counted as a failed call. When a call ran a check and another jouet command, as in jouet edit replace ... && jouet test, and exited with the check's answer, calls failed counts it as the check's. jouet edit's failures are counted against the old rate instead, in their own line. The primer's requests include subagents', which may not read it, so that line can count high; its notes, such as the slow checks, are left out of its size.

The net is the savings less the costs, and may be negative. When a cost cannot be priced, as when the history after setup was not read or, with --session, none of that session's transcripts was found, there is no net rather than one that leaves the cost out. A harness with no history before setup at all, such as Cursor, can have neither its savings nor its costs priced: its costs are listed, left out of the net, and named under it. A saving that cannot be estimated counts as nothing.

The history before setup does not change, so jouet stats saves each harness's baseline and reuses it while that harness's first ledger entry and the jouet version stay the same, instead of reading the transcripts again. Reading them takes seconds on a large history. A harness with no ledger entries yet is always read, and --rescan reads them again.

Process-wait estimates need at least 20 linked opportunities in that history. A previously cached baseline that only grouped calls by category cannot support one; run jouet stats --rescan to rebuild it from the available transcripts. Unlinked or blocking waits are not evidence of avoidable requests.

Example ​

From the fixture ledger in jouet's tests, its decisions stamped with the current rules' revisions as the tests do, whose history before setup is far too thin to estimate from, so there is no net:

console
$ jouet stats
jouet stats: 14 ledger entries in 2 sessions, 2026-10-31T00:00:00Z to 2026-10-31T00:07:00Z

measured, from the ledger:
  command           harness  runs  calls failed  own runs  own failed  time
  jouet pr status   claude      1             0         0           0    1s
  jouet wait ci     claude      1             1         0           0    4m
  jouet edit        codex       1             0         0           0    0s
  jouet pr threads  codex       1             0         0           0    0s
  (calls failed: calls that ran it and failed, on it or on whatever else they ran; own: runs that recorded their own exit code)

  rule            deny  warn  sessions  again  overridden  then jouet  then other  then nothing
  python-edit        1     0         1      0           1           0           1             0
  review-threads     0     1         1      0           0           0           0             0
  sleep-poll         1     0         1      0           0           1           0             0
  (sessions: the sessions it denied or warned in; again: those in which it did so more than once)

  checks recorded: test 1 (1 failed)
  finishing blocked after a failed check: 1
  failing CI logs returned as the failing step's excerpt: 1

estimated savings: what these runs would have cost at your rates before setup (assumed, not measured):
  Claude Code (1 session before 2026-10-31T00:00:00Z):
  - jouet wait ci/run/pr: 1 run, not estimated: only 1 CI wait before setup, and an estimate needs 20
  - jouet pr status: 1 run, not estimated: only 1 PR status check before setup, and an estimate needs 20
  Codex (3 sessions before 2026-10-31T00:06:40Z):
  - jouet pr threads: 1 run, not estimated: only 0 review-thread rounds before setup, and an estimate needs 20
  - jouet edit: 1 run, not estimated: only 1 edit before setup, and an estimate needs 20

estimated costs, priced the same way:
  Claude Code:
  - finishing blocked, then finished with no check passing: 1, not estimated: only 8 requests with token counts before setup, and a price needs 20
  - calls a rule denied: 2, not estimated: only 8 requests with token counts before setup, and a price needs 20
  - requests carrying the session-start primer: 0, about 0 input tokens
      basis: 0 requests in the history after setup, subagents' included, each reading the primer's ~500 tokens
  Codex:
  - rule warnings: 1, not estimated: a warning adds no request, but its text stays in the context that later requests read; not priced
  - requests carrying the session-start primer: 0, about 0 input tokens
      basis: 0 requests in the history after setup, subagents' included, each reading the primer's ~505 tokens

estimated savings 0, costs 0: no net, since a cost above could not be priced.

Measured figures come from the ledger; estimates price them by your own history and are not measurements.

Without a ledger, jouet stats says so and shows what one run of each command would save, by your history.

The summary line ​

jouet stats --summary prints one line about what jouet saved, or nothing when there is nothing worth saying, for a stop hook to show at the end of a session (with --session). Every line carries a number the ledger recorded, and a line about tokens says it is an estimate:

text
jouet[savings]: 3 waits, zero 'is it done yet?'. about 2.4M tokens left unread (estimated).

It works out the same net as the report, reading only that session's transcripts after setup with --session, and never claims a saving the net does not support. When the net is below a saving it names, the line gives the net and says so ("estimated, net of jouet's costs"). When the costs are larger, the line is about them instead:

text
jouet[cost]: jouet cost about 686k more input tokens than it saved (estimated). the helper needed help.

When the net is unknown, the line names no tokens.

[stats] summary in ~/.config/jouet/config.toml, or JOUET_STATS_SUMMARY, sets the style: quips (the default), plain for the same fact stated plainly, or off for no line. A value jouet cannot read counts as the default, as with every setting, so a typo never breaks a stop hook. The summary reads the baseline the last full jouet stats saved under $XDG_STATE_HOME/jouet/stats, so it stays fast; until then it leaves estimates out, and names no tokens.

JSON ​

--json prints one document: ledger (where it is, whether it is there), measured (each command with runs, failed for the calls that failed, and own_runs and own_failed; and overhead, the per-harness counts the costs come from), baselines (one per harness, with its runs, requests and tokens per kind of work, and input_tokens over all its requests), estimates for the measured runs (or per_run without a ledger), estimated_input_tokens, after_setup (each harness's requests after setup and its primer_tokens), costs (each with kind, count, input_tokens and basis, and outside_net for a harness the net leaves out), estimated_cost_tokens, net_input_tokens (savings less costs, negative when jouet cost more, absent when a cost could not be priced), scan (reading the history before setup) and after_setup_scan. An estimate or cost that was refused has refused with the reason and no input_tokens. Fields that are zero or empty are left out.

Exit codes ​

0 with a report, including without a ledger; 2 for a usage error; 1 when the ledger cannot be read.

MIT LicenseCopyright © 2026jdx.dev