agentleFS
Evan-DaruwallaEvan-Daruwalla/claude-skill-suite/token-squeeze/SKILL.md

token-squeeze

Skill0 starsChanged 45 days agoMITView on GitHub

No-LLM compressor for text that will be REUSED (saved prompts, system prompts, skill bodies); protects code, paths, numbers, negations. NOT for live chat. Use when: "compress this for reuse", "shrink this system prompt", "token-squeeze".

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 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.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    RUN IT. From the skill directory: npm install once (pulls gpt-tokenizer), then:

    line 14
  2. Very specific:

    add --clean only for text carrying junk whitespace (pasted logs, tables).

    line 19
  3. Distinctive:

    After running, show the user the savedPct and the guard result.

    line 31

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

This skill wraps a deterministic CLI. It does NOT ask you to compress text by hand — invoke the tool so results are reproducible and guard-checked.

WHEN IT PAYS (state this if the user aims it at live chat). Compressing text already in the context window saves nothing — those tokens were billed on arrival. token-squeeze only nets tokens when its output is reused: a saved prompt, a system prompt, a skill body, a doc pasted across many sessions. For a one-off message, skip it.

RUN IT. From the skill directory: npm install once (pulls gpt-tokenizer), then:

  • node cli.js <file> — compressed text to stdout.
  • node cli.js <file> --stats — adds a token-before/after + guard line on stderr.
  • node cli.js <file> --json — structured {tokensBefore, tokensAfter, savedPct, subs, subsDetail, guard}; subsDetail is the per-substitution ledger ("what changed"), show it when the user asks what was done.
  • node cli.js - --stats — read from stdin.
  • add --clean only for text carrying junk whitespace (pasted logs, tables); it's off by default because it saves ~0% on normal prose. Exit code is non-zero if the guard trips, so it's safe to script.

WHAT IT DOES. Layer B (default): token-aware dictionary substitution — "in order to"->"to", "due to the fact that"->"because", "utilize"->"use", plus deletion of pure filler. Each dictionary entry is self-filtered at load against the tokenizer and dropped unless it strictly reduces tokens, so a bad entry can't make output worse. Layer A (--clean, opt-in): lossless whitespace reclamation.

GUARANTEES AND LIMITS (report honestly, don't oversell).

  • Measured on the bundled corpus: ~25% overall, 37-42% on verbose prose, 13-17% on technical text, 0% on already-tight prompts (a tight prompt returns byte-identical). Run node test.js to reproduce.
  • Protected spans are never altered: fenced/inline code, URLs, Windows paths, double-quoted strings, dotted identifiers (auth.js, example.com, decimals). A five-way guard verifies every run and fails loudly: numbers; negation/constraint words in ANY case (no/not/never/must/cannot + contractions); dotted identifiers; protected spans; idempotence (running the output through again must be byte-identical).
  • Homonym-risky words are deliberately NOT in the dictionary (e.g. "leverage" — financial noun; "interface with" — UI noun phrase); a deterministic tool can't disambiguate, so it doesn't try. Same for phrases whose compression would delete a negation ("there is no doubt that") — the guard outranks the saving.
  • Token counts use the o200k (tiktoken) tokenizer as a PROXY for Claude's tokenizer, which Anthropic does not publish. Real Claude savings will be close but not identical. For exact numbers, count via the Anthropic count-tokens API (needs an API key).
  • Meaning-leaning, not string-lossless: substitutions preserve propositional content but change wording; emphasis from deleted filler is lost by design. Do not use where exact wording is contractual (legal text, quoted material) — those cases are protected only if quoted.

After running, show the user the savedPct and the guard result; if the guard fails, surface it rather than returning the output silently.

REPORTING FORMAT. Show before/after with the savedPct, then two short lists: Preserved (protected spans, negations, numbers — what the guard confirmed survived) and Dropped (pure-filler phrases removed entirely, not substituted — from subsDetail, the "-> (deleted)" entries). Never silently swap the user's text; the diff and the guard result are always shown.

FOR LONG REUSABLE PROMPTS (~200+ words). Beyond running the dictionary substitution, restructure the result as: INTENT (one sentence — what the prompt is for), CONSTRAINTS (bullets — the non-negotiable rules), CONTEXT (only what the model can't infer on its own). This is a manual restructuring step on top of the deterministic pass, not something the CLI does — do it only when asked to prep a prompt for reuse (a saved prompt, a system prompt, a skill body), not for a one-off message.

node cli.js --canary — MUST print CANARY PASS 15/15 before you trust a result.

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.