token-compression
Skill1 starsChanged 7 months agoMITView on GitHub
Use to reduce the token cost of agents' INTERNAL communication — inter-agent messages, scratch notes, internal reasoning summaries — by writing tersely ("talk like a caveman"), WITHOUT harming external output quality (output to users / other systems / final deliverables stays full-quality; TC-1). Provides a deterministic stdlib "caveman" compressor (drops articles / politeness / intensifiers + wordy phrases, preserves content words / identifiers / numbers / code verbatim) and documents evaluating a heavier ML token-compression package (LLMLingua-style) for developer agents while they run (TC-3). The deterministic engine lives in scripts/token_compression/caveman.py; this skill is the contract, including the hard internal-only boundary.
In this repository60 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-exploreSkill
- openspec-proposeSkill
- api-design-from-frontendSkill
- architect-team-pipelineSkill
- bug-fix-pipelineSkill
- cartographer-teamSkill
- claude-design-importSkill
- claude-md-efficiencySkill
- closeoutSkill
- common-pipeline-conventionsSkill
- contract-first-parallelismSkill
- coverage-mappingSkill
- data-annotationsSkill
- data-dictionarySkill
- data-engineering-explorationSkill
- data-eng-pipelineSkill
- data-lineage-mappingSkill
- delivery-manifestSkill
- design-fidelity-mappingSkill
- dev-api-integration-testingSkill
- diagnostic-research-teamSkill
- documentation-currencySkill
- domain-research-teamSkill
- dynamic-value-discoverySkill
- editability-completenessSkill
- email-testingSkill
- endpoint-trace-mappingSkill
- expensive-verification-debuggingSkill
- frontend-route-mappingSkill
- helpdeskSkill
- intake-and-mappingSkill
- interaction-completenessSkill
- interaction-intuitionSkill
- interactive-mockup-discoverySkill
- intuition-map-lifecycleSkill
- mcp-output-contract-designSkill
- mempalace-integrationSkill
- mini-architect-team-pipelineSkill
- phenotype-absorptionSkill
- phenotypesSkill
- playwright-suite-builderSkill
- playwright-user-flowsSkill
- proposal-refinerSkill
- readme-stylingSkill
- reuse-first-designSkill
- root-cause-test-failuresSkill
- structure-optimizationSkill
- team-spawning-and-review-gatesSkill
- test-prod-safety-classifierSkill
- test-run-monitorSkill
- ux-test-builderSkill
- verification-planningSkill
- verified-agent-outputSkill
- visual-fidelity-reconciliationSkill
- visual-to-api-designSkill
- visual-verification-teamSkill
- warehouse-sql-miningSkill
The file
Files
Token Compression (TC-1 … TC-3)
Agents spend tokens on two kinds of text: what they say to the OUTSIDE (users, other systems, final deliverables) and what they say to THEMSELVES and EACH OTHER (inter-agent messages, scratch notes, internal summaries). The outside text must stay full-quality; the internal text can be terse. This discipline compresses the internal text to free up context, and draws a hard line so the outside text is never touched.
The deterministic, always-available compressor lives in
scripts/token_compression/caveman.py (stdlib-only, unit-tested). This skill
is the contract + the internal-only boundary. Do not re-implement the transform in
prose — call the module.
The hard boundary (TC-1) — internal only
NEVER compress external output. The caveman transform applies ONLY to:
- inter-agent messages (teammate ↔ teammate, Lead ↔ teammate),
- an agent's own scratch / working notes / internal reasoning summaries,
- internal context an agent re-reads for itself.
It must NOT touch: the final answer to the user, content sent to other systems (API payloads, commits, file contents, PRs, emails), test output, or anything a human or downstream system consumes. Output quality to the outside is preserved verbatim — that is the non-negotiable line TC-1 draws.
The caveman style (TC-2)
compress(text) reduces verbosity meaning-preservingly: it drops pure filler
(articles a/an/the, politeness please/kindly/thanks, intensifiers /
hedges just/really/very/actually/basically/simply/…) and a few wordy
phrases (in order to → to, due to the fact that → because), while
PRESERVING content words, identifiers, numbers, line structure, and — critically
— fenced (```) and inline (`) code VERBATIM. Prepositions,
conjunctions, and copulas are kept (they carry meaning) so the compressed text
stays understandable to the agent that re-reads it.
$(command -v python3 || command -v python) scripts/token_compression/caveman.py stats --json # measure savings
$(command -v python3 || command -v python) scripts/token_compression/caveman.py compress # emit compressedcompression_stats(text) reports the original vs compressed token estimate + the
saved percentage so the win is measurable, not assumed.
Evaluating a heavier package (TC-3)
The stdlib caveman compressor is the FLOOR — always available, zero dependencies,
safe. For larger wins on developer agents while they run, evaluate an ML
token-compression package (e.g. LLMLingua-style prompt compression) and apply it
to the internal channels per the same TC-1 boundary. Such a package is a
third-party dependency (NOT stdlib) and is plugged in at the application layer,
not bundled into this stdlib-only plugin — evaluate it for the specific agent
workload, measure with compression_stats as the baseline to beat, and keep the
caveman transform as the always-on fallback.
Honest boundary
The caveman transform is a lossy-of-FILLER heuristic, not a semantic ML
compressor — it drops a fixed filler list + wordy phrases and collapses
whitespace; it does not understand meaning. Two consequences: (1) any single
token that matches a filler word case-insensitively is dropped, so a single-letter
or short token used as CONTENT outside backticks — a variable a, the grade A,
a drug/vitamin designation A, a list marker — can be lost; wrap such content in
` so the code-preserve path keeps it verbatim; (2) the token counts are
estimates (~4 chars/token), not an exact tokenizer. Never apply it to external
output (TC-1), and measure rather than assume the savings.
Cross-references
scripts/token_compression/caveman.py— the deterministic compressor + stats (the machine).- CT6-6 §3 (TC) — the requirements (internal-comms optimization; "talk like a caveman"; evaluate compression packages).
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.

