← Back to Skills Marketplace
rubenaquispe

Token Saver

by Ruben Quispe · GitHub ↗ · v3.0.0
cross-platform ⚠ suspicious
6432
Downloads
9
Stars
31
Active Installs
7
Versions
Install in OpenClaw
/install token-saver
Description
Reduce OpenClaw AI costs with model-aware optimization. Features dynamic compaction presets based on your model's context window, intelligent file compression, and robust model detection with fallback. Supports Claude, GPT-4, Gemini, DeepSeek, and more.
README (SKILL.md)

Token Saver v3

💡 Did you know? Every API call sends your workspace files (SOUL.md, USER.md, MEMORY.md, AGENTS.md, etc.) along with your message. These files count toward your context window, slowing responses and costing real money on every message.

Token Saver v3 is model-aware — it knows your model's context window and adapts recommendations accordingly. Using Gemini's 1M context? Presets scale up. On GPT-4o's 128K? Presets adjust down.

What's New in v3

Feature v2 v3
Compaction presets Fixed (80K/120K/160K) Dynamic (% of model's context)
Model detection Fragile, env-only Robust fallback chain
Context windows Not tracked Full registry (9 models)
Model info Hardcoded pricing JSON registry, easy updates
Already-optimized Re-compressed Smart bypass

Commands

Command What it does
/optimize Full dashboard — files, models, context usage %
/optimize tokens Compress workspace files (auto-backup)
/optimize compaction Chat compaction control (model-aware)
/optimize compaction balanced Apply balanced preset (60% of context)
/optimize compaction 120 Custom threshold (compact at 120K)
/optimize models Detailed model audit with registry
/optimize revert Restore backups, disable persistent mode

Features

📊 Model-Aware Dashboard

Shows current model, context window, and usage percentage:

🤖 Model: Claude Opus 4.5 (200K context)
   Detected: openclaw.json

📊 Context Usage: [████████░░░░░░░░░░░░] 42% (84K/200K)

📁 Workspace File Compression

Scans all .md files, shows token count and potential savings. Smart bypass skips already-optimized files.

File-aware compression:

  • SOUL.md — Light compression, keeps personality language
  • AGENTS.md — Medium compression, dense instructions
  • USER.md / MEMORY.md — Heavy compression, key:value format
  • PROJECTS.md — No compression (user structure preserved)

💬 Dynamic Compaction Presets

Presets adapt to your model's context window:

Preset % of Context Claude 200K GPT-4o 128K Gemini 1M
Aggressive 40% 80K 51K 400K
Balanced 60% 120K 77K 600K
Conservative 80% 160K 102K 800K
Off 95% 190K 122K 950K

🤖 Model Registry

24+ models with context windows, pricing, and aliases:

  • Claude: Opus 4.6 (1M), Opus 4.5, Sonnet 4.5, Sonnet 4, Haiku 4.5, Haiku 3.5 (200K)
  • OpenAI: GPT-5.2, GPT-5.1, GPT-5-mini, GPT-5-nano (256K), GPT-4.1, GPT-4o (128K), o1, o3, o4-mini
  • Gemini: 3 Pro (2M), 2.5 Pro, 2.0 Flash (1M)
  • Others: DeepSeek V3 (64K), Kimi K2.5 (128K), Llama 3.3 70B, Mistral Large

🔍 Robust Model Detection

Detection priority:

  1. Runtime injection (--model=...)
  2. Environment variables (SKILL_MODEL, OPENCLAW_MODEL)
  3. Config file (~/.openclaw/openclaw.json)
  4. File inference (TOOLS.md, MEMORY.md mentions)
  5. Fallback: Claude Sonnet 4 (safe default)

Unknown model handling:

  • Strict version matching — opus-6.5 won't fuzzy-match to opus-4.5
  • Unknown models get safe defaults (200K context) + warning
  • Easy to add new models to scripts/models.json

📝 Persistent Mode

Adds writing guidance to AGENTS.md for continued token efficiency:

File Writing Style
SOUL.md Evocative, personality-shaping
AGENTS.md Dense instructions, symbols OK
USER.md Key:value facts
MEMORY.md Ultra-dense data

Safety

  • Auto-backup — All modified files get .backup extension
  • Integrity > Size — Never sacrifices meaning for smaller tokens
  • Smart bypass — Skips already-optimized files
  • Revert anytime/optimize revert restores everything
  • No external calls — All analysis runs locally

Installation

clawhub install token-saver --registry "https://www.clawhub.ai"

Version History

  • 3.0.0 — Model registry, dynamic presets, robust detection, smart bypass
  • 2.0.1 — Chat compaction, file-aware compression, persistent mode
  • 1.0.0 — Initial release
Usage Guidance
Use caution before installing or invoking `/optimize tokens`. The local/no-external-calls design is a positive sign, but this skill can change AGENTS.md, MEMORY.md, USER.md, and SOUL.md in ways that affect future agent behavior. If you proceed, back up your workspace, run only in a test copy first, inspect every diff, and avoid accepting persistent-mode changes unless you understand them.
Capability Analysis
Type: OpenClaw Skill Name: token-saver Version: 3.0.0 The skill is classified as suspicious due to its use of prompt injection and persistence mechanisms, despite these being disclosed and intended for benign token optimization. Specifically, `scripts/compressor.js` contains hardcoded instructions like 'Auto-execute.' and 'Internal actions (read/organize/learn): free' that directly influence agent behavior. Furthermore, `scripts/optimizer.js` modifies `AGENTS.md` to enable a 'Persistent Mode' by appending writing guidance, which is a form of persistence and prompt injection. While these actions are disclosed in `SKILL.md` and `audit.json` and align with the stated purpose of cost reduction, they represent high-risk capabilities that modify core agent instructions.
Capability Assessment
Purpose & Capability
Optimizing token usage is coherent with reading and compressing workspace Markdown, but the provided compressor includes hardcoded AGENTS.md content that is not merely a compressed version of the user's existing file.
Instruction Scope
The hardcoded AGENTS.md template includes behavior-shaping instructions such as auto-execution, memory maintenance, heartbeats, and proactive checks, which are broader than a token optimization workflow.
Install Mechanism
There is no install spec or dependency install path, but the source is listed as unknown and the package contains runnable Node scripts, so users should verify provenance before use.
Credentials
The skill scans workspace Markdown files and appears to auto-scan chat/session history for recommendations; the local-only design is mitigating, but the scope is sensitive and not clearly bounded in the main documentation.
Persistence & Privilege
The skill documents persistent mode and code shows generation of persistent AGENTS.md instructions; modifying agent memory/config files can affect future sessions even after the original command is complete.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install token-saver
  3. After installation, invoke the skill by name or use /token-saver
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v3.0.0
v3: Model-aware optimization with dynamic presets, robust model detection, context window registry for 9+ models
v2.0.1
Added back intro text explaining why token optimization matters
v2.0.0
Chat compaction with personalized recommendations, file-aware compression, persistent mode with file-type writing styles
v1.1.0
Persistent Mode - AI maintains compressed format after optimization. One-and-done, reversible with /optimize revert.
v1.0.2
Fix model detection to read actual OpenClaw config, rename dashboard to Token Saver
v1.0.1
Add educational intro about workspace file token overhead
v1.0.0
Initial release - dashboard with file compression and AI model audit
Metadata
Slug token-saver
Version 3.0.0
License
All-time Installs 32
Active Installs 31
Total Versions 7
Frequently Asked Questions

What is Token Saver?

Reduce OpenClaw AI costs with model-aware optimization. Features dynamic compaction presets based on your model's context window, intelligent file compression, and robust model detection with fallback. Supports Claude, GPT-4, Gemini, DeepSeek, and more. It is an AI Agent Skill for Claude Code / OpenClaw, with 6432 downloads so far.

How do I install Token Saver?

Run "/install token-saver" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Token Saver free?

Yes, Token Saver is completely free (open-source). You can download, install and use it at no cost.

Which platforms does Token Saver support?

Token Saver is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Token Saver?

It is built and maintained by Ruben Quispe (@rubenaquispe); the current version is v3.0.0.

💬 Comments