token-optimization
Skill433 starsChanged 5 months agoMITView on GitHub
Use when the user says 'token optimization', 'save tokens', 'context window', 'reduce tokens', 'token stack', or 'TokenStack', or asks about extending context window capacity. Covers TokenStack, the built-in compression proxy that shrinks Claude Code tool output before it reaches the Anthropic API. Do NOT use for proxy troubleshooting or live status (Compress skill).
- Installs packages
10 other projects use a version of this.
Adopted by
Most recently taken up by
- QSOLKCB/CLAUDE-SKILLS-AGItheir own version, first seen Nov 8, 2026
- OpenxIntelligence/Coding-Agent-Skillstheir own version, first seen Nov 1, 2026
- okfriansyah-moh/agentic-workflowtheir own version, first seen Oct 25, 2026
- I-Onlabs/claude-code-skillstheir own version, first seen Oct 25, 2026
- andrewalhaj/custom-hermesagenttheir own version, first seen Oct 20, 2026
- bm629/agent-skillstheir own version, first seen Aug 21, 2026
Other versions10 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 10
- Hassaan146/claude-skills★ 18same name
- I-Onlabs/claude-code-skills★ 4same name
- OpenxIntelligence/Coding-Agent-Skills★ 4same name
- bm629/agent-skills★ 2same name
- cheukswiss/etdxm★ 2same name
- QSOLKCB/CLAUDE-SKILLS-AGI★ 1same name
- andrewalhaj/custom-hermesagent★ 0same name
- ESUnternehmensberatung/ClaudeCode★ 0same name
- muxammadmamajonov/dot-claude★ 0same name
- okfriansyah-moh/agentic-workflow★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository87 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- memstack-automation-api-integrationSkill
- memstack-automation-content-pipelineSkill
- memstack-automation-cron-schedulerSkill
- memstack-automation-hosted-mcp-catalogSkill
- memstack-automation-n8n-workflow-builderSkill
- memstack-automation-webhook-designerSkill
- memstack-business-client-onboardingSkill
- memstack-business-contract-templateSkill
- memstack-business-financial-modelSkill
- memstack-business-freelancer-toolkitSkill
- memstack-business-gdprSkill
- memstack-business-invoice-generatorSkill
- memstack-business-licensingSkill
- memstack-business-proposal-writerSkill
- memstack-business-scope-of-workSkill
- memstack-business-sop-builderSkill
- compressSkill
- memstack-content-blog-postSkill
- memstack-content-email-sequenceSkill
- memstack-content-landing-page-copySkill
- memstack-content-newsletterSkill
- memstack-content-product-descriptionSkill
- memstack-content-tiktok-scriptSkill
- memstack-content-twitter-threadSkill
- memstack-content-youtube-scriptSkill
- memstack-deployment-ci-cd-pipelineSkill
- memstack-deployment-docker-setupSkill
- memstack-deployment-domain-sslSkill
- memstack-deployment-hetzner-setupSkill
- memstack-deployment-netlify-deploySkill
- memstack-deployment-railway-deploySkill
- memstack-development-api-designerSkill
- memstack-development-changelog-generatorSkill
- memstack-development-code-reviewerSkill
- memstack-development-mentorSkill
- memstack-development-migration-plannerSkill
- memstack-development-performance-auditSkill
- memstack-development-refactor-plannerSkill
- memstack-development-test-writerSkill
- memstack-development-webapp-testingSkill
- diarySkill
- echoSkill
- familiarSkill
- forgeSkill
- goalSkill
- governorSkill
- grimoireSkill
- humanizeSkill
- memstack-marketing-competitor-analysisSkill
- memstack-marketing-facebook-adSkill
- memstack-marketing-google-adSkill
- memstack-marketing-launch-planSkill
- memstack-marketing-lead-magnetSkill
- memstack-marketing-marketplace-submitSkill
- memstack-marketing-pricing-strategySkill
- memstack-marketing-sales-funnelSkill
- memstack-marketing-webinar-scriptSkill
- memstack-product-feature-specSkill
- memstack-product-feedback-analyzerSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
5 rules. 0 are common, 5 are distinctive, and 0 are very specific to this project.
0
Common
Most of the 8 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 14
When this skill activates, output:
- Distinctive: line 41
Start the dashboard with the proxy flag:
- Distinctive: line 79
Only AST truncation is lossy.
- Distinctive: line 103
Read your savings on the dashboard (Overview header and Burn Report).
- Distinctive: line 105
No installs, no MCP servers, no command prefixing.
“Common” is measured: kept by at least 6 in 10 of the 8 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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-proxyThis 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 Nchanges the proxy port (default 8787).- To run only the proxy without the dashboard:
python -m memstack_skill_loader proxy.
Free vs Pro Transforms
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.
Confirming It Routes
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/healthReading Your Savings
The dashboard reports savings in three places:
- Overview header: tokens saved for the current session and lifetime.
- Burn Report: a per-transform breakdown with estimated cost, filterable by all-time, daily, weekly, and monthly.
- Per-Agent Token Cost: the Burn Report also splits cost across the Manager, Builder, and Reviewer agents.
What You Actually Do
- Enable the proxy:
python -m memstack_skill_loader dashboard --with-proxy. - Optionally activate a Pro license to unlock the seven Pro transforms.
- Read your savings on the dashboard (Overview header and Burn Report).
No installs, no MCP servers, no command prefixing.
Relationship to Other Skills
| 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 |
Level History
- Lv.1 - Base: legacy 3-layer manual guide (Serena MCP, RTK CLI, Headroom API proxy). Retired. (Origin: MemStack Pro, Mar 2026)
- Lv.2 - Rewrite: replaced the retired 3-layer manual stack with the built-in TokenStack proxy. Documents the verified enable command, free vs Pro transforms, proxy confirmation, and dashboard savings. (Jun 2026)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

