Magic Compact
Lossless context compression plugin for Claude Code & OpenCode.
Install
/plugin marketplace add aerovato/magic-compactInstall command taken from the project's README or registry entry. Always review code before running it.
README excerpt
Read full README on GitHub →Magic Compact
English | 中文
[!IMPORTANT] Magic Compact development has been paused in favor of Operator Memory, its successor. Magic Compact focuses on context compression; Operator already provides durable memory and documentation, and will gain context-management features over time. Install and follow Operator for future development; a Claude Code plugin will be added soon. Magic Compact remains fully functional.
Lossless context compression for OpenCode and Claude Code.
Built with Operator Memory
Why
OpenCode and Claude Code's built-in compaction replaces an entire conversation with one summary blob. The user messages, the assistant's reasoning, tool calls, design decisions, and workflow are all flattened into a generic template (Goal, Progress, Key Decisions...). The agent wakes up with amnesia, forced to reconstruct its working state from an abstraction that captured a fraction of what mattered.
Magic Compact takes a different approach: preserve the conversation skeleton, condense each old assistant turn into its own summary, prune bulky tool I/O, and keep everything retrievable. The agent retains its memory of what it did, why, and what comes next.
How
Instead of collapsing an entire session into a single generic summary, Magic Compact replaces old assistant turns with high-fidelity summaries while leaving user messages and tool calls in place.
The assistant's thought process, decisions, and actions remain in context along with all your commands while unnecessary bloat is stripped away. Long tool calls are aggressively pruned but can be retrieved via a custom read_omitted_content tool.
Features
- Lossless context compression — Fully preserve working memory instead of flattening history into one recap.
- Zero compaction overhead — Compaction happens once on your command rather than during the agentic loop. Maximum token savings, minimal cache invalidations.
- Preserved user messages — Exact requirements and guidance remain visible to the agent, verbatim.
- Smart tool call pruning — Bulky completed tool I/O is replaced with omission notices, with original content cached and retrievable on demand via
read_omitted_content. - Recompactable — Run
/magic-compactagain later to compact new turns while preserving prior summaries. - Trim without summarizing — OpenCode can prune historical tool I/O with
/magic-trimwhile preserving assistant responses.
Installation
Magic Compact works flawlessly on Claude Code, but OpenCode will have more features + first class support as OpenCode exposes more functionality to plugins.
Claude Code
Install from this repository's first-party plugin marketplace:
/plugin marketplace add aerovato/magic-compact
/plugin install claude-magic-compact@magic-compact
After installation, run /reload-plugins if Claude Code is already open.
OpenCode
Install from the CLI:
rm -rf ~/.cache/opencode/packages/magic-compact*
opencode plugin magic-compact --global
# If you are encountering "No versions available":
NPM_CONFIG_MIN_RELEASE_AGE=0 opencode plugin magic-compact --global
This installs the package and adds it to your global OpenCode config.
Usage
/magic-compact
To compact, run /magic-compact [N] with an optional argument indicating how many turns to preserve.
Similar plugs
CLI proxy that reduces LLM token consumption by 60-90% on common dev commands. Single Rust binary, zero dependencies
Bash is all you need - A nano claude code–like 「agent harness」, built from 0 to 1
Documented system prompts from Anthropic - Claude Fable 5.1, Opus 5.5, Claude Design, Claude Code. OpenAI - ChatGPT GPT-6-Astra, Codex. Google - Gemini 3.8 Flash, 3.1 Pro,…
Wrap Antigravity, ChatGPT Codex, Claude Code, Grok Build, Muse Code, Devin as an OpenAI/Gemini/Claude/Codex compatible API service, allowing you to enjoy the free Gemini…