Compact Middleware — Development skill for Claude Code
Claude Code's compaction engine, as a drop-in DeepAgents middleware.
How to install Compact Middleware
This entry records only its repository, not the path inside it, so there is no
exact command to give. Open emanueleielo/compact-middleware and copy the folder into
~/.claude/skills/, or the file into ~/.claude/agents/.
What Compact Middleware does
Claude Code's compaction engine, as a drop-in DeepAgents middleware.
Alternatives in Development
- Openwolf — Sharper context 699 ★
- Fast Jev Compaction — Claude Code plugin that replaces the compaction summary with Jev decisions: every tool call and result is scor 425 ★
- Compact 서비스 (대화 요약) — 관찰 위치: Claude Code 내부 아키텍처 변수: NO_TOOLS_PREAMBLE, BASE_COMPACT_PROMPT, PARTIAL_COMPACT_PROMPT, PARTIAL_COMPACT 149 ★
README
compact-middleware
Claude Code's compaction engine, as a drop-in DeepAgents middleware.
Problem • How it works • Quick start • Configuration • Comparison
Long-running AI agents hit the context window wall. The built-in `SummarizationMiddleware` does a single-pass summary with a generic prompt — it works, but it loses critical details and has no lightweight fallbacks.
**compact-middleware** takes the battle-tested compaction pipeline from [Claude Code](https://docs.anthropic.com/en/docs/claude-code) and makes it a composable [DeepAgents](https://github.com/langchain-ai/deepagents) middleware. One import, and your agents handle **10x longer conversations** without blowing the context window.
The Problem
| What goes wrong | Built-in middleware | compact-middleware |
|---|---|---|
| Summary loses file paths, code, user feedback | Generic prompt | 9-section structured prompt |
| Every compaction = expensive LLM call | Yes | 3 free levels tried first |
| Recently-read files vanish after compaction | Yes | Auto-restores top 5 files + active plan |
| Compaction fails |
Related Skills
Post Compact Reminder
Claude Code hook that detects context compaction and injects a reminder to re-read AGENTS.md, preventing post-
Context Compact
Prepare context for compaction: $ARGUMENTS
Compact
Prepare session state for context compaction — capture learnings, save state, then compact
Cc Strategic Compaction
Claude Code mod to allow the Agent to auto compact himself based on instructions, programatic conditions or ex
Do Not Compact
Claude Code plugin: reload CLAUDE.md files after context compaction
Skill Compact
Shrink Claude Code SKILL.md token cost without breaking skills. Trigger-preserving description gate + lossless
Related Agents
Context Engine
Context window management — tracks tool call count, auto-detects when context fills up, triggers state save +
Claude Code Tools
by Prasad Chalasani - Well-crafted toolset for session continuity, featuring skills/commands to avoid compacti
Vbw Lead
Planning agent that researches, decomposes phases into plans, and self-reviews in one compaction-extended sess