Skip to content
Back to skills

Context Compactor

ASecurity

Automatic context summarization for long-running sessions. Use when context is approaching limits, summarizing completed work, preserving critical information, or managing token budgets.

  • 3 stars
  • 0 votes
  • 1 copy
  • 13 views
  • Added February 8, 2026
businesspythongo

Security analysis

A100/100

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

Scanned February 12, 2026

npx -y skills add adaptationio/Skrillz --skill context-compactor --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Compactor?

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

Security grade badge for Context Compactor
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adaptationio-context-compactor/badge)](https://www.skillsdirectory.com/skills/adaptationio-context-compactor)

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
---
name: context-compactor
description: Automatic context summarization for long-running sessions. Use when context is approaching limits, summarizing completed work, preserving critical information, or managing token budgets.
version: 1.0.0
category: autonomous-coding
layer: context-engineering
---

# Context Compactor

Automatically summarizes and compacts context when approaching token limits while preserving critical information.

## Quick Start

### Check if Compaction Needed
```python
from scripts.compactor import ContextCompactor

compactor = ContextCompactor()
if compactor.should_compact(context, limit=100000):
    compacted = compactor.compact(context)
```

### Compact Context
```python
compacted = compactor.compact(context)
# Preserves: architectural decisions, bugs, current state
# Discards: stale tool outputs, redundant messages
```

## Preservation Strategy

```
┌─────────────────────────────────────────────────────────────┐
│                  PRESERVATION PRIORITY                       │
├─────────────────────────────────────────────────────────────┤
│                                                              │
│  MUST PRESERVE (Never remove)                               │
│  ├─ Architectural decisions                                 │
│  ├─ Unresolved bugs and blockers                           │
│  ├─ Current feature state                                   │
│  ├─ Recent file changes (last 5)                           │
│  └─ Error patterns and solutions                           │
│                                                              │
│  CAN SUMMARIZE (Compress to summary)                        │
│  ├─ Completed features (list of IDs)                       │
│  ├─ Resolved errors (brief mention)                        │
│  └─ Historical decisions (key points)                      │
│                                                              │
│  CAN DISCARD (Remove entirely)                              │
│  ├─ Redundant tool outputs                                 │
│  ├─ Stale search results                                   │
│  ├─ Superseded messages                                    │
│  └─ Verbose logging                                         │
│                                                              │
└─────────────────────────────────────────────────────────────┘
```

## Compaction Process

1. **Score Importance**: Assign score to each message/content
2. **Identify Critical**: Mark must-preserve content
3. **Summarize Middle**: Compress can-summarize content
4. **Discard Stale**: Remove can-discard content
5. **Validate**: Ensure compacted context is coherent

## Token Budgets

| Context Type | Limit | Action |
|--------------|-------|--------|
| < 50% | Normal | No action |
| 50-75% | Warning | Prepare for compaction |
| 75-90% | Compact | Trigger compaction |
| > 90% | Critical | Aggressive compaction |

## Integration Points

- **autonomous-session-manager**: Triggers compaction check
- **memory-manager**: Stores compacted summaries
- **handoff-coordinator**: Uses compacted state for handoffs

## References

- `references/COMPACTION-STRATEGY.md` - Detailed strategy
- `references/TOKEN-BUDGETS.md` - Budget management

## Scripts

- `scripts/compactor.py` - Core ContextCompactor
- `scripts/importance_scorer.py` - Message scoring
- `scripts/summarizer.py` - Content summarization
- `scripts/token_estimator.py` - Token counting

Files in this skill

  • SKILL.md3.9 KB
  • references/COMPACTION-STRATEGY.md3.5 KB
  • scripts/compactor.py4.2 KB
  • scripts/importance_scorer.py3.6 KB
  • scripts/summarizer.py3.8 KB
  • scripts/token_estimator.py2.6 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…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.