precc
Predictive error correction for LLM-driven shells.

precc is a PreToolUse:Bash hook for Claude Code (and similar agentic
shells) that rewrites commands before they run, turning what would have
been a failed turn into a successful one. It is the missing input-shaping
layer that sits next to output-compressing tools.
What it does
Four pillars, one hook:
- Context resolution —
cargo buildoutside a Rust project?preccprepends the rightcd. - GDB opportunities — repeated failures on the same command get a one-line diagnostic hint.
- Pattern mining — failure → fix pairs in your shell history are distilled into preventions for next time.
- Skills — high-confidence patterns auto-apply:
git statusin ajj-colocated repo becomesjj status;asciinema recbecomesprecc gif; …
Optional fifth: pluggable output compressors (e.g. rtk) — opt-in
via ~/.config/precc/config.toml.
Status
v0.1 — early release. The hook, skills system, and metrics are
operational; the compressor layer ships with two adapters (none,
rtk) and is extensible.
Install
Then add to your Claude Code settings.json:
{
"hooks": {
"PreToolUse": [
{ "matcher": "Bash", "hooks": [{ "type": "command", "command": "precc-hook" }] }
]
}
}
Other tools
PRECC also ships first-class shims for two more agentic-coding tools:
Cursor
Cursor exposes a beforeShellExecution hook. Install precc-cursor-hook
and drop examples/cursor/hooks.json at
~/.cursor/hooks.json. Note: Cursor's hook protocol is allow/deny only
(no rewrite field), so PRECC denies wrong-dir commands and surfaces the
corrected invocation via agent_message. The agent re-runs the
suggested command on the next turn.
Aider
Aider has no hook surface. PRECC ships precc-shell,
a thin $SHELL wrapper. Install it and set SHELL=$(which precc-shell);
Aider's /run invocations now flow through PRECC. See
examples/aider/ for details.
License
Dual-licensed under MIT or Apache-2.0, at your option.