by aerovato
Lossless context compression plugin for Claude Code & OpenCode.
Unlocks once the catalog security scan passes (runs nightly).
The deep catalog scan for this skill is still queued. Run an instant dependency check now instead.
# Add to your Claude Code skills
git clone https://github.com/aerovato/magic-compactGuides for using ide extensions skills like magic-compact.
English | 中文
Lossless context compression for OpenCode and Claude Code.
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.
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.
read_omitted_content./magic-compact again later to compact new turns while preserving prior summaries.Magic Compact works flawlessly on Claude Code, but OpenCode will have more features + first class support as OpenCode exposes more functionality to plugins.
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.
Install from the CLI:
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.
/magic-compactTo compact, run /magic-compact [N] with an optional argument indicating how many turns to preserve.
N is the number of recent assistant turns to preserve as-is. Default: 0 (summarize everything).Examples:
/magic-compact — summarize all old assistant turns./magic-compact 3 — keep the 3 most recent assistant turns, summarize the rest./magic-stats (OpenCode Exclusive)Run /magic-stats to show cumulative token savings for the current conversation: tokens pruned, cached tokens saved, estimated money saved, among other statistics.
Magic Compact registers a read_omitted_content tool that the agent can call to retrieve any tool input or output that was pruned during compaction.
Each omission notice in the conversation includes a Content ID (e.g. omitted-001). The agent uses that ID to fetch the original content when it needs stale information that cannot be reproduced via a new tool call.
Claude Code does not expose as much capability to plugins vs OpenCode. Therefore, certain differences are present when using Magic Compact for Claude Code:
/resume <new-session-id> to enter the compacted session
/magic-stats is not implemented for Claude CodePruning applies only to summarized turns.
Kept:
Removed or condensed:
Completed tool outputs over 128 words or 1024 characters are omitted by default. A few tools have special handling.
read — output always omitted (stale file contents are reloadable)write / edit / apply_patch — large file content omittedbash — commands over 1024 characters are truncatedtask — output omitted above a higher threshold (512 words / 4096 characters)question — input and output preservedtodowrite / skill — output discarded without caching (redundant or reloadable)Read / NotebookEdit — output always omitted (file text, notebook JSON, images, PDFs are reloadable)Bash.command — commands over 512 characters truncated; full command cached with an omission IDAgent / TaskOutput — output omitted above a higher threshold (512 words / 4096 characters)AskUserQuestion — input and output preserved (captures explicit user decisions)Skill — output discarded without caching (reloadable by re-invoking the skill)Pending, running, and errored tool calls are always preserved as-is.
OpenCode-DCP is a runtime context management system that rewrites messages when requested by the model. Magic Compact takes a different approach.
Magic Compact Offers:
If you want model-driven compaction with increased cache invalidations and token burn, consider using DCP instead.
Magic Context is a much broader runtime context-management system: it runs background historian and dreamer processes, maintains project memory, and injects recalled memories and history back into the prompt on an ongoing basis. That makes it powerful, but also much heavier in tokens and cache churn.
Magic Compact Offers:
If you want a lightweight, user-driven compaction tool with minimal ongoing overhead, Magic Compact is the better fit. If you want a full long-term memory system with background maintenance, Magic Context is the heavier alternative.
See docs/Development.md for setup and maintenance commands.
magic-compact is an open-source ide extensions skill for AI coding assistants such as Claude Code, Codex CLI, and ChatGPT, built by aerovato. Lossless context compression plugin for Claude Code & OpenCode. It has 69 GitHub stars.
magic-compact's catalog security scan is still queued. You can run an instant dependency and prompt-injection check now with the "Scan for vulnerabilities" button above.
Clone the repository with "git clone https://github.com/aerovato/magic-compact" and add it to your Claude Code skills directory (see the Installation section above).
magic-compact is primarily written in TypeScript. It is open-source under aerovato on GitHub, so you can review or fork the full source.
Yes. SkillsLLM lists many other IDE Extensions skills you can browse and compare side by side. Open the IDE Extensions category from the badge at the top of this page, or use the Related Skills and comparison links further down to weigh magic-compact against similar tools.
No comments yet. Be the first to share your thoughts!
Top skills in this category by stars