A Claude Code plugin that automatically saves conversations before context compaction and injects historical context after compaction.
- Auto-save conversations - Automatically saves full conversation to Markdown before context compression
- Context injection - Injects summary of recent conversations after compaction for Claude's reference
- Dual format - Saves both Markdown (human-readable) and JSON (programmatic access)
- Auto-cleanup - Keeps only the most recent 50 archives to save disk space
- Index file - Maintains an index of all archived conversations
/plugin marketplace add anthhub/claude-context-saver/plugin install context-saver@anthhub# Clone the repository
git clone https://github.com/anthhub/claude-context-saver.git
# Load the plugin locally
claude --plugin-dir ./claude-context-saverWhen context is about to be compacted (manually via /compact or automatically when context window fills):
- Captures the full conversation transcript
- Converts it to readable Markdown format
- Saves to
.claude/context-archives/in project directory - Also saves raw JSON for programmatic access
- Updates
latest.mdsymlink andindex.md
When a new session starts after compaction:
- Reads recent archive files
- Extracts key conversation snippets
- Outputs a summary for Claude to reference
- Provides path to full archives
After installation, archives are stored in:
your-project/
└── .claude/
└── context-archives/
├── index.md # Index of all archives
├── latest.md -> conversation_xxx.md # Symlink to latest
├── conversation_20260205_143022.md # Markdown archive
├── conversation_20260205_143022.json # JSON archive
└── ...
# Conversation Archive
| Property | Value |
|----------|-------|
| Saved At | 2026-02-05 14:30:22 |
| Session ID | `abc123` |
| Trigger | manual |
| Message Count | 42 |
| Project Dir | `/path/to/project` |
---
## Conversation
### User
What is the authentication flow in this project?
---
### Claude
The authentication flow consists of...
---{
"session_id": "abc123",
"timestamp": "20260205_143022",
"trigger": "manual",
"cwd": "/path/to/project",
"message_count": 42,
"messages": [
{"role": "user", "content": "..."},
{"role": "assistant", "content": "..."}
]
}The plugin works out of the box with sensible defaults. No configuration required.
- Project-level (default):
.claude/context-archives/in your project - Global fallback:
~/.claude/context-archives/if no project directory
- Keeps the most recent 50 archives per directory
- Older archives are automatically deleted
# 1. Make scripts executable
chmod +x claude-context-saver/scripts/*.sh
# 2. Start Claude Code with the plugin
claude --plugin-dir ./claude-context-saver
# 3. Have a conversation, then trigger compaction
/compact
# 4. Check the saved archive
cat .claude/context-archives/latest.md
# 5. Start a new session to see context injection
# (or wait for auto-compaction on long conversations)- Claude Code CLI
jqcommand-line JSON processor- Bash shell
MIT License - see LICENSE file.
Contributions welcome! Please open an issue or pull request on GitHub.