/memstack:token-optimizationfrom memstack
Compresses Claude Code tool output via the built-in TokenStack proxy to reduce token consumption, extend context window, and lower API costs. Enable with a single flag.
Ships in memstack. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
One built-in compression proxy that shrinks Claude Code tool output before it reaches the Anthropic API.
When this skill activates, output:
TokenStack - enabling compression & reading your savings...
Then execute the protocol below.
| 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 |
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.
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).python -m memstack_skill_loader proxy.Free-tier transforms run on every request and are lossless (they remove only redundant formatting):
| Transform | What it removes |
|---|---|
| Strip ANSI codes | terminal color and escape sequences |
| Strip trailing whitespace | end-of-line padding |
| Collapse blank lines | runs of empty lines |
| Dedup consecutive identical lines | repeated identical lines |
| Strip preambles | "Here is the contents of file..." lead-ins |
| Collapse inline whitespace (Python) | redundant intra-line spacing |
Pro tier (active with a valid Pro license) adds seven more transforms on top:
| Transform | Effect |
|---|---|
| AST truncation | Shortens Python function bodies while keeping signatures and type annotations. Largest single saving (around 78% on line-numbered Python). Lossy by design: Python code blocks are not preserved byte-for-byte. |
| JSON compression | Minifies verbose JSON output |
| Log deduplication | Folds repeated log lines |
| Path compression | Shortens long repeated file paths |
| Markdown stripping | Removes decorative markdown |
| System-prompt compression | Compresses system-prompt boilerplate |
| Conversation-history dedup | Drops duplicated earlier message blocks |
Only AST truncation is lossy. Every other transform reduces tokens without changing meaning.
The dashboard shows a proxy indicator with a live PRO or FREE tier badge plus your session and 30-day savings percentages. If the badge is present, traffic is routing through TokenStack.
A quick health check from a terminal:
curl http://127.0.0.1:8787/health
The dashboard reports savings in three places:
python -m memstack_skill_loader dashboard --with-proxy.No installs, no MCP servers, no command prefixing.
| Skill | Scope | When to Use |
|---|---|---|
| Token Optimization (this) | What TokenStack is, how to enable it, free vs Pro, reading savings | Understanding or turning on compression |
| Compress | Proxy health and live status troubleshooting | Proxy not routing, health checks |
| Context DB | SQLite fact store | Reducing repeated reads of project context |
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub cwinvestments/memstack --plugin memstack87 skills in this plugin
/memstack-seo-ai-search-visibilityUse this skill when the user says 'AI search', 'AI visibility', 'ChatGPT ranking', 'Perplexity optimization', 'GEO', 'generative engine optimization', or needs to optimize content for AI-powered search engines and LLM citations. Do NOT use for traditional SEO audits or Google Ads./memstack-security-api-auditUse this skill when the user says 'audit API', 'check API security', 'API routes security', 'endpoint audit', 'check my routes', or needs to verify API route protection. Reviews API endpoints for authentication, authorization, and input validation gaps. Do NOT use for frontend security headers or dependency scanning./memstack-development-api-designerUse this skill when the user says 'design API', 'API endpoints', 'REST API', 'API designer', 'route structure', 'API architecture', or is designing RESTful API routes, request/response schemas, and endpoint organization. Do NOT use for API security audits or database design.Other plugins' skills for the same job