token-optimization

token-optimization is a skill for Claude Code from cwinvestments/memstack. It costs 79 tokens per session (1,246 once invoked), scanned A, original, MIT.

A compression proxy that shortens bulky tool output before it reaches the AI service. It helps preserve room in the conversation context and reduce token use.

In plain words
What is it for?
Use it when you want to reduce token use, extend usable context, or check how much output compression saves.
Why use it?
Long tool results can fill the context window and increase usage costs. Compressing them leaves more space for useful code and discussion.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin. Also seen: mentions Claude Code.

Part of the memstack plugin — 87 skills, 2 commands, 6 hooks shipped together

Good fit Use it when you want to reduce token use, extend usable context, or check how much output compression saves.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/cwinvestments/memstack/token-optimization
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add cwinvestments/memstack --skill token-optimization
Clone the repo
git clone --depth 1 https://github.com/cwinvestments/memstack

Made for: Claude Code.

Or install memstack, the plugin that ships this one along with the rest of its 87 skills, 2 commands, 6 hooks.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for token-optimization

README.md
[![agentmods](https://agentmods.dev/badge/skills/cwinvestments/memstack/token-optimization/github.svg)](https://agentmods.dev/skills/cwinvestments/memstack/token-optimization)
Your own site
<a href="https://agentmods.dev/skills/cwinvestments/memstack/token-optimization"><img src="https://agentmods.dev/badge/skills/cwinvestments/memstack/token-optimization/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for token-optimization

Your own site · 80×15
<a href="https://agentmods.dev/skills/cwinvestments/memstack/token-optimization"><img src="https://agentmods.dev/badge/skills/cwinvestments/memstack/token-optimization.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 79 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,246 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 1 finding. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00079 $0.01246
Opus 5.5 $0.00032 $0.00498
Sonnet 5.5 $0.00016 $0.00249
Haiku 4.5 $0.00008 $0.00125

Measured 1mo ago against content hash 5ae4d2bcd0ea, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

token-optimization scanned grade A with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

curl http://127.0.0.1:8787/health
skills/token-optimization/SKILL.md · 119 lines

How it starts

The opening of the file, as written. The whole thing — 119 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Token Optimization Guide - TokenStack

One built-in compression proxy that shrinks Claude Code tool output before it reaches the Anthropic API.

Activation

When this skill activates, output:

TokenStack - enabling compression & reading your savings...

Then execute the protocol below.

Context Guard

Context Status
User asks about token savings or context optimization ACTIVE - full guide
User says "TokenStack", "token stack", "reduce tokens" ACTIVE - relevant section
User wants to enable or confirm the proxy ACTIVE - enable steps
User asks how to read their savings ACTIVE - dashboard section
Proxy crash, health check, or live status DORMANT - use Compress skill
User is actively coding (no optimization discussion) DORMANT - do not activate

What TokenStack Is

TokenStack is a single transparent proxy that sits between Claude Code and the Anthropic API. It intercepts each request, compresses the bulky tool output inside it, and forwards the smaller payload upstream. Less text per turn means more usable context and lower token cost.

It is built into the memstack-skill-loader package. There is nothing extra to install: if you have MemStack, you have TokenStack.

Earlier versions documented a 3-layer manual setup (Serena MCP, RTK CLI, and the Headroom API proxy). That stack is retired. TokenStack supersedes all three. There is no pip install, no Rust binary, no MCP server, and no command prefixing.

Enabling It

Start the dashboard with the proxy flag:

python -m memstack_skill_loader dashboard --with-proxy

This starts the TokenStack proxy on 127.0.0.1:8787 and sets ANTHROPIC_BASE_URL for you, so Claude Code traffic routes through it automatically. No manual environment configuration is needed.

Options:

  • --proxy-port N changes the proxy port (default 8787).
  • To run only the proxy without the dashboard: python -m memstack_skill_loader proxy.

Read the full file on GitHub · 119 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 119 lines · 79 tokens per session scan A 5ae4d2bcd0ea

Subscribe to this mod's changes

token-optimization is a skill published in the GitHub repository cwinvestments/memstack (425 stars, last pushed yesterday), licensed MIT. It adds 79 tokens to every session and 1,246 once invoked, about $0.0003 per session on Opus 5.5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.

Related

Other skills, from other repositories

catchup

Restore context after /clear by summarizing recent work and project state.

FlorianBruniaux/claude-code-ultimate-guide · 16 tokens

atomic-wiki

Conversational wiki and capture-bucket routing. Fires when the user wants a place, space, or folder for notes, research, tickets, raw dumps, or knowledge capture — checks the block in /.claude/CLAUDE.md; if the cwd is under a registered realm, creates the folder as a bucket via atomic wiki bucket add rather than a…

damusix/atomic-claude · 204 tokens

memory-factcheck

A check that compares the project’s saved agent notes with the current code, database, issue tracker, and files. It identifies notes whose claims are outdated or no longer match reality.

LeeYudok/agents-scaffold · 137 tokens

fable-context-thrift

Use at the start of any multi-step task and during exploration — before reading files, searching, or re-checking completed work, especially when tempted to read whole files, re-verify known facts, or run independent lookups one at a time.

DizzyMii/fable-skills · 56 tokens

context-mode

Use context-mode tools (ctxexecute, ctxexecutefile) instead of Bash/cat when processing large outputs. Triggers: "analyze logs", "summarize output", "process data", "parse JSON", "filter results", "extract errors", "check build output", "analyze dependencies", "process API response", "large file analysis", "page…

opencue/cuecards · 225 tokens

deep-clean

Full-spectrum consolidation of AI agent configuration files. Goes beyond memory-only dream skills: audits and optimizes context files (AGENTS.md/AGENTS.md/GEMINI.md/.cursorrules), rules, skills, and memory. Detects stale references, dead file paths, duplicated rules, stack mismatches, contradictions, vague directives…

opencue/cuecards · 87 tokens