- name
- precc-token-saver
- description
- Before running any shell command, pipe it through the PRECC hook to fix wrong-directory errors, compress CLI output, and apply learned heuristics — saving 34%+ of API token spend automatically.
- version
- 0.1.8
- emoji
- ⚡
- user-invocable
- true
- disable-model-invocation
- false
- metadata
- openclaw
- emoji
- ⚡
- homepage
- https://github.com/yijunyu/precc-cc
- os
- requires
- bins
- install
- tap
- yijunyu/tap
- formula
- precc
- bins
- [precc, precc-hook]
PRECC Token Saver
PRECC (Predictive Error Correction) intercepts every shell command before it runs. In under 3ms it:
- Fixes wrong-directory errors — detects the correct project root and prepends
cd /correct/path && - Compresses CLI output — rewrites commands through RTK (60–90% smaller output)
- Applies learned skills — uses patterns mined from past sessions to prevent repeated failures
- Translates git→jj — auto-converts git commands in Jujutsu repos (saves ~40 tokens per
git add)
Measured results (29 real sessions, 5,384 bash calls):
- 34% cost saving ($296 saved from $878 baseline)
- 98% of failures prevented (352/358)
- 2.93ms average hook latency
How it works in OpenClaw
Note: OpenClaw does not yet have a nativePreToolUsehook (unlike Claude Code). This skill works via prompt-level instruction: the SKILL.md is loaded into the agent's context and the agent is instructed to manually pipe every shell command throughprecc-hookbefore executing it. Interception is LLM-enforced, not OS-level. A native hook equivalent is tracked in openclaw/openclaw#7597.
When PRECC Token Saver is active, the agent follows this pattern for every shell command it wants to run:
- Construct the JSON payload for
precc-hook - Pipe it through
precc-hookon stdin - Read the (possibly rewritten) command from stdout
- Execute the rewritten command instead of the original
Agent wants to run: cargo build
↓
precc-hook receives: {"tool_input": {"command": "cargo build"}}
precc-hook outputs: {"hookSpecificOutput": {"updatedInput": {"command": "cd /path/to/project && rtk cargo build"}}}
↓
Agent executes: cd /path/to/project && rtk cargo buildSetup
# Install PRECC
curl -fsSL https://raw.githubusercontent.com/yijunyu/precc-cc/main/scripts/install.sh | bash
# Initialise (one-time)
precc init
# Mine existing session history (optional)
precc ingest --allCommands
Once the skill is loaded, you can address the agent directly:
@precc report— show token savings and command statistics@precc skills list— list active correction skills@precc update— update PRECC binaries to the latest release@precc savings— show dollar-value savings estimate
Skill behaviour
This skill is loaded as a system-level instruction into the agent's context. The agent (not the platform) is responsible for enforcing the hook pattern.
The agent is instructed to:
- Always route shell/bash tool calls through
precc-hookby constructing the
hook JSON payload and parsing the response before execution.
- On session start, run
precc initif the databases are absent. - On session end, optionally run
precc reportand summarise savings. - Never skip the hook even for simple commands — the latency is <3ms and the
hook is fail-open (any error → original command is used unchanged).
Hook invocation pattern
# Wrap any command through precc-hook:
echo '{"tool_input":{"command":"YOUR_COMMAND_HERE"}}' | precc-hookParse the JSON response:
- If
.hookSpecificOutput.updatedInput.commandis non-empty → use it - Otherwise → use the original command unchanged
Advanced: savings report
precc report # full analytics dashboard
precc savings # dollar-value breakdown
precc skills list # active skills
precc skills show <name> # detail for one skillLicense
MIT — https://github.com/yijunyu/precc-cc