feat: add session-persist plugin for client-side session state preservation#55864
feat: add session-persist plugin for client-side session state preservation#55864SanskaarUndale21 wants to merge 2 commits intoanthropics:mainfrom
Conversation
…vation Introduces the session-persist plugin to address the session lifecycle problem described in anthropics#55860. When the window closes mid-task, all working context is lost. This plugin provides a client-side stopgap while server-side session persistence is built out. What the plugin adds: - SessionStart hook: generates a unique session ID on every run and exports it as CLAUDE_PERSIST_SESSION_ID. If .claude/.session-resume exists it reads the named session file and injects the saved context as additionalContext, then deletes the resume trigger file. - SessionEnd hook: stamps ended_at on any session file that was explicitly saved during the session. - /session-save command: asks the assistant to summarise the current task and writes the result to .claude/sessions/<session-id>.json. - /session-list command: lists all saved sessions with timestamps and last-task previews. - /session-resume <id> command: reads a saved session file and injects its context into the current conversation so work can continue without reconstructing state from scratch. Sessions are stored as plain JSON in .claude/sessions/ and are gitignore-able. The auto-resume path (.claude/.session-resume) lets users wire up an IDE keybinding or shell alias to checkpoint-and-resume in one step. Closes anthropics#55860 (partial — client-side only; server-side agent loop persistence requires platform changes)
|
i will run test now |
There was a problem hiding this comment.
Pull request overview
This PR adds a new session-persist marketplace plugin intended as a client-side stopgap for preserving task context across Claude Code sessions until the server-side persistence work from issue #55860 exists.
Changes:
- Adds
session-persisthooks to assign a per-session ID on start and stamp saved sessions on end. - Adds
/session-save,/session-list, and/session-resumecommands plus README/plugin metadata. - Registers the new plugin in the marketplace catalog.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
plugins/session-persist/hooks/session-start.sh |
Initializes session IDs and handles auto-resume context injection on session start. |
plugins/session-persist/hooks/session-end.sh |
Updates saved session files with ended_at when a session closes. |
plugins/session-persist/hooks/hooks.json |
Wires the plugin’s SessionStart and SessionEnd hooks. |
plugins/session-persist/commands/session-save.md |
Defines the save/checkpoint command workflow and output format. |
plugins/session-persist/commands/session-resume.md |
Defines manual session restore behavior from saved JSON files. |
plugins/session-persist/commands/session-list.md |
Lists saved sessions and displays summary metadata. |
plugins/session-persist/README.md |
Documents plugin purpose, workflow, commands, and session file format. |
plugins/session-persist/.claude-plugin/plugin.json |
Adds plugin manifest metadata for distribution/loading. |
.claude-plugin/marketplace.json |
Registers session-persist in the marketplace index. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Ran the full test plan locally against the plugin scripts. All 5 checks pass: Test 1 — SessionStart sets Test 2 — Test 3 — Test 4 — Test 5 — auto-resume via Platform note: on Windows, |
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Problem
Closing the window mid-task wipes all working context. The next session starts blank and the user has to reconstruct what was being worked on from memory.
Issue #55860 proposes a full server-side fix (agent loop running independently of the window). This PR is a client-side stopgap that can ship now while the deeper platform work is designed.
What this adds
A new
session-persistplugin with two hooks and three commands.Hooks (automatic)
SessionStartSESSION_ID, exports it asCLAUDE_PERSIST_SESSION_ID. If.claude/.session-resumeexists, reads that session file and injects saved context asadditionalContext, then removes the trigger file.SessionEndended_aton any session file that was explicitly saved during the session.Commands (on demand)
/session-save.claude/sessions/<id>.json/session-list/session-resume <id>Auto-resume
Write a session ID to
.claude/.session-resumeand the next session start picks it up automatically — no command needed.Session file format
Sessions are stored as plain JSON in
.claude/sessions/(safe to gitignore):Limitations
This addresses context loss only. The agent loop is still window-bound — tool calls in flight when the window closes are still interrupted. Full server-side persistence (#55860) requires platform changes; this plugin is a reference for the client-side patterns that work will build on.
Files changed
plugins/session-persist/— new plugin (hooks, commands, README, manifest).claude-plugin/marketplace.json— registers the new pluginTest plan
CLAUDE_PERSIST_SESSION_IDis set in hooks/session-save— verify.claude/sessions/<id>.jsonis written with correct fields/session-list— verify saved sessions are listed with timestamps/session-resume <id>— verify context is injected and assistant resumes correctly.claude/.session-resume, start a new session — verify auto-resume fires and the trigger file is deletedended_atis stamped on the session file