Install
openclaw skills install @asif2bd/openclaw-token-optimizerOpenClaw Token Optimizer v3.2.0 — practical cost-control toolkit for OpenClaw agents. Lazy context loading, Sonnet/Opus-aware routing, heartbeat scheduling, local token budgets, cache-TTL guidance, and security-audit-safe command behavior for current OpenClaw 2026.6.x installs.
openclaw skills install @asif2bd/openclaw-token-optimizerBuilt for current OpenClaw 2026.6.x agents by Asif2BD · GitHub · Security Notes
Security notice: local-only optimization toolkit. The Python scripts make no network requests and do not execute dynamic code. Commands that write files are explicit, documented, and backup-safe.
openclaw skills install @asif2bd/openclaw-token-optimizer
The skill card now leads with a clearer product promise, current OpenClaw compatibility, security posture, and practical commands instead of the older long-form v3.0 copy.
Routine Anthropic work maps to anthropic/claude-sonnet-4-5; only explicitly complex reasoning routes to anthropic/claude-opus-4-5.
context_optimizer.py generate-agents prints to stdout by default.AGENTS.md requires --output or --workspace-output../scripts/optimize.sh heartbeat previews only by default../scripts/optimize.sh heartbeat install writes HEARTBEAT.md only after backing up an existing file.Stop loading every workspace file into every session. Recommend only the context needed for the current prompt.
python3 scripts/context_optimizer.py recommend "hi"
Typical result: SOUL.md + IDENTITY.md only for a greeting.
Keep standard work on Sonnet and reserve Opus for deep reasoning.
python3 scripts/model_router.py "thanks!"
python3 scripts/model_router.py "design a multi-agent architecture"
Run only checks that are due, respect quiet hours, and align heartbeat timing with prompt-cache TTL.
python3 scripts/heartbeat_optimizer.py plan
python3 scripts/heartbeat_optimizer.py cache-ttl
Track local daily budget state and surface warnings before runaway spend.
python3 scripts/token_tracker.py check
python3 scripts/context_optimizer.py recommend "write a deployment checklist"
python3 scripts/context_optimizer.py generate-agents
Save a review copy only when you explicitly ask for it:
python3 scripts/context_optimizer.py generate-agents --output ~/.openclaw/workspace/AGENTS.md.optimized
./scripts/optimize.sh heartbeat
Install with backup protection:
./scripts/optimize.sh heartbeat install
python3 scripts/model_router.py "debug this error"
| Area | Typical waste | Optimizer approach |
|---|---|---|
| Startup context | Loading docs, memory, tools, and old logs every turn | Lazy-load only what the prompt needs |
| Routine model use | Opus used for quick replies or simple checks | Sonnet for routine work, Opus for complex reasoning |
| Heartbeats | Every check runs on every heartbeat | Due-check planner + quiet hours |
| Cache TTL | Idle sessions trigger expensive cache rewrites | 55-minute heartbeat guidance for 1-hour cache TTL |
| Budget control | Spend discovered after the fact | Local budget checks before expensive work |
Expected savings: 50-80% in context-heavy OpenClaw workspaces, with context optimization usually delivering the biggest win.
scripts/context_optimizer.py — prompt classification and context bundle recommendationsscripts/model_router.py — Sonnet/Opus-aware task routingscripts/heartbeat_optimizer.py — due-check planning, quiet hours, cache-TTL interval guidancescripts/token_tracker.py — local budget trackingscripts/optimize.sh — convenience wrapper around bundled scriptsassets/HEARTBEAT.template.md — backup-safe heartbeat templateassets/cronjob-model-guide.md — scheduled-task model guidanceassets/config-patches.json — native and optional config examplesreferences/PROVIDERS.md — optional external-provider strategy notesSECURITY.md — complete security and data-handling breakdowneval, dynamic imports, shell command execution, or downloader behaviorHEARTBEAT.md is backed up before replacement.clawhubsafe covers every published file with SHA256 hashesVerify locally:
sha256sum -c .clawhubsafe
Use OpenClaw's built-in context and usage commands alongside this skill:
/context list
/context detail
/usage tokens
/usage cost
Use the built-ins to see where tokens are going, then use Token Optimizer to reduce the recurring waste.
openclaw skills install @asif2bd/jarvis-mission-control
openclaw skills search asif2bd