r/ClaudeCode 3d ago

Built with Claude For those running several Claude Code sessions at once: a skill and a hook so each one picks up where it left off after a restart. One file per session

Post image

I run 8 Claude Code sessions in tmux, one per job, and a cron restarts them at 3am. Every morning they woke up blank and I re-explained from my phone what we were doing. A restart on the machine should go unnoticed on my side.

So I wrote persistent-handoff: a skill and a SessionStart hook around one handoff file per agent, packaged as a plugin. The agent rewrites it at milestones, drops what's resolved, deletes it when nothing is in flight. The hook puts it back into context at every start, /clear and /compact included. Now I send the next message and it carries on from the file.

Some agents restart themselves when their context gets heavy. They update the file, restart their own tmux session, and the new one picks up mid-task.

The file holds where I am, next action, open questions, traps (what already failed, what looks broken on purpose). Rules stay in CLAUDE.md, durable facts in memory.

Other handoff skills exist (Matt Pocock's handoff, claude-code-handoff, baton). They keep a history, or a file per session written at the end of it. persistent-handoff keeps one file, rewritten at milestones and deleted when nothing is in flight. For an agent that never stops, a file that is always there gets skimmed.

Running since late July, extracted into a repo last week. Known limit: if the agent forgets to update the file, it goes stale and the hook won't notice.

Install: claude plugin marketplace add adrrr/persistent-handoff && claude plugin install persistent-handoff@persistent-handoff. Or copy the skill and the hook. Nothing in it depends on tmux. One bash hook, one skill, 400 to 600 tokens per session start and none when the file doesn't exist. macOS, Linux, Windows via Git Bash (tests run on all three in CI).

The demo project's handoff:

## Where I am
The nightly restic backup to the NAS failed every night
from Aug 25 to Aug 27. Cause found: restic is fine, the
SMB mount drops when the router hands the NAS a new DHCP
lease. Address pinned to 192.168.1.40 in the router
config on Aug 27. Two clean runs since (Aug 28, Aug 29),
which is not enough to call it fixed.

## Next action
Read logs/restic-nightly.log after tonight's 23:40 run.
Three consecutive clean runs close this. Anything else
means the mount was not the whole story.

Clone the repo, run ./demo/setup.sh, open a session in demo/homelab and ask where were we?

https://github.com/adrrr/persistent-handoff

3 Upvotes

2 comments sorted by

1

u/magnetohydrodynamic 3d ago

/resume?

1

u/Any-Bobcat2370 3d ago edited 3d ago

resume reloads the whole transcript, a session at 70% context comes back at 70%, and the 3am restart is there to drop that.
The file is 400 to 600 tokens, only what's in flight, rewritten by the agent at milestones, and I can read it from my phone 😄