context-compression
Skill9 starsChanged 3 months agoApache-2.0View on GitHub
Manage and compress conversation context in long sessions. Detect when context is growing large, summarize completed work phases, archive old findings while preserving key decisions. Prevents context degradation. When a session has 20+ turns, when context feels repetitive, when the agent is losing track of earlier work, or when the user says 'summarize what we've done'. NOT for short sessions.
24 other projects use a version of this, 2 of them edited.
Adopted by
Most recently taken up by
- docxology/templatetheir own version, first seen Oct 30, 2026
- viasrijan/crazy-skillstheir own version, first seen Oct 20, 2026
- AbdelrhmanAlquran/claude-skillstheir own version, first seen Oct 20, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
- brake71/1c-ssl-skillstheir own version, first seen Oct 13, 2026
- DBAAZzz/skillstheir own version, first seen Oct 13, 2026
Used with
Projects with it also use bdi-mental-states, hosted-agents and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
Downey6689Skillbdi-mental-states
Transforms external RDF context into BDI mental states. Invoke when modeling beliefs, desires, and intentions.
Also in 5 projects that use this
Downey6689Skillhosted-agents
Guidance for hosted/sandboxed agents. Invoke when running background agents in isolated VMs or multi-client setups.
Also in 5 projects that use this
DVwebBiz11Skillself-improvement-loops
This skill should be used when the harness, scaffold, workflow, or optimizer itself is the optimization target: recursive self-improvement (RSI) loops, meta-harnesses, self-improving harnesses that mine their own failures and propose bounded edits, evolutionary or population-based search over agent scaffolds, acceptance gates for self-modifying systems, and agentic context evolution where the mechanism that produces context is versioned and evolved. Route governance of a single autonomous loop (locked surfaces, durable logs, rollback, novelty gates, approval boundaries) to harness-engineering, measurement and quality-gate design to evaluation, judge design to advanced-evaluation, and remote sandbox infrastructure to hosted-agents.
Also in 4 projects that use this
DVwebBiz11Skilllong-horizon-prompting
This skill should be used when writing, enhancing, or evaluating the launch prompt for a long-running autonomous agent or a parallel multi-agent orchestration attacking a hard problem: pseudo-formal task briefs that define terms and an exact success predicate linguistically, enumerate non-counting outcomes, set persistence rules with explicit stop and return conditions and effort floors, manage a diverse portfolio of parallel approaches with an approach registry and blocked-route bookkeeping, and gate the return on adversarial audit. Route agent topology and coordination protocols to multi-agent-patterns, runtime control surfaces and loop governance to harness-engineering, evaluator and quality-gate construction to evaluation, judge design to advanced-evaluation, and compaction or memory mechanics to context-compression and memory-systems.
Also in 4 projects that use this
AbdelrhmanAlquranSkilllatent-briefing
This skill should be used when the user asks to "share memory between agents", "KV cache compaction for multi-agent", "orchestrator worker context", "latent briefing", "reduce worker tokens", "cross-agent memory without summarization", or discusses Attention Matching compaction, recursive language models with workers, or token explosion in hierarchical agents.
Also in 4 projects that use this
- +2 more from Downey6689
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 2
- vudovn/ag-kit★ 8.2k98% same
- vudovn/antigravity-kit★ 8.2k98% same
Wrote their own version · 22
- bojieli/ai-agent-book-projects★ 53ksame name
- bojieli/ai-agent-book★ 53ksame name
- muratcankoylan/Agent-Skills-for-Context-Engineering★ 18ksame name
- brake71/1c-ssl-skills★ 85same name
- Fandry96/k3-agentic-skills★ 27same name
- docxology/template★ 23same name
- xfstudio/skills★ 9same name
- Archive228/lab-skills★ 8same name
- rohunvora/my-claude-skills★ 6same name
- yeaight7/agent-powerups★ 6same name
12 more not listed
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 repository36 other files it gives its agents.
- .claude/CLAUDE.mdCLAUDE.md
- CLAUDE.mdCLAUDE.md
- api-designSkill
- architectureSkill
- bash-linuxSkill
- batch-operationsSkill
- behavioral-modesSkill
- claude-code-worktreesSkill
- clean-codeSkill
- coordinator-modeSkill
- database-designSkill
- deployment-proceduresSkill
- documentation-templatesSkill
- error-handlingSkill
- github-issuesSkill
- github-pmSkill
- github-projectSkill
- git-workflowSkill
- goal-builderSkill
- graphifySkill
- intelligent-routingSkill
- lint-and-validateSkill
- lint-fixSkill
- memory-systemSkill
- performance-profilingSkill
- powershell-windowsSkill
- pre-commit-verifySkill
- red-team-tacticsSkill
- release-vsixSkill
- run-testsSkill
- server-managementSkill
- setup-testingSkill
- testing-patternsSkill
- test-triageSkill
- uncle-bob-craftSkill
- vulnerability-scannerSkill
The file
Files
<!-- Vendored from ag-kit (github.com/vudovn/ag-kit) @ 20a13da6d4414c7c6ae33db050a9c606eaef9f40 :: .agents/skills/context-compression/SKILL.md. MIT (c) vudovn. -->Context Compression — Long Session Management
Keep sessions productive by compressing completed work while preserving key decisions.
Overview
Long sessions (30+ turns) cause context degradation — the AI loses track of earlier work, repeats itself, or forgets decisions. Context compression proactively summarizes completed phases so the context window stays focused on active work.
Token Impact: Recovers 5,000-15,000 tokens in long sessions by replacing verbose tool outputs with semantic summaries.
When to Compress
| Signal | Action |
| Session has 20+ turns | Consider proactive compression |
| Agent repeats earlier suggestions | Context is saturated — compress now |
| User says "we already discussed this" | Compress immediately |
| Switching to a new phase of work | Compress the completed phase |
| Large tool output (500+ lines) | Micro-compact the output |
Compression Levels
Level 1: Micro-Compact (Tool Output)
Compress individual tool outputs while retaining semantic content:
❌ Before (raw grep output — 200 lines, ~4,000 tokens):
src/auth/jwt.ts:15: import { verify } from 'jsonwebtoken'
src/auth/jwt.ts:23: export function validateToken(token: string) {
src/auth/jwt.ts:24: try {
src/auth/jwt.ts:25: const decoded = verify(token, SECRET)
... (195 more lines)
✅ After (micro-compact — 5 lines, ~100 tokens):
Grep results for "jwt": Found 8 files, 42 matches.
Key files: src/auth/jwt.ts (main JWT logic), src/middleware/auth.ts (middleware),
src/api/login.ts (token creation). Token validation at jwt.ts:23-40.
Error handling at jwt.ts:42-55. Secret loaded from env at jwt.ts:8.Level 2: Phase Summary
Replace a completed work phase with a summary:
❌ Before (full research transcript — ~3,000 tokens):
[turn 1] Read package.json...
[turn 2] Read src/index.ts...
[turn 3] Grep for "auth"...
[turn 4] Found 8 files related to auth...
[turn 5] Read src/auth/jwt.ts...
... (10 more turns of exploration)
✅ After (phase summary — ~200 tokens):
## Research Phase Complete
- Project: Next.js 15 app with JWT auth
- Auth files: 8 files in src/auth/, src/middleware/, src/api/
- Token flow: login → create JWT → store in httpOnly cookie → validate in middleware
- Bug location: src/auth/jwt.ts:45 — expiry check uses `<` instead of `<=`
- Decision: Fix the comparison operator, add edge case testLevel 3: Session Checkpoint
Full session summary for long-running work:
## Session Checkpoint (Turn 35)
### Completed
- [x] Researched auth system (8 files, JWT flow mapped)
- [x] Fixed token expiry bug in jwt.ts:45
- [x] Added edge case test in jwt.test.ts
- [x] Verified: all 42 tests passing
### In Progress
- [ ] Update API documentation
- [ ] Review related middleware
### Key Decisions
1. Keep httpOnly cookies (not localStorage) for token storage
2. Use `<=` for expiry check to include exact-moment expiry
3. Add 5-minute grace period for clock skew
### Files Modified
- src/auth/jwt.ts (line 45: comparison fix)
- tests/auth/jwt.test.ts (added 3 edge case tests)Compression Protocol
Step 1: Identify Completed Phases
What work is DONE and won't be revisited?
→ Research findings already synthesized
→ Implementation already verified
→ Decisions already made and appliedStep 2: Extract Key Information
From the completed phase, preserve:
✅ Decisions made and WHY
✅ File paths and line numbers of changes
✅ Key findings that inform ongoing work
✅ Error messages or test results (summarized)
Discard:
❌ Step-by-step tool invocation details
❌ Full file contents that were read
❌ Exploratory dead-ends that didn't lead anywhere
❌ Verbose error stack traces (keep the message only)Step 3: Write Summary
Use the Phase Summary format above.
Keep to 100-300 tokens per completed phase.
Include enough detail to resume work without re-reading.Best Practices
- Compress phases, not facts — Individual decisions should stay, full transcripts should go
- Preserve "why" over "what" — Why a decision was made matters more than the exact commands run
- Never auto-compress — Always tell the user "I'm summarizing the completed research phase to keep context focused"
- Keep file references — Always preserve file paths and line numbers in summaries
- Checkpoint on phase transitions — Natural compression point when switching from research to implementation
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.

