# Magic compact

> Magic compact is an open-source agent skill for ai models and llm tooling. Claude Code slash command shim for compacting a session with the Magic Compact plugin. It is available on Claude Code.

- **Kind:** Skill
- **Pricing:** Open source
- **Platforms:** Claude Code
- **Website:** https://github.com/aerovato/magic-compact/tree/main/packages/claude-code-plugin/skills/magic-compact
- **Repository:** https://github.com/aerovato/magic-compact
- **GitHub stars:** 180
- **License:** BSD-3-Clause
- **Skill name:** magic-compact
- **Collection:** https://github.com/aerovato/magic-compact
- **Categories:** [AI models and LLM tooling](https://ai-powered.com/categories/ai-and-llm), [developer tools](https://ai-powered.com/categories/developer-tools)
- **Listing updated:** 2026-11-30

## About

This skill is a thin shim for the `/magic-compact [N]` slash command in Claude Code. The actual compaction is handled by a hook from the `claude-magic-compact` plugin, which intercepts the command before the agent acts on it.

The SKILL.md itself holds no compaction logic. It is only reached when the hook fails to intercept the command. In that case it tells the agent to alert the user and suggest checking that the `claude-magic-compact` plugin is installed and enabled.

The command takes an optional numeric argument, shown as `[N]`. Model invocation is disabled, so the skill runs only when the user types the command, not when the agent decides a task matches.

## When your agent uses it

> Compact this Claude Code session.

## What it can access

From a static check of the files on GitHub; nothing was run.

- [Instructions only, no scripts](https://github.com/aerovato/magic-compact/tree/HEAD/packages/claude-code-plugin/skills/magic-compact)
- [License: BSD-3-Clause](https://github.com/aerovato/magic-compact/tree/HEAD/packages/claude-code-plugin/skills/magic-compact)

## Features

- **Slash command entry point:** Registers `/magic-compact [N]` so the command is available in Claude Code.
- **Optional argument:** Accepts an optional `[N]` argument that is passed along for the plugin hook to handle.
- **Hook failure fallback:** If the hook does not intercept the command, the agent warns the user instead of silently doing nothing.
- **Manual invocation only:** Model invocation is disabled, so the agent never triggers it on its own.
- **Plugin install guidance:** Points users to check that the `claude-magic-compact` plugin is installed and enabled.

## Good for

- Compact a long Claude Code session with a single slash command
- Run `/magic-compact` with a number argument to control the compaction
- Diagnose why the Magic Compact hook did not fire
- Check that the claude-magic-compact plugin is installed and enabled

## Install

### Claude Code

Copy the skill folder to `~/.claude/skills/magic-compact` to use it in all your projects:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/aerovato/magic-compact.git "$tmp" &&
mkdir -p ~/.claude/skills &&
rm -rf ~/.claude/skills/magic-compact &&
cp -R "$tmp/packages/claude-code-plugin/skills/magic-compact" ~/.claude/skills/magic-compact &&
rm -rf "$tmp"
```

For one project only, put the folder in `.claude/skills/magic-compact` inside it instead.

### Codex

Copy the skill folder to `~/.agents/skills/magic-compact` to use it in every repository:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/aerovato/magic-compact.git "$tmp" &&
mkdir -p ~/.agents/skills &&
rm -rf ~/.agents/skills/magic-compact &&
cp -R "$tmp/packages/claude-code-plugin/skills/magic-compact" ~/.agents/skills/magic-compact &&
rm -rf "$tmp"
```

For one repository only, put the folder in `.agents/skills/magic-compact` inside it instead.

### Cursor

Copy the skill folder to `~/.cursor/skills/magic-compact` to use it in every project:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/aerovato/magic-compact.git "$tmp" &&
mkdir -p ~/.cursor/skills &&
rm -rf ~/.cursor/skills/magic-compact &&
cp -R "$tmp/packages/claude-code-plugin/skills/magic-compact" ~/.cursor/skills/magic-compact &&
rm -rf "$tmp"
```

For one project only, put the folder in `.cursor/skills/magic-compact` inside it instead.

### Gemini CLI

Run in a terminal (add `--scope workspace` to install it for the current workspace only):

```sh
gemini skills install https://github.com/aerovato/magic-compact.git --path packages/claude-code-plugin/skills/magic-compact
```

Or copy the folder to `~/.gemini/skills/magic-compact` yourself.

### VS Code

For GitHub Copilot in VS Code, copy the skill folder to `~/.copilot/skills/magic-compact`:

```sh
tmp=$(mktemp -d) &&
git clone --depth 1 https://github.com/aerovato/magic-compact.git "$tmp" &&
mkdir -p ~/.copilot/skills &&
rm -rf ~/.copilot/skills/magic-compact &&
cp -R "$tmp/packages/claude-code-plugin/skills/magic-compact" ~/.copilot/skills/magic-compact &&
rm -rf "$tmp"
```

For one project only, put the folder in `.github/skills/magic-compact` inside it instead.

### Other agents

Get the folder:

```sh
git clone --depth 1 https://github.com/aerovato/magic-compact.git
```

Then copy `magic-compact/packages/claude-code-plugin/skills/magic-compact` into your agent's skills folder as `magic-compact`. Agents that support SKILL.md read one folder per skill.

## FAQ

### Does Magic compact compact the session by itself?

No. It is a shim. The compaction is done by a hook from the claude-magic-compact plugin, which intercepts the command.

### What happens if I see its instruction text?

It means the hook failed to intercept the command. The agent will tell you and suggest checking that the claude-magic-compact plugin is installed and enabled.

### Can the agent invoke Magic compact automatically?

No. Model invocation is disabled, so it only runs when you type the `/magic-compact` command.

### What does the [N] argument do?

The skill declares an optional `[N]` argument hint. Its exact meaning is handled by the plugin hook and is not described in the skill.

### How do I install Magic compact in Claude Code?

Copy the skill folder from GitHub to ~/.claude/skills/magic-compact to use it in all your projects, or to .claude/skills/magic-compact in one project.

### Does Magic compact run scripts?

No. It is instructions only, with no scripts. This comes from a static check of the files on GitHub; nothing was run. Read the files before you install it.

### Which AI agents can use Magic compact?

Claude Code. It reads skills in the SKILL.md format; the install steps on this page show where to put the folder.

### What are the best alternatives to Magic compact?

The closest alternatives to Magic compact are Compact now, Conventions claude, Compress, Writing hooks and Skill update.

## Where this comes from

- Description: from the skill's own SKILL.md.

## Alternatives

- [Compact now](https://ai-powered.com/skills/compact-now): Compact now is an open-source agent skill for developer tools.
- [Conventions claude](https://ai-powered.com/skills/conventions-claude-xiaolai): Conventions claude is an open-source agent skill for ai models and llm tooling.
- [Compress](https://ai-powered.com/skills/compress): Compress is an open-source agent skill for ai models and llm tooling.
- [Writing hooks](https://ai-powered.com/skills/writing-hooks-xiaolai): Writing hooks is an open-source agent skill for developer tools.
- [Skill update](https://ai-powered.com/skills/skill-update): Skill update is an open-source agent skill for developer tools.
- [Session hardening](https://ai-powered.com/skills/session-hardening): Session hardening is an open-source agent skill for developer tools.
- [Autonomous agent harness](https://ai-powered.com/skills/autonomous-agent-harness): Autonomous agent harness is an open-source agent skill for developer tools.
- [Code simplifier](https://ai-powered.com/skills/code-simplifier): Code simplifier is an open-source agent skill for developer tools.

---
Source: https://ai-powered.com/skills/magic-compact
