Install
openclaw skills install @yijunyu/preccPredictive Error Correction for Claude Code — corrects bash commands before execution, predicts token costs via a trained ML oracle, and captures opt-in counterfactual telemetry
openclaw skills install @yijunyu/preccPRECC 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.
cargo build or npm test is run in the wrong directory and prepends cd /correct/path &&precc debugprecc-hook binary; no extra scripts neededcocoindex-code install (pipx install cocoindex-code)precc compressprecc compress --revertprecc 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 with precc predict --train; subsequent
predictions are tagged trained-v1 automatically.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
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.
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.
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:
To enable manually, add to ~/.claude/settings.json:
{
"statusLine": {
"type": "command",
"command": "~/.local/bin/precc-hook --statusline"
}
}
~/.claude/settings.json — Adds a PreToolUse hook entry pointing to precc-hook~/.local/share/precc/ — SQLite databases for learned failure-fix patterns and skill heuristics~/.local/bin/ — Installs precc, precc-hook, and precc-learner binariesOnce 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
| 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) |