agentleFS
GabrieleDattileGabrieleDattile/agent-superpowers/skills/optimization/token-squeezer/SKILL.md

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.

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
  1. Distinctive:

    Run the Squeezer script:

    line 39

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

📉 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:

  1. interface mode (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.
  2. compact mode (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 interface

Phase 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 compact mode.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.