token-optimizer

Automatically analyze and reduce OpenClaw token waste through context compression, tool-call deduplication insights, model selection guidance, and session hygiene checks. Use when sessions are nearing context limits, costs are climbing, or you want proactive token optimization before expensive tasks.

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 "token-optimizer" with this command: npx skills add mkhaytman87/mkhaytman-token-optimizer

Token Optimizer

Overview

Use this skill to optimize OpenClaw token usage with a local CLI that performs analysis, compression snapshots, health checks, cleanup planning, and preflight token budgeting.

Quick Start

$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --analyze --period 7d

Core Commands

  1. Enable local optimizer config:
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --enable
  1. Optimization analysis:
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --analyze --period 7d
  1. Force context compression snapshot:
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --compress --threshold 0.7 --session agent:main:main
  1. Session health check:
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --health-check --active-minutes 120
  1. Auto-cleanup planning and apply:
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --cleanup
$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --cleanup --apply

Preflight Optimization

Use preflight planning before expensive task batches:

$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize \
  --preflight /path/to/actions.json \
  --session-limit 180000

actions.json should be a JSON array of planned operations, for example:

[
  {"type": "web_search", "query": "..."},
  {"type": "web_fetch", "url": "..."},
  {"type": "summarize", "target": "youtube"}
]

Output Artifacts

  • Compression snapshots: $OPENCLAW_WORKSPACE/token-usage/compressed/
  • Optional JSON output: --format json --output /path/file.json
  • Baseline config (from --enable): $OPENCLAW_WORKSPACE/token-usage/token-optimizer.config.json

Defaults

Default behavior is configured in:

  • config/defaults.json

Override with:

$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --config /path/custom.json --analyze

Resources

  • scripts/token_optimize.py: main CLI
  • src/optimizer.py: core optimization engine
  • src/models.py: model selection logic
  • src/compression.py: context compression helpers
  • src/cleanup.py: session hygiene evaluation
  • references/operating-notes.md: implementation details and safe-operating guidance

Validation

python3 $OPENCLAW_SKILLS_DIR/.system/skill-creator/scripts/quick_validate.py \
  $OPENCLAW_SKILLS_DIR/token-optimizer

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.

Coding

Olares Shared (olares-cli foundation)

Shared olares-cli foundation: profile model, first-time login (profile login with password + TOTP), bootstrapping a profile from an existing refresh token (p...

Registry SourceRecently Updated
Coding

Olares Dashboard (olares-cli dashboard)

olares-cli dashboard command tree — AI-agent-oriented mirror of the dashboard SPA's Overview2 + Applications2 routes. Covers: the strict dual-shape JSON enve...

Registry SourceRecently Updated
Coding

Olares Settings (olares-cli settings)

olares-cli settings command tree: profile-based reads of every section the SPA's Settings page exposes (https://docs.olares.com/manual/olares/settings/) plus...

Registry SourceRecently Updated
Coding

Olares Market (olares-cli market)

olares-cli market command tree against the per-user Market app-store v2 API: list / get / categories for catalog browsing; install / uninstall / upgrade / cl...

Registry SourceRecently Updated