
Context Compression
Design summarization and compression tactics so long Claude Code or Cursor sessions stay within context limits without losing file edits and decisions.
Overview
Context Compression Strategies is a journey-wide agent skill that teaches anchored and structured conversation compression—usable whenever a solo builder needs to keep long agent sessions coherent without blowing context
Install
npx skills add https://github.com/sickn33/antigravity-awesome-skills --skill context-compressionWhat is this skill?
- Optimizes tokens per completed task—not naive tokens-per-request minimization
- Anchored iterative summarization with explicit sections for intent, files touched, decisions, and next steps
- Contrasts production approaches including opaque compression and structured merge strategies
- Targets debugging when agents forget which files they modified after truncation
- Frames evaluation criteria for compression quality on multi-million-token sessions
- Three production-ready compression approaches documented in core concepts
Adoption & trust: 930 installs on skills.sh; 40.1k GitHub stars; 3/3 security scanners passed (skills.sh audits).
Who is it for?
Indie builders shipping with Claude Code or Cursor on large repos or marathon sessions who need a repeatable summarization policy before sessions become unusable.
Skip if: Builders on short, single-shot prompts with no history truncation, or teams that do not use agentic multi-turn workflows at all.
When should I use this skill?
Agent sessions exceed context window limits; codebases exceed context windows (5M+ token systems); designing conversation summarization strategies; debugging agents that forget modified files; building evaluation framewo
What do I get? / Deliverables
After applying the skill, you adopt a compression strategy tuned to tokens-per-task with structured summaries that preserve intent, modifications, and next steps across truncations.
- Chosen compression approach (anchored vs opaque vs hybrid)
- Structured summary schema for session intent, files, decisions, and next steps
- Compression quality checks or eval notes
Recommended Skills
Journey fit
Useful at every journey phase - explore requirements and options before committing to a direction.
Where it fits
Define anchored summary sections before a week-long feature branch driven entirely by an agent.
Compress exploration of a five-million-token monorepo while preserving which services were already patched.
Debug a review pass where truncation dropped the list of files the agent had already lint-fixed.
Tune compression policy for recurring production incident runbooks handled in multi-hour agent threads.
Keep discovery notes and open questions intact when validating scope across many competitor-analysis turns.
How it compares
Use for methodology on what to keep in rolling summaries—not as a drop-in MCP server or a generic 'summarize this chat' one-liner.
Common Questions / FAQ
Who is context-compression for?
Solo and indie developers who rely on coding agents for long tasks and need production-minded compression instead of ad-hoc 'compress everything' defaults.
When should I use context-compression?
Use it when sessions exceed the context window, when you are designing summarization for huge codebases, when agents forget prior file edits after compression, or when you are building evals for compression quality—across Build agent-tooling, Ship review/debug loops, and Operate
Is context-compression safe to install?
It is documentation-style procedural knowledge with no inherent shell or network hooks in the skill itself; review the Security Audits panel on this Prism page before installing from the upstream repo.
SKILL.md
READMESKILL.md - Context Compression
# Context Compression Strategies When agent sessions generate millions of tokens of conversation history, compression becomes mandatory. The naive approach is aggressive compression to minimize tokens per request. The correct optimization target is tokens per task: total tokens consumed to complete a task, including re-fetching costs when compression loses critical information. ## When to Use Activate this skill when: - Agent sessions exceed context window limits - Codebases exceed context windows (5M+ token systems) - Designing conversation summarization strategies - Debugging cases where agents "forget" what files they modified - Building evaluation frameworks for compression quality ## Core Concepts Context compression trades token savings against information loss. Three production-ready approaches exist: 1. **Anchored Iterative Summarization**: Maintain structured, persistent summaries with explicit sections for session intent, file modifications, decisions, and next steps. When compression triggers, summarize only the newly-truncated span and merge with the existing summary. Structure forces preservation by dedicating sections to specific information types. 2. **Opaque Compression**: Produce compressed representations optimized for reconstruction fidelity. Achieves highest compression ratios (99%+) but sacrifices interpretability. Cannot verify what was preserved. 3. **Regenerative Full Summary**: Generate detailed structured summaries on each compression. Produces readable output but may lose details across repeated compression cycles due to full regeneration rather than incremental merging. The critical insight: structure forces preservation. Dedicated sections act as checklists that the summarizer must populate, preventing silent information drift. ## Detailed Topics ### Why Tokens-Per-Task Matters Traditional compression metrics target tokens-per-request. This is the wrong optimization. When compression loses critical details like file paths or error messages, the agent must re-fetch information, re-explore approaches, and waste tokens recovering context. The right metric is tokens-per-task: total tokens consumed from task start to completion. A compression strategy saving 0.5% more tokens but causing 20% more re-fetching costs more overall. ### The Artifact Trail Problem Artifact trail integrity is the weakest dimension across all compression methods, scoring 2.2-2.5 out of 5.0 in evaluations. Even structured summarization with explicit file sections struggles to maintain complete file tracking across long sessions. Coding agents need to know: - Which files were created - Which files were modified and what changed - Which files were read but not changed - Function names, variable names, error messages This problem likely requires specialized handling beyond general summarization: a separate artifact index or explicit file-state tracking in agent scaffolding. ### Structured Summary Sections Effective structured summaries include explicit sections: ```markdown ## Session Intent [What the user is trying to accomplish] ## Files Modified - auth.controller.ts: Fixed JWT token generation - config/redis.ts: Updated connection pooling - tests/auth.test.ts: Added mock setup for new config ## Decisions Made - Using Redis connection pool instead of per-request connections - Retry logic with exponential backoff for transient failures ## Current State - 14 tests passing, 2 failing - Remaining: mock setup for session service tests ## Next Steps 1. Fix remaining test failures 2. Run full test suite 3. Update documentation ``` This structure prevents silent loss of file paths or decisions because each section must be explicitly addressed. ### Compress