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.

Safety Notice

This listing is from the official public ClawHub registry. Review SKILL.md and referenced scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "precc-token-saver" with this command: npx skills add yijunyu/precc-token-saver

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 PreToolUse hook (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 through precc-hook before 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:

  1. Construct the JSON payload for precc-hook
  2. Pipe it through precc-hook on stdin
  3. Read the (possibly rewritten) command from stdout
  4. 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:

  1. Always route shell/bash tool calls through precc-hook by constructing the hook JSON payload and parsing the response before execution.
  2. On session start, run precc init if the databases are absent.
  3. On session end, optionally run precc report and summarise savings.
  4. 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.command is 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

MIT — https://github.com/yijunyu/precc-cc

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

Feishu Calendar Intelligent Scheduler

飞书智能日历调度器 - 自动推荐最佳会议时间,批量管理日程,生成会议报表

Registry SourceRecently Updated
180Profile unavailable
Automation

Charmie CRM Lite

Lightweight CRM with SQLite – manage contacts. Upgrade to Pro for email, messaging, and more.

Registry SourceRecently Updated
521Profile unavailable
Automation

Proactive Claw

🦞 The most powerful proactive engine for OpenClaw. Your personal assistant that learns from you and helps you be more productive.

Registry SourceRecently Updated
9243Profile unavailable
Coding

Tesla Commander

Command and monitor Tesla vehicles via the Fleet API. Check status, control climate/charging/locks, track location, and analyze trip history. Use when you ne...

Registry SourceRecently Updated
1790Profile unavailable