token-squeezer
Skill1 starsChanged 15 days agoMITView on GitHub
AST-based token and context optimizer. Compresses heavy source code and logs by 50-70% before feeding them into LLM context windows without semantic loss.
In this repository36 other files it gives its agents.
- .cursor/rules/agent-superpowers.mdcCursor rule
- arch-archaeologistSkill
- graphifySkill
- hindsight-architectSkill
- ghost-runnerSkill
- figma-designerSkill
- frontend-sentinelSkill
- hallmarkSkill
- landing-page-designSkill
- review-frontend-productionSkill
- hindsight-coding-agentSkill
- memory-nexusSkill
- video-shotcraftSkill
- caveman-compressSkill
- cavemanSkill
- prompt-optimizerSkill
- using-superpowersSkill
- api-synthesizerSkill
- blackbox-clonerSkill
- agent-reachSkill
- firecrawl-buildSkill
- firecrawl-build-interactSkill
- firecrawl-build-onboardingSkill
- firecrawl-build-scrapeSkill
- firecrawl-build-searchSkill
- scrapling-officialSkill
- adversarial-duelistSkill
- testsprite-ciSkill
- testsprite-verifySkill
- caveman-commitSkill
- feature-brainstormerSkill
- git-worktree-sandboxSkill
- ponytail-auditSkill
- ponytail-debtSkill
- ponytail-reviewSkill
- ponytailSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
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 39
Run the Squeezer script:
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
📉 Skill: Token Squeezer (Context & Cost Optimizer)
1. When to Trigger (Routing)
- TRIGGER WHEN:
- The agent is about to load large source files, multi-module directories, or verbose logs into context.
- The user requests: "optimize context", "compress this file for LLM", "reduce token cost", or "make prompt fit context limit".
- DO NOT TRIGGER WHEN:
- Exact literal string matching or character-for-character formatting must be preserved (e.g. formatting linters).
2. Fundamental Philosophy
"LLM context windows are expensive and suffer from 'lost in the middle' syndrome. Token Squeezer distills codebases to their semantic essence: structural signatures, type annotations, and core logic, eliminating 60%+ of token waste."
3. Operational Protocol
Phase 1: Compression Strategy Selection
Select one of two modes based on agent needs:
interfacemode (Maximum Compression, ~70% reduction):- Preserves classes, function signatures, docstrings (first line only), and type hints.
- Replaces function bodies with
...(ellipsis). - Ideal for agent architecture exploration and cross-file API discovery.
compactmode (Full Logic, ~40% reduction):- Preserves all logical execution.
- Strips inline comments, trailing whitespace, empty lines, and normalizes imports.
Phase 2: Execution
Run the Squeezer script:
python skills/optimization/token-squeezer/scripts/squeezer.py --file <path_to_code.py> --mode interfacePhase 3: Telemetry & Injection
The script emits the compressed payload along with exact token reduction metrics:
- Original tokens vs Compressed tokens
- Percentage saved
- The compressed representation is then fed into the agent's prompt context.
4. Guardrails & Negative Constraints
- ❌ NEVER discard type annotations or return types during interface compression.
- ❌ NEVER mutate runtime logic when using
compactmode.
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.

