How session savings are counted
Read the local savings ledger, understand per-tool baselines, and distinguish estimates from measured counts.
The savings ledger estimates the difference between a tool's baseline and its compact result. It does not measure your entire session bill. The benchmark methodology describes the separate reference workload, its date, and per-call results. Those percentages are not a guarantee for another project or session.
What the counters mean
For each recorded call, recordSaving(rawBytes, compactBytes, tool) adds max(0, ceil((rawBytes - compactBytes) / 4)) to tokensSaved. It adds ceil(rawBytes / 4) to lifetime.rawTotal, the denominator used for the saved percentage. A result larger than its baseline records zero saved tokens.
The arguments are size estimates supplied by each tool. Several callers use JavaScript string lengths, so the result is a heuristic, not an exact tokenizer measurement. The byTool maps contain calls and tokensSaved, not byte counts or dollar amounts. See the stats schema.
Reads depend on the file and mode
ashlr__read can return an AST skeleton for supported large files, compact head and tail content, or an LLM summary. Small files can return their full content with line numbers and accounting notes. Savings vary with the file, mode, and available provider; there is no fixed saving for every qualifying file.
bypassSummary: true skips AST and LLM summarization. A range read with startLine and endLine returns numbered lines directly and does not record a savings entry. Repeated whole-file cache hits credit the source-size baseline again. These accounting choices affect the ledger, so it is not a trace of every token delivered to the host. See read modes and ranges.
Edit baselines
ashlr__edit uses search.length + replace.length as its baseline, then subtracts the compact confirmation's length. For strict: false with multiple matches, the implementation adds a 500-character context allowance once. It does not multiply the baseline by the match count.
ashlr__multi_edit sums each edit's search and replacement lengths across the batch. Neither tool uses the complete file before and after as its savings baseline. A short edit can therefore record zero saved tokens even in a large file.
Hooks and session identity
The Bash hook suggests ashlr__bash for supported verbose commands in both redirect and nudge modes. It never blocks or redirects the native Bash call. ASHLR_HOOK_MODE=off disables the suggestion. Native Bash calls do not contribute to the ashlr savings ledger; recorded ashlr__bash calls do. Run /ashlr-status to inspect the host's mode.
Session buckets use CLAUDE_SESSION_ID when available, then a recent session-start hint, then a parent-process-derived ID. Sub-agent calls only get a separate bucket when they resolve to a different session ID. Session displays can combine matching buckets; lifetime totals include all recorded sessions. See session buckets.
Genome search
ashlr__grep can return matching genome sections and, when available, merged PRs and closed issues. It falls back to ripgrep when genome retrieval does not produce a result. Its savings depend on the selected retrieval path and result size. Use /ashlr-genome-init to build project memory, and consult the benchmark methodology for the measured reference workload.
Inspect the JSON ledger
In a terminal:
The first command reads ~/.ashlr/stats.json and returns schema, schemaVersion, sessions, and lifetime. Replace example-session with a key from sessions. The tool filter selects lifetime.byTool; the session filter selects one session bucket. A missing slice returns {"schema":"ashlr-plugin.stats.v1","value":null}. These CLI commands read the JSON file, including when an optional SQLite backend is configured for tool accounting.
Inside Claude Code, use /ashlr-savings for a session and lifetime summary, /ashlr-dashboard for charts and tool breakdowns, or /ashlr-handoff for a session snapshot.
Dollar figures are computed when reports render, using the selected model's input-token price. ASHLR_PRICING_MODEL overrides model selection. The status line can use the detected summarizer's price, while other reports use the shared pricing helper. These are cost estimates, not credits applied to a provider invoice. See status-line fields.
API-measured and estimated counts
Ordinary tool accounting defaults to measurementMode: "estimate". Setting ANTHROPIC_API_KEY does not automatically measure every tool call or convert the ledger to measured counts.
The benchmark's optional --validate-tokenizer mode calls measureTokens() on a sample to compare its heuristic with Anthropic usage counts. This sends sampled content to the configured Anthropic endpoint and can incur API charges; it is separate from local ledger recording. See the benchmark guide before enabling it.
The ledger supports tokensSavedMeasured and measuredCalls for entries explicitly recorded as measured. When lifetime measuredCalls reaches 10, the status-line lifetime total and the savings report's saved-token columns display tokensSavedMeasured with (API-measured). That is the measured subset, which can be smaller than tokensSaved. Other fields can still use the overall estimate; the label does not certify the whole ledger.
Related
- Savings: the command that presents this ledger
- Dashboard: charts and tool breakdowns
- Benchmark: measure the reference workflow on your code
- Stats schema: the on-disk format
- Automatic hooks: host lifecycle and tool hooks