precc-token-saver
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.
- License 许可
- MIT
- 最近更新
- 2026-06-10
- Stars
- ★ 3
- Forks
- 0
01 前言 Front Matter
- name
- precc-token-saver
- emoji
- ⚡
- version
- 0.1.8
- metadata
- { "openclaw": { "os": [ "darwin", "linux" ], "emoji": "⚡", "install": [ { "tap": "yijunyu/tap", "bins": [ "precc", "precc-hook" ], "kind": "brew", "formula": "precc" } ], "homepage": "https://github.com/yijunyu/precc-cc", "requires": { "bins": [ "precc-hook", "precc" ] } } }
- 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.
- user-invocable
- true
- disable-model-invocation
- false
03 SKILL.md 正文
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 native
PreToolUsehook (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 build
Setup
# 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 --all
Commands
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-hook
Parse 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 skill
License
04 同仓库更多 Skills
youtube-content
YouTube transcripts to summaries, threads, blogs.
xurl
X/Twitter via xurl CLI: post, search, DM, media, v2 API.
touchdesigner-mcp
Control a running TouchDesigner instance via twozero MCP — create operators, set parameters, wire connections, execute Python, build real-time visuals. 36 native tools.
test-driven-development
TDD: enforce RED-GREEN-REFACTOR, tests before code.
teams-meeting-pipeline
Operate the Teams meeting summary pipeline via Hermes CLI — summarize meetings, inspect pipeline status, replay jobs, manage Microsoft Graph subscriptions.
systematic-debugging
4-phase root cause debugging: understand bugs before fixing.