ClawGuard operates securely inside OpenClaw to actively compress massive payloads, prune history, and dynamically route simple tasks to cheap models. Save up to 80% on API costs.
npm install -g clawguard
# Installs the ClawGuard CLI and Hook globally.
npm install -g clawguard && clawguard init
Requires Node.js 18+. The init command will automatically detect your ~/.openclaw directory and safely inject the Trustless Hook.
Generic API routers blindly charge you for massive 100k token payloads. ClawGuard actually looks inside OpenClaw and actively shrinks the payload before it leaves your machine.
OpenClaw injects your massive SOUL.md character file on every turn. If you ask "What is 2+2?", we temporarily strip the 5,000-word backstory because the AI doesn't need to know its persona to do math.
SOUL.md
Instead of sending history back and forth forever, we aggressively condense old turns (like a 2,000 word email draft) into a single, dense memory block. Facts are retained, fluff is deleted.
Even if OpenClaw is configured to use Claude 3.5 Opus, if we intercept a simple request, we silently override the target model to Haiku locally to save you money.
OpenClaw sends background check-ins. ClawGuard recognizes these and instantly returns a mock success response locally. Cost drop from $0.15 to $0.00.
When OpenClaw runs a command (like `git log`), the massive terminal output gets stuck in the history forever. Our Fast Math engine dynamically replaces old tool outputs with a 1-sentence summary, instantly deleting thousands of tokens securely.
Set a hard daily spending limit. ClawGuard tracks your real-time token usage locally and securely blocks API calls before you accidentally wake up to a massive AI bill.
We know developers hate proxies because it means giving up API keys. That's why ClawGuard is not a proxy. It is a Native OpenClaw Hook.
ClawGuard runs in-memory *before* OpenClaw attaches your keys. We never see your API tokens.
All heuristics and context trimming happen locally on your hardware. We don't send your data to our servers.
No waiting on external router servers. We run entirely as local TypeScript inside OpenClaw's loop.
// 1. Intercept before OpenClaw sends export default async function hook(event) { if (event.type === 'agent:bootstrap') { // 2. Analyze the messages array locally const payload = event.context; // 3. Condense context if it exceeds 5k tokens if (payload.tokenCount > 5000) { payload.messages = compressMemory(payload.messages); log('Saved $0.15 this turn.'); } } }
Join the community
Learn the ropes
View the source
Download skills