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

Qwen 3.6 27B with MTP on V100 32GB: 54 t/s via llama.cpp Branch
am17an's MTP branch of llama.cc runs Qwen 3.6 27B at 54 t/s on V100 32GB via PCIe adapter, dropping to 29-30 t/s without MTP.

WebClaw: Open-Source MCP Server for Web Extraction with Claude
WebClaw is an open-source MCP server built with Claude Code that provides web extraction tools for Claude Desktop and Claude Code, solving Claude's built-in web_fetch limitations with TLS fingerprinting and content optimization.

Be My Butler: Multi-Agent Pipeline for AI Code Verification
Be My Butler is an open-source multi-agent pipeline where different AI models review each other's code through blind verification. The system addresses the problem of AI agents incorrectly reporting their own code as functional.

TUI Studio: Visual Terminal UI Design Tool in Alpha
TUI Studio is a Figma-like visual editor for designing terminal user interfaces with drag-and-drop components, real-time ANSI preview, and planned export to six frameworks including Ink, BubbleTea, and Textual. Currently in alpha with non-functional exports, it's available for macOS, Windows, and Docker.