context-compression
What it does
This skill helps your AI manage very long conversations. It summarizes finished parts of the work and keeps the important decisions. It is for people who run long sessions where the AI starts to lose track.
When to use it
- βWhen a conversation has grown past about twenty or thirty turns.
- βWhen the AI starts repeating earlier suggestions or forgetting decisions.
- βWhen you finish one phase of work and want to move on to another.
Skill link
https://github.com/vudovn/ag-kit/blob/main/.agents/skills/context-compression/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βThis chat has become very long and we keep repeating ourselves. Please summarize what we finished and keep the key decisions.β
5 new skills a week. 1 minute to read.
How it works
The skill replaces long tool outputs and finished work with short summaries. The key decisions are kept, so the AI can keep working without losing context.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
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 test
Level 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 applied
Step 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
FAQ
When should I ask for compression?
Use it when the session is long, when the AI repeats itself or when you switch to a new phase of work.
Will it lose my important decisions?
The skill is designed to keep key decisions while summarizing the rest.
How much does it help?
It is meant to free up room in long sessions, and the savings depend on the session.
Details
Original description by the author
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.
repo: vudovn/ag-kit
Popularity
- GitHub stars
- 8.2k
- Ranking position
- #12529
- License
- MIT
- Updated
- 10/18/2026
Comments
- β¦
More skills from this repository
batch-operations
8.2kHelps your agent make the same change across many files at once, such as renaming a function or replacing an old import everywhere.
brainstorming
8.2kTeaches your agent to ask clarifying questions before building anything new or complex, so it understands your goal first.
code-review-checklist
8.2kGives your agent a checklist for reviewing code for correctness, security, performance, testing and documentation, including AI-specific risks.
code-review-graph
8.2kHelps your agent review code in large projects using a structural map, so it reads only the files affected by a change.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.