Compress long agent sessions with structured summarization — choose between anchored iterative, opaque, or regenerative strategies, optimizing for tokens-per-task rather than tokens-per-request.
---
name: Context Compression
description: Use when long-running agent sessions need context compression, structured summarization, compaction, token-per-task optimization, or durable handoff summaries that preserve decisions, files, risks, and next actions.
---
When sessions or codebases blow past the context window, compress deliberately — optimizing for total tokens-per-task (including re-fetch costs when compression drops something critical), not tokens-per-request.
## How to use
1. Optimize for tokens-per-task: aggressive compression that loses file paths, errors, or decision rationale forces re-exploration that costs more than it saved.
2. Pick a strategy by session shape:
- Anchored Iterative Summarization — for long sessions where file tracking matters; keep a structured persistent summary (intent, file changes, decisions, next steps) and only summarize the newly-truncated span, merging it in to avoid drift.
- Opaque Compression — for short sessions with low re-fetch cost; maximal token savings but no interpretability, so never use it when debugging or artifact tracking matters.
- Regenerative Full Summary — when readability is critical and sessions have clear phase boundaries; accepts cumulative detail loss across cycles.
3. Use structured sections as checklists so the summarizer is forced to preserve decisions, modified files, risks, and next actions.
4. Build probe-based evaluation to verify what a compression strategy actually preserved.
Full skill & source: https://github.com/muratcankoylan/Agent-Skills-for-Context-Engineering/tree/main/skills/context-compressionSign in to rate and review this skill.
No reviews yet. Be the first to review this skill.