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

Hearth: Self-Hosted Multi-User AI Chat App for Households on OpenClaw
Hearth is a self-hosted household AI chat app built on OpenClaw that provides separate accounts and conversations for each family member, with features including PIN/biometric login, private chats, reminders, and model presets.

Claude Code's Plan-Skeptic Sub Agent Identifies Security Gaps in Generated Plans
A developer discovered Claude Code's plan-skeptic sub agent, which identifies gaps and issues in AI-generated development plans, particularly catching security concerns that weren't initially obvious. The agent works alongside the previously known security-sheriff sub agent to improve plan quality.

Claude Dispatch Beta: Setup Tips and Initial Impressions
A developer shares their experience setting up Claude's Dispatch beta on a Mac Mini, highlighting the need for constant uptime, specific success criteria, and aggressive permissions with Computer Use enabled.

Brand-Docs: Open-Source Tool for Claude to Generate DOCX, PPTX, XLSX from Templates
A Reddit user open-sourced Brand-Docs, a solution for Claude to generate Office documents (DOCX, PPTX, XLSX) that faithfully preserve company brand templates — layout, styles, images — without recreation.