Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Savings

PRECC tracks estimated token savings from every interception. Use precc savings to see how much waste PRECC has prevented.

Quick Summary

$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Breakdown:
  Pillar 1 (cd prepends):         <span data-stat="session_p1_tokens">3,204</span> tokens  (<span data-stat="session_p1_count">6</span> corrections)
  Pillar 4 (skill activations):   <span data-stat="session_p4_tokens">1,560</span> tokens  (<span data-stat="session_p4_count">4</span> activations)
  RTK rewrites:                   <span data-stat="session_rtk_tokens">2,749</span> tokens  (<span data-stat="session_rtk_count">11</span> rewrites)
  Lean-ctx wraps:                 <span data-stat="session_lean_tokens">1,228</span> tokens  (<span data-stat="session_lean_count">2</span> wraps)

Detailed Breakdown (Pro)

$ precc savings --all
Session Token Savings (Detailed)
================================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Command-by-command:
  #  Time   Command                          Saving   Source
  1  09:12  cargo build                      534 tk   cd prepend (cargo-wrong-dir)
  2  09:14  cargo test                       534 tk   cd prepend (cargo-wrong-dir)
  3  09:15  git status                       412 tk   cd prepend (git-wrong-dir)
  4  09:18  npm install                      824 tk   cd prepend (npm-wrong-dir)
  5  09:22  find . -name "*.rs"              387 tk   RTK rewrite (output truncation)
  6  09:25  cat src/main.rs                  249 tk   RTK rewrite (lean-ctx wrap)
  7  09:31  cargo clippy                     534 tk   cd prepend (cargo-wrong-dir)
  ...

Pillar Breakdown:
  Pillar 1 (context resolution):   <span data-stat="session_p1_tokens">3,204</span> tokens  <span data-stat="session_p1_pct">36.6</span>%
  Pillar 2 (GDB debugging):            0 tokens   0.0%
  Pillar 3 (mined preventions):        0 tokens   0.0%
  Pillar 4 (automation skills):    <span data-stat="session_p4_tokens">1,560</span> tokens  <span data-stat="session_p4_pct">17.8</span>%
  RTK rewrites:                    <span data-stat="session_rtk_tokens">2,749</span> tokens  <span data-stat="session_rtk_pct">31.5</span>%
  Lean-ctx wraps:                  <span data-stat="session_lean_tokens">1,228</span> tokens  <span data-stat="session_lean_pct">14.1</span>%

How Savings Are Estimated

Each correction type has an estimated token cost based on what would have happened without PRECC:

Correction TypeEstimated SavingReasoning
cd prepend~500 tokensError output + Claude reasoning + retry
Skill activation~400 tokensError output + Claude reasoning + retry
RTK rewrite~250 tokensVerbose output that Claude would have to read
Lean-ctx wrap~600 tokensLarge file contents compressed
Mined prevention~500 tokensKnown failure pattern avoided

These are conservative estimates. Actual savings are often higher because Claude’s reasoning about errors can be verbose.

Cumulative Savings

Savings persist across sessions in the PRECC database. Over time, you can track the total impact:

$ precc savings
Session Token Savings
=====================
Total estimated savings: <span data-stat="session_tokens_saved">8,741</span> tokens

Lifetime savings: <span data-stat="total_tokens_saved">142,389</span> tokens across <span data-stat="total_sessions">47</span> sessions

Status Bar

After installation, PRECC wires a statusLine entry into ~/.claude/settings.json so the Claude Code status bar shows live session metrics:

$0.42 spent | 1.2M in/out | 📊 last cmd: −1.2K | PRECC: 7 fixes | 5.8ms avg | this session: 320 saved over 7 cmds (~$0.05) | lifetime: 8.9K saved over 217 cmds (~$2.85)

Each segment:

SegmentSourceMeaningResets on session restart?
$0.42 spentClaude Code’s cost.total_cost_usdCumulative session cost reported by Claude CodeYes
1.2M in/outClaude Code’s total_input_tokens + total_output_tokensNon-cached input + output tokens across the sessionYes
📊 last cmd: −1.2KPRECC measurement of the most recent Bash commandReal ground-truth saving from re-running the originalNo (persists across sessions)
PRECC: 7 fixesPRECC session aggregate from metrics.logNumber of corrections this session — fix count only, no fake token estimateYes
5.8ms avgPRECC hook latency p50Time PRECC spent processing each tool callYes
bash 18% of totalPRECC post_observations.log filtered by session windowShare of session tokens that came from Bash output — clarifies why PRECC’s savings are naturally a fraction of total cost (PRECC only optimizes Bash output)Yes
this session: 320 saved over 7 cmds (~$0.05)~/.local/share/precc/.lifetime_summary.json minus the per-session baseline at ~/.local/share/precc/sessions/<session_id>.savings_baselineReal per-session delta. Baseline is captured the first time PRECC sees this session_id; subsequent refreshes compute current_lifetime − baseline so the value reflects savings accrued in this session only. Hidden when delta is zero (start of session)Yes (baseline re-snapshots)
lifetime: 8.9K saved over 217 cmds (~$2.85)~/.local/share/precc/.lifetime_summary.json + current session’s cost.total_cost_usd / total_used_tokens rateCumulative tokens saved and re-measured commands since PRECC was first installed, plus an estimated USD value computed from the current session’s per-token rate. Cost estimate is conservative — it uses (input+output) as the denominator while the cost includes cache tokens, so the per-token rate is overstated and the resulting savings figure is lower than actualNo

The lifetime: segment is placed last so it’s the first to be truncated if Claude Code’s UI clips the bar at the right edge.

Why cost and token count don’t divide

The displayed 1.2M in/out is not the denominator that produced $0.42 spent. Claude Code’s cost.total_cost_usd is computed from the API’s full token breakdown — base input, output, plus cache reads and cache creations. The session-wide cumulative cache token counts are not exposed in the statusline schema, so PRECC can only show the visible (non-cache) portion.

On long sessions with heavy file rereads, cache reads can be 10× the visible token count. That’s why pairing the two as a ratio would mislead — PRECC shows them as independent segments instead.

Why PRECC doesn’t compute the cost

The cost number is authoritative. PRECC reads cost.total_cost_usd verbatim from the JSON Claude Code pipes into the status command on stdin. That’s the same number Claude Code charges against your subscription/usage budget. You can verify it any time with the built-in /cost slash command — both should agree.

What drives the cost

For Claude Opus 4.6:

Token typeStandard (≤200k context)1M context tier
Input$15 / MTok$30 / MTok
Output$75 / MTok$150 / MTok
Cache write$18.75 / MTok$37.50 / MTok
Cache read$1.50 / MTok$3 / MTok

The biggest drivers on long sessions are usually:

  1. Output tokens — most expensive per-token type, especially on the 1M context tier
  2. Repeated cache reads — cheap individually but accumulate fast across many turns
  3. Cache creations — written once per file read, ~1.25× the base input rate

PRECC reduces the visible-token cost by compressing Bash output (the 📊 last cmd: segment shows the per-command saving), but it cannot reduce cache reads of files Claude has already loaded.

Stable session counts

The “PRECC: N fixes” segment counts events since the persisted session start, written to ~/.local/share/precc/sessions/<session_id>.start on the first statusline refresh of each session. This makes the count monotonic — it cannot drop mid-session even if cost.total_duration_ms is missing on a particular refresh (which would otherwise collapse the window to “since now” and silently drop nearly all events).

Auto-refreshed lifetime snapshot

The lifetime: segment reads ~/.local/share/precc/.lifetime_summary.json, which is rewritten:

  • On every PostToolUse measurement (so it stays current as commands accumulate)
  • On every precc savings invocation

The this session: segment reads the same lifetime file but subtracts a per-session baseline persisted to ~/.local/share/precc/sessions/<session_id>.savings_baseline on the first refresh of each session.

No need to manually refresh anything — the files update themselves.

Suppressing the status bar

If you’d rather keep your existing status bar, set your own statusLine command in ~/.claude/settings.json. PRECC’s installer will detect the custom value and leave it alone on subsequent updates.

To suppress only the per-interaction 📊 PRECC line (in additionalContext), set PRECC_QUIET=1 in your shell environment.