context-compressor
Skill952 starsChanged 3 months agoMITView on GitHub
Strategies for compressing context to maximize token efficiency
5 other projects use a version of this.
Adopted by
Most recently taken up by
- zedarvates/frugal-skillstheir own version, first seen Nov 8, 2026
- lihao-24/claude-skillstheir own version, first seen Oct 25, 2026
- fatih-developer/fth-skillstheir own version, first seen Oct 13, 2026
- cyfung1031/skillstheir own version, first seen Jun 17, 2026
- PengEjeen/claude_skillstheir own version, first seen May 22, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- fatih-developer/fth-skills★ 7same name
- cyfung1031/skills★ 2same name
- zedarvates/frugal-skills★ 1same name
- lihao-24/claude-skills★ 0same name
- PengEjeen/claude_skills★ 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 repository12 other files it gives its agents.
- adapters/CLAUDE.mdCLAUDE.md
- codebase-mapperSkill
- context-fetchSkill
- context-health-monitorSkill
- debuggerSkill
- empirical-validationSkill
- executorSkill
- plan-checkerSkill
- plannerSkill
- subagent-delegationSkill
- token-budgetSkill
- verifierSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
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 103
Start with outline (Level 1)
- Distinctive: line 104
If insufficient, load key functions (Level 2)
- Distinctive: line 105
If still stuck, load related code (Level 3)
- Distinctive: line 133
When you need details from compressed context:
≈ “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
Context Compressor Skill
<role>
You are a context compression specialist. Your job is to maintain rich understanding while using minimal tokens.Core principle: Compress aggressively, decompress only when needed.
</role>
Compression Strategies
Strategy 1: Summary Mode
When: You've fully understood a file and may need to reference it later.
How:
## File Summary: src/auth/login.ts
**Purpose:** Handles user login via email/password
**Key functions:**
- handleLogin(req, res) → Validates credentials, returns JWT
- validateCredentials(email, password) → Checks against DB
**Dependencies:** bcrypt, jose, database
**Tokens saved:** ~400 (95 lines not reloaded)Use instead of: Re-reading the full file
Strategy 2: Outline Mode
When: You need to understand a file's structure but not implementation details.
How:
## Outline: src/services/payment.ts (127 lines)
- L1-15: Imports and types
- L17-35: PaymentService class
- L20: constructor(config)
- L25: processPayment(amount, method)
- L45: refund(transactionId)
- L67: getHistory(userId)
- L90-127: Helper functionsTokens: ~50 vs ~500 for full file
Strategy 3: Diff-Only Mode
When: You've already seen a file and need to understand changes.
How:
## Changes to: src/config.ts
Added:
- L45: TOKEN_BUDGET_THRESHOLD = 0.5
- L46: COMPRESSION_ENABLED = true
Modified:
- L12: MAX_CONTEXT → increased from 100000 to 150000Use for: Reviewing modifications, understanding updates
Strategy 4: Reference Mode
When: You need to track a file without loading it.
How:
## References
| File | Last Seen | Summary | Load If |
|------|-----------|---------|---------|
| auth.ts | Task 2 | Login handling | Auth bugs |
| db.ts | Task 1 | Postgres client | DB errors |
| utils.ts | Never | Utility funcs | Helper needed |Cost: ~10 tokens vs ~200+ per file
Strategy 5: Progressive Disclosure
When: Unsure how much detail is needed.
Process:
- Start with outline (Level 1)
- If insufficient, load key functions (Level 2)
- If still stuck, load related code (Level 3)
- Full file only as last resort (Level 4)
L1: Outline → "I see handleLogin at L25"
L2: Function → "handleLogin validates then calls createToken"
L3: Related → "createToken uses jose.sign with HS256"
L4: Full → Only for complex debuggingCompression Triggers
Automatic Compression Points
| Trigger | Action |
| After understanding a file | Create summary |
| Switching tasks | Compress previous context |
| Budget at 50% | Aggressive outline mode |
| Budget at 70% | Summary-only mode |
| End of wave | Full compression pass |
Decompression Protocol
When you need details from compressed context:
- Check summary first — Often sufficient
- Load specific section — If summary incomplete
- Full load as last resort — And re-compress after
## Decompression Log
| File | Reason | Level | Tokens |
|------|--------|-------|--------|
| auth.ts | Debug login | L2 (func) | +150 |
| db.ts | Check query | L3 (snippet) | +50 |Compression Format Templates
Summary Template
## 📦 [filename]
**Purpose:** [one line]
**Key exports:** [list]
**Dependencies:** [list]
**Patterns:** [notable patterns used]
**Watch for:** [gotchas or edge cases]Outline Template
## 📋 [filename] (N lines)
- L[start]-[end]: [section name]
- L[n]: [key item]
- L[n]: [key item]Diff Template
## Δ [filename]
**+** [additions]
**-** [removals]
**~** [modifications]Integration
Works with:
token-budget— Triggers compression at thresholdscontext-fetch— Provides input for compressioncontext-health-monitor— Monitors compression effectiveness
Anti-Patterns
❌ Keeping full files in mental context — Compress after understanding ❌ Re-reading instead of referencing — Use summaries ❌ Loading full file for one function — Use outline + target ❌ Skipping compression "to save time" — Costs more later
Part of GSD v1.6 Token Optimization. See docs/token-optimization-guide.md for examples.
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.

