emanueleielo

Compact Middleware — Development skill for Claude Code

Development community

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.

PyPI License Python DeepAgents

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