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 ★
- Raw CLI — The agent harness you can fork 105 ★
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
Apex Deepagents Matrix
Deterministic Mathematical Kernels, Causal Digital Twin Grounding & Compensatory Rollback Middleware for LangC
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
Latch Compact
Manually trigger a latch compaction for the current session
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
Related Agents
Context Engine
Context window management — tracks tool call count, auto-detects when context fills up, triggers state save +
Revops Analyst
RevOps analyst for an organization on GTM OS. Use for revenue and pipeline questions, funnel conversion, attri
Claude Code Tools
by Prasad Chalasani - Well-crafted toolset for session continuity, featuring skills/commands to avoid compacti