Automated Session State Management for Claude Code Handoff

Automated Context Preservation for Claude Sessions
A Reddit user has shared a solution for managing context degradation in Claude conversations, particularly addressing issues with autocompact and mid-conversation context loss as conversation windows grow large. The system automatically maintains a live state file throughout sessions without manual intervention.
How It Works
The solution expands on manual handoff commands by incorporating additional hooks:
- A
UserPromptSubmithook fires on every message sent, injecting a directive into Claude's system context that says "check if anything important happened, and if so, update session-state.md" - A
PostToolUsehook tracks which files Claude edits - When
session-state.mdgets too long, the directive automatically switches to "rewrite mode" telling Claude to keep only critical information - Before autocompaction, a
PreCompacthook forces a full state dump so nothing is lost - On session start, the previous session's state is loaded back in
Implementation Details
The automated system consists of approximately 4 shell scripts with no dependencies beyond bash and jq. Installation options include:
- Install as a git submodule
- Copy the hooks into
.claude/hooks/directory
The system maintains a live state file at .claude/session-state.md throughout the session. It also includes a manual /handoff command for deliberate checkpoints, useful for task tracking, bug investigations, and recovery from degraded context.
This type of tool is useful for developers working on complex, multi-session projects with Claude where maintaining context across conversations is critical for continuity and avoiding repetition.
📖 Read the full source: r/ClaudeAI
👀 See Also

Tilde.run: An Agent Sandbox with a Transactional, Versioned Filesystem
Tilde.run provides isolated, reversible sandboxes for AI agents, with a versioned filesystem that mounts GitHub, S3, and Google Drive, and network isolation by default.

Paseo: Open-Source Interface for Claude Code, Codex, Copilot, OpenCode, and Pi Agents
Paseo is a self-hosted interface that runs Claude Code, Codex, Copilot, OpenCode, and Pi agents in parallel. It offers voice control, cross-device access, and a CLI. No telemetry, no forced login.
MTP + Unified Memory Boosts llama.cpp Inference 30% on RTX 5090
Enabling MTP speculation alongside GGML_CUDA_ENABLE_UNIFIED_MEMORY=1 pushes Qwen3.6-27B Q8_0 from 49 to 64 tok/sec on an RTX 5090 with 128GB system RAM.

Claude-Code v2.1.111 adds Opus 4.7 xhigh effort, /ultrareview, and PowerShell tool
Claude-Code v2.1.111 introduces the Opus 4.7 xhigh effort level between high and max, adds the /ultrareview command for cloud-based multi-agent code reviews, and begins rolling out PowerShell tool support on Windows. The update also includes interactive /effort controls, auto theme matching, and numerous bug fixes.