claude-auto-handoff
v1.0.0
Published
Prevent context loss during Claude Code compact. Saves conversation context before compact and restores it after.
Maintainers
Readme
claude-auto-handoff
Prevent context loss during Claude Code compact.
When Claude Code runs /compact or auto-compact, your conversation context gets compressed and important details can be lost. This tool saves the conversation state before compact and automatically restores it after, so Claude retains awareness of what you were working on.
Install
npx claude-auto-handoff installUninstall
npx claude-auto-handoff uninstallCheck Status
npx claude-auto-handoff statusHow It Works
[Compact triggered (auto or /compact)]
1. PreCompact hook → parses transcript → saves context to ~/.claude/autohandoff/
2. [Compact runs]
3. SessionStart hook → loads saved context → injects it back into ClaudeWhat Gets Saved (~4-8KB)
- First user message (original request)
- Last 3 user messages (300 chars each)
- Last 5 assistant responses (500 chars each)
- Last 10 tool calls (name + input summary)
- Session metadata (trigger type, working directory, compact count)
Test
After installing, run /compact in Claude Code, then ask:
"What was my last question?"
If Claude remembers, it's working.
Requirements
- macOS or Linux
- python3 (pre-installed on macOS)
- Claude Code with hooks support (PreCompact + SessionStart events)
How It's Safe
- All errors exit silently (
exit 0) — never blocks compact - Only reads transcript, never modifies it
- Auto-cleans old handoff files (keeps last 20)
- Zero external API calls, runs in <1 second
License
MIT
