Skip to content
Back to skills

Context Compression

ASecurity

Compress agent context while preserving critical information for long-running sessions.

  • 7 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 3, 2026
ai-agents

Security analysis

A100/100

Pro scans all 2 files and shows the line behind each finding

Scanned September 3, 2026

npx -y skills add mediar-ai/skillhubz --skill context-compression --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Compression?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Context Compression
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/mediar-ai-context-compression/badge)](https://www.skillsdirectory.com/skills/mediar-ai-context-compression)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Context Compression Strategies

Compress agent context while preserving critical information for long-running sessions.

## Prerequisites

- Understanding of context windows
- Familiarity with summarization techniques

## Instructions

### Key Insight

Optimize for **tokens-per-task**, not tokens-per-request. When compression loses critical details, agents must re-fetch information, wasting more tokens overall.

### Compression Approaches

| Approach | Compression | Quality | Trade-off |
|----------|-------------|---------|-----------|
| Anchored Iterative | 98.6% | 3.70 | Best quality |
| Regenerative | 98.7% | 3.44 | Moderate |
| Opaque | 99.3% | 3.35 | Best compression |

### Structured Summary Sections

```markdown
## Session Intent
[What the user is trying to accomplish]

## Files Modified
- file.ts: Description of changes

## Decisions Made
- Key decision and rationale

## Current State
- Progress status

## Next Steps
1. Next action item
```

### Compression Triggers

| Strategy | Trigger Point |
|----------|---------------|
| Fixed threshold | 70-80% context utilization |
| Sliding window | Keep last N turns + summary |
| Task-boundary | Compress at logical task completions |

### Probe-Based Evaluation

Test compression quality by asking questions:

| Probe Type | Tests |
|------------|-------|
| Recall | "What was the original error?" |
| Artifact | "Which files have we modified?" |
| Continuation | "What should we do next?" |

## Guidelines

1. Use structured summaries with explicit sections
2. Implement incremental merging, not full regeneration
3. Track artifact trail separately (weakest dimension)
4. Accept slightly lower compression for better quality
5. Monitor re-fetching frequency as quality signal

## Notes

- Structure forces preservation through dedicated sections
- Artifact trail integrity is universally weak (2.2-2.5/5.0)
- Sliding window with structured summaries is best for coding agents

Source: muratcankoylan/Agent-Skills-for-Context-Engineering

Files in this skill

  • manifest.json334 B
  • skill.md2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…