{"skill":{"slug":"mkhaytman-token-optimizer","displayName":"Token Optimizer","summary":"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.","description":"---\nname: token-optimizer\ndescription: 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.\n---\n\n# Token Optimizer\n\n## Overview\n\nUse this skill to optimize OpenClaw token usage with a local CLI that performs analysis, compression snapshots, health checks, cleanup planning, and preflight token budgeting.\n\n## Quick Start\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --analyze --period 7d\n```\n\n## Core Commands\n\n1) Enable local optimizer config:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --enable\n```\n\n2) Optimization analysis:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --analyze --period 7d\n```\n\n3) Force context compression snapshot:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --compress --threshold 0.7 --session agent:main:main\n```\n\n4) Session health check:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --health-check --active-minutes 120\n```\n\n5) Auto-cleanup planning and apply:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --cleanup\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --cleanup --apply\n```\n\n## Preflight Optimization\n\nUse preflight planning before expensive task batches:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize \\\n  --preflight /path/to/actions.json \\\n  --session-limit 180000\n```\n\n`actions.json` should be a JSON array of planned operations, for example:\n\n```json\n[\n  {\"type\": \"web_search\", \"query\": \"...\"},\n  {\"type\": \"web_fetch\", \"url\": \"...\"},\n  {\"type\": \"summarize\", \"target\": \"youtube\"}\n]\n```\n\n## Output Artifacts\n\n- Compression snapshots: `$OPENCLAW_WORKSPACE/token-usage/compressed/`\n- Optional JSON output: `--format json --output /path/file.json`\n- Baseline config (from `--enable`): `$OPENCLAW_WORKSPACE/token-usage/token-optimizer.config.json`\n\n## Defaults\n\nDefault behavior is configured in:\n\n- `config/defaults.json`\n\nOverride with:\n\n```bash\n$OPENCLAW_SKILLS_DIR/token-optimizer/scripts/token-optimize --config /path/custom.json --analyze\n```\n\n## Resources\n\n- `scripts/token_optimize.py`: main CLI\n- `src/optimizer.py`: core optimization engine\n- `src/models.py`: model selection logic\n- `src/compression.py`: context compression helpers\n- `src/cleanup.py`: session hygiene evaluation\n- `references/operating-notes.md`: implementation details and safe-operating guidance\n\n## Validation\n\n```bash\npython3 $OPENCLAW_SKILLS_DIR/.system/skill-creator/scripts/quick_validate.py \\\n  $OPENCLAW_SKILLS_DIR/token-optimizer\n```\n","tags":{"latest":"1.0.0"},"stats":{"comments":0,"downloads":1254,"installsAllTime":0,"installsCurrent":0,"stars":1,"versions":1},"createdAt":1770917533203,"updatedAt":1778990098490},"latestVersion":{"version":"1.0.0","createdAt":1770917533203,"changelog":"Initial release of Token Optimizer skill for OpenClaw.\n\n- Analyze and reduce token waste through context compression, tool-call deduplication insights, and session hygiene checks.\n- Provides CLI commands for token usage analysis, optimization snapshots, health checks, cleanup planning, and preflight budgeting.\n- Supports model selection guidance and session-limit-aware optimization.\n- Output includes compression snapshots, JSON reports, and configurable baseline settings.\n- Extensive documentation and quick start guidance included in SKILL.md.","license":null},"metadata":null,"owner":{"handle":"mkhaytman87","userId":"s178gwge6871v3768gwm4egx29885str","displayName":"mkhaytman87","image":"https://avatars.githubusercontent.com/u/24794258?v=4"},"moderation":null}