PRECC
Latest: v0.3.112
PRECC v0.3.112
PRECC now runs inside the DeepSeek Harness
PRECC's command correction has so far needed Claude Code's PreToolUse hook.
The DeepSeek Harness (DSH) has no such event, so DSH sessions ran with no
correction and contributed nothing to PRECC's savings measurements. This
release ships a native DSH plugin that closes that gap.
- A native DSH plugin (
plugins/dsh). It listens to DSH'stools/executewaterfall, asksprecc-hookfor a rewrite using a Claude-compatiblePreToolUseevent, and runs the rewritten command inside the same authorised tool call — so wrong-directory commands get corrected and verbose output gets wrapped through RTK/lean-ctx/nushell, exactly as under Claude Code. - Savings are measured in DSH too. The plugin sends a best-effort
PostToolUseobservation, so DSH sessions now feed PRECC's savings metrics instead of being invisible to them. - Fails open, by design. A missing hook, a timeout, malformed JSON, or an
unchanged command all let the original command run untouched. A broken hook
can never block a command. A PRECC
denyis surfaced as a tool error. - No DSH or npm dependencies. The plugin uses only
tools/executeand no package-private DSH imports, so it pins no private DSH sub-package version. It intercepts only thebashtool; DSH's nativeread,grepandglobare untouched.
Install is dsh plugin --profile <name> add <path>/plugins/dsh, then restart
the profile — the bundle patch inserts a precc-bash row with enabled: true,
which can be disabled from the plugin config. README.md documents it as
"Option 4: DeepSeek Harness (DSH)".
Judge-labelled command classes (opt-in)
PRECC picks a compressor from the two-word command class (git status,
cargo build). Measured on session logs, that class is precise but only fires
on classes it already has history for — it cannot see a flood coming from a
line-range dump or an && chain it has never met. This release adds an opt-in
second opinion for exactly those cases.
- A judge labels commands off the hot path. Point
PRECC_JEV_URLat a local System One endpoint (jev-rs, any GGUF) andprecc-learnerlabels Bash commands with a semantic class and a flood probability, then publishes two flat snapshots. The hook only reads those snapshots and never calls a model, so the sub-5ms budget is untouched. - Semantic classes pool thin evidence. A
sem:<class>row aggregates measurements across two-word classes, and is consulted only when the exact class has no row of its own — so it adds coverage without overriding anything PRECC has measured directly. - Flood predictions pick the strongest compressor. An exact command predicted to flood at ≥ 0.80 is routed through lean-ctx, or RTK when lean-ctx is off.
- Off by default. With
PRECC_JEV_URLunset both snapshots stay empty and behaviour is identical to v0.3.111. When a label does fire it is recorded in the hook's reasons asjev-class:<class>orjev-flood:<p>.
Model size matters for this one: a 4B model scored at chance on the labelling
task, while a 73 GB model reached 0.53 precision / 0.53 recall on floods the
command class misses, taking the union's recall to 0.74. Point
PRECC_JEV_URL at a large model or leave the feature off.
Upgrade
precc update # macOS / Linux
iwr -useb https://peria.ai/install.ps1 | iex # Windows
PRECC — Predictive Error Correction for Claude Code
PRECC saves ~34 % of Claude Code costs through three savings pillars: correcting bash commands before they fail, compressing tool output, and reducing context token usage via semantic search and file compression. v1.1 adds a token-cost prediction oracle (precc predict) that ships its own trainable ridge model, and opt-in counterfactual telemetry for measuring would-have-run vs. did-run deltas. Ships as a single Rust binary.
Three Savings Pillars
Pillar 1: Command Correction & Output Compression
- Fixes wrong-directory commands — Detects when
cargo buildornpm testis run in the wrong directory and prependscd /correct/path && - Prevents repeated failures — Learns from past session failures and auto-corrects commands that would fail the same way
- Compresses CLI output — Rewrites verbose commands for 60-90% smaller output via RTK
- Suggests GDB debugging — When a command fails repeatedly, suggests
precc debug
Pillar 2: Semantic Code Search (cocoindex-code)
- Optional AST-aware semantic search across 28+ languages, saving ~70% of search tokens
- Built into the
precc-hookbinary; no extra scripts needed - Requires separate
cocoindex-codeinstall (pipx install cocoindex-code)
Pillar 3: Context File Compression
- Strips filler words from CLAUDE.md and memory files via
precc compress - Reduces tokens loaded on every API call (~30 % compression)
- Backups saved automatically, revertible with
precc compress --revert
Token-Cost Prediction Oracle (v1.1)
precc predict records a prediction → actual labelled dataset for any
multi-step task you plan in tokens (never in wall-clock time). It ships
two predictors:
heuristic-1— rule-based category × length estimator, available out of the box.trained-v1— closed-form ridge regression on category + log(description length), persisted to~/.local/share/precc/predict_model.json. Fit it from your own closed predictions withprecc predict --train; subsequent predictions are taggedtrained-v1automatically.
precc predict "<task description>" # log a prediction
precc predict --record <id> <actual_tokens> # close the loop
precc predict --train # fit trained-v1
precc predict --eval # MAPE per category
Counterfactual Telemetry (v1.1, opt-in, dormant by default)
The hook can record a (would-have-run, did-run, outcome) triple per
Bash invocation to a SQLCipher-encrypted store at
~/.local/share/precc/triples.db. The stream is opt-in only —
disabled by default; you turn it on per machine via the [counterfactual]
section of consent.toml (CLI ceremony lands in a future release).
A daily-rotated salt + agent-class fingerprint keeps the data
re-identification-resistant; nothing leaves the machine until a separate
upload path is configured. The telemetry schema is designed for k-anonymity,
with a documented threat model.
Install
curl -fsSL https://peria.ai/install.sh | bash
precc init
The install script downloads a platform-specific binary from GitHub Releases, verifies its SHA256 checksum, and places it in ~/.local/bin. It then configures a PreToolUse hook in ~/.claude/settings.json.
Live Status Line
PRECC includes a built-in status line that shows real-time session metrics directly in the Claude Code terminal:
PRECC: 12 fixes, ~3.6K tokens saved | 2.1ms avg
The status line is automatically configured during installation. It shows:
- Corrections — commands fixed in the current session
- Tokens saved — estimated token savings from all corrections
- Hook latency — average hook execution time
To enable manually, add to ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "~/.local/bin/precc-hook --statusline"
}
}
What PRECC Modifies
~/.claude/settings.json— Adds aPreToolUsehook entry pointing toprecc-hook~/.local/share/precc/— SQLite databases for learned failure-fix patterns and skill heuristics~/.local/bin/— Installsprecc,precc-hook, andprecc-learnerbinaries
Usage
Once installed, PRECC works automatically as a PreToolUse hook.
# Mine existing session history for failure-fix patterns
precc ingest --all
# View what PRECC has learned
precc skills list
# View unified savings report (all three pillars)
precc savings
# Semantic code search (requires cocoindex-code)
ccc init && ccc index
ccc search "authentication middleware"
# Compress context files
precc compress --dry-run # preview
precc compress # compress
precc compress --revert # revert
# Token-cost prediction (v1.1)
precc predict "<task description>"
precc predict --record <id> <actual_tokens>
precc predict --train # fit trained-v1 once you have ≥ 10 actuals
precc predict --eval # mean error / MAPE
Measured Results
| Metric | Value |
|---|---|
| Cost savings | $296 / $878 (34%) |
| Failures prevented | 352 / 358 (98%) |
| Bash calls improved | 894 / 5,384 (17%) |
| Cache reads saved | 988M / 1.67B tokens (59%) |
| Hook latency | 2.93ms avg (1.77ms overhead) |
Links
- GitHub: https://github.com/peri-a-i/precc-cc
- ClawHub: https://clawhub.ai/skills/precc
- cocoindex-code: https://github.com/cocoindex-io/cocoindex-code
- RTK: https://github.com/rtk-ai/rtk
