By morphllm
Replace Claude Code's context compaction with Morph's service by installing an API key in ~/.claude/morph/.env and appending override instructions to ~/.claude/CLAUDE.md. Uninstall cleans up files. Run TypeScript hooks via Bun on PreCompact, SessionStart, SubagentStart, and UserPromptSubmit for session lifecycle automation.
npx claudepluginhub morphllm/morph-claude-code-plugin --plugin morph-compactA Claude Code marketplace that houses Morph integration plugins. There is currently only one plugin:
[!IMPORTANT] This plugin enables morph's Flash Compact, but does NOT provide warpgrep OR fast apply. Those are available through the mcp. We strongly reccomend having BOTH the MCP and Plugin installed.
The morph-compact plugin hooks parts of the compaction lifecycle in order to inject Morph Compact into its context.
[!IMPORTANT] Currently there is no way to make the default calude code compaction NOT run. So we prompt inject, asking claude's own summarization model to not waste time summarizing, instead only output a few words. Your claude will use morph's provided context instead. Prompt injection is not a fool proof method, we're working on making this more reliable and consisten. We are open to PRs for this. More detailes below
The former uses the PreCompact hook and the latter uses the SessionStart hook.
Run the install skill to set up your API key and compact instructions:
/morph-compact:install
This will:
~/.claude/morph/.env~/.claude/CLAUDE.mdTo remove:
/morph-compact:uninstall
The API key can also be provided via the MORPH_API_KEY environment variable, which takes precedence over the file.
Due to limitations with Claude Code's hooks, we are unable to alter the output of a compaction.
To work around this, the install skill adds compact instructions to ~/.claude/CLAUDE.md that tell Claude to skip its own summarization when Morph is handling it. This reduces time spent compacting.
For manual compaction, simply run:
/compact morph
Claude will see the morph instruction and output only the sentinel text, letting Morph's summary take over.
If the compact instructions are not followed (more likely on very large sessions), the plugin will detect this and prompt you to run /compact morph again. The second compaction operates on a much smaller context and is far more likely to succeed. The Morph summary is cached, so no additional API call is made on retry.
[!WARNING] Even with these instructions, there's no guarantee that compaction will respect them. We are currently working on a more reliable way to fully disable claude's own compaction.
Replace /compact with intelligent context transfer - analyzes current thread and generates focused prompts for new threads based on your goal
Share bugs, ideas, or general feedback.
Automatic context preservation - saves 50-60% tokens across sessions
Memory compression system for Claude Code - persist context across sessions
Governor: always-on compact professional output, telemetry, context slimming, tool-output filtering, prompt guidance, and drift guardrails for Claude Code Max users.
Ultra-compressed communication mode. Cuts ~75% of tokens while keeping full technical accuracy by speaking like a caveman.
Intelligent prompt optimization using skill-based architecture. Enriches vague prompts with research-based clarifying questions before Claude Code executes them