← 返回 Skills 市场
rubenaquispe

Token Saver

作者 Ruben Quispe · GitHub ↗ · v3.0.0
cross-platform ⚠ suspicious
6432
总下载
9
收藏
31
当前安装
7
版本数
在 OpenClaw 中安装
/install 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.
使用说明 (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
安全使用建议
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.
功能分析
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.
能力评估
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.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install token-saver
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /token-saver 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
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
元数据
Slug token-saver
版本 3.0.0
许可证
累计安装 32
当前安装数 31
历史版本数 7
常见问题

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. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 6432 次。

如何安装 Token Saver?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install token-saver」即可一键安装,无需额外配置。

Token Saver 是免费的吗?

是的,Token Saver 完全免费(开源免费),可自由下载、安装和使用。

Token Saver 支持哪些平台?

Token Saver 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Token Saver?

由 Ruben Quispe(@rubenaquispe)开发并维护,当前版本 v3.0.0。

💬 留言讨论