OpenClaw
Token Optimizer for OpenClaw is a native TypeScript plugin with zero Python dependency, zero runtime dependencies, and zero telemetry. It works with any model your OpenClaw gateway is configured against.
Prerequisites
Section titled “Prerequisites”- OpenClaw installed
- npm (for npx CLI commands)
- Git (for source install only)
Recommended method: GitHub registry install
Section titled “Recommended method: GitHub registry install”openclaw plugins install github:alexgreensh/token-optimizerAlternative method: ClawHub install
Section titled “Alternative method: ClawHub install”openclaw plugins install token-optimizerAlternative method: source install
Section titled “Alternative method: source install”-
Clone the repo:
Terminal window git clone https://github.com/alexgreensh/token-optimizer -
Build and install:
Terminal window cd token-optimizer/openclaw && npm install && npm run buildopenclaw plugins install ./
Grant conversation access
Section titled “Grant conversation access”The in-session continuity hints, cold-resume and nudges run on OpenClaw’s agent_turn_prepare hook. OpenClaw lets a non-bundled plugin use that hook only with an explicit grant in openclaw.json:
{ "plugins": { "entries": { "token-optimizer-openclaw": { "enabled": true, "hooks": { "allowConversationAccess": true } } } }}Merge the entry into your existing config; with the default hybrid reload mode the policy change hot-reloads. Without the grant the plugin still installs and the CLI, detectors and dashboard work, but the in-session contributions stay silent. See the OpenClaw hook permissions for the upstream rule.
Verify the install
Section titled “Verify the install”npx token-optimizer doctor --jsonA healthy install reports plugin status and checkpoint health. The --json flag returns machine-readable output for scripting.
Inside OpenClaw
Section titled “Inside OpenClaw”Run /token-optimizer inside any OpenClaw session for a guided audit with coaching.
CLI commands
Section titled “CLI commands”All commands are available via npx token-optimizer outside of sessions:
npx token-optimizer detect # Is OpenClaw installed?npx token-optimizer scan --days 30 # Scan sessions, show usagenpx token-optimizer audit --days 30 # Detect waste, show $ savingsnpx token-optimizer audit --json # JSON output for agentsnpx token-optimizer dashboard # Generate HTML dashboard, open in browsernpx token-optimizer context # Context overhead breakdownnpx token-optimizer context --json # Context audit as JSONnpx token-optimizer quality # Quality score (0-100)npx token-optimizer quality --json # Quality report as JSONnpx token-optimizer git-context # Suggest files based on git statenpx token-optimizer git-context --json # Git context as JSONnpx token-optimizer drift # Check for config driftnpx token-optimizer drift --snapshot # Capture current config snapshotnpx token-optimizer validate # Before/after impact comparisonnpx token-optimizer validate --strategy auto --json # Auto-split strategy, JSON outputnpx token-optimizer doctor --json # Check checkpoint health, plugin statusTOKEN_OPTIMIZER_CHECKPOINT_TELEMETRY=1 npx token-optimizer checkpoint-stats # Checkpoint telemetry summaryDashboard
Section titled “Dashboard”The OpenClaw dashboard is an 8-tab interactive HTML file, separate from the Python-based shared dashboard used by Claude Code and Codex. It auto-regenerates on session end. Open it manually:
npx token-optimizer dashboardTabs: Overview, Context, Quality, Waste, Agents, Sessions, Daily, Manage.
Auto-update
Section titled “Auto-update”Standard npm versioning. After updating to a new version, re-install from source if you used the source install path.
Model support
Section titled “Model support”30+ models: Claude, GPT-5, Gemini, DeepSeek, Qwen, Mistral, Grok, and local models via Ollama. Four pricing tiers: Anthropic API (direct), Google Vertex AI (global), Vertex AI (regional, +10%), and AWS Bedrock. User-configured pricing overrides via openclaw.json.
See OpenClaw capabilities for the full feature list, the 16 waste detectors, and features unique to OpenClaw vs Claude Code.
