Session handoff
Skill davidshaevel-dot-com/davidshaevel-marketplace/skills/session-handoff
Use at the start and end of every coding session, or when switching between Claude Code and Cursor, to maintain cross-agent memory persistence via SESSION_LOG.mdFrom its SKILL.md
npx -y skills add davidshaevel-dot-com/davidshaevel-marketplace --skill session-handoffAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
8.9 KB, as published. Nobody here has run it
Session Handoff
Read and write SESSION_LOG.md for cross-agent memory persistence. Enables seamless switching between Claude Code and Cursor sessions.
Usage
This skill is used automatically:
- Session start: Read SESSION_LOG.md to restore context
- Session end: Update SESSION_LOG.md to preserve context for the next session
Process
At Session Start
Standard repos (no worktrees)
- Check if
SESSION_LOG.mdexists in the project root - If it exists, read the Current State section
- Summarize the context for continuity:
- What was the last agent and session?
- What branch are we on?
- What work is active?
- Are there any blockers?
- What are the next steps?
Bare + worktree repos
- Check if
.bare/directory exists at cwd — if so, this is a bare+worktree repo - Run
git worktree listto discover all worktrees - Use built-in Grep to find all SESSION_LOG.md files and extract active work in a single call:
Do NOT use bashGrep pattern="Active work:" glob="**/SESSION_LOG.md" output_mode="content"forloops, shellgrep,find, or piped commands to scan worktrees — these complex commands can't be pattern-matched by the command allowlist and cause repeated approval prompts every session. Always prefer built-in tools (Grep, Glob, Read) over bash equivalents for file scanning. - Based on how many SESSION_LOG.md files are found:
- Zero found: This is a fresh start, no context to restore
- One found: Read it automatically and confirm with the user
- Multiple found: Show a summary of each (worktree name, branch, active work from the Grep results) and ask the user which worktree to resume in
- Read the selected worktree's SESSION_LOG.md and summarize as usual
At Session End
Standard repos (no worktrees)
-
Overwrite the "Current State" section with current information
-
Prepend a new entry to the "Session History" section
-
Trim Session History to the last 30 sessions (remove oldest entries beyond 30)
-
Back up local config — Run the backup script to sync gitignored files to Google Drive:
"${CLAUDE_PLUGIN_ROOT}/scripts/backup-local-config.sh" /path/to/repoReplace
/path/to/repowith the project root. If the backup fails, log the error but do not block the session handoff.Exit 2 is not a failure. It means
PARTIAL: the transfer worked, but something about the configuration is wrong — an unsupported entry, an entry that never resolved, a stale config location, or a config that resolved zero entries. Report theWARNING:lines and name the offending entry. Exit 1 means either a copy failed or a pre-flight check did (no config found, rclone missing, not a git repo) — read theError:line before concluding which.
Bare + worktree repos
-
Determine which worktree the session worked in by checking the branch used throughout the conversation
-
Map that branch to its worktree directory (via
git worktree list) -
Write SESSION_LOG.md only to that worktree's directory
-
Never update another worktree's SESSION_LOG.md
-
Back up local config — Run the backup script to sync gitignored files to Google Drive:
"${CLAUDE_PLUGIN_ROOT}/scripts/backup-local-config.sh" /path/to/repo-rootReplace
/path/to/repo-rootwith the bare repo root (the directory containing.bare/). This backs up files from all worktrees in a single call. If the backup fails, log the error but do not block the session handoff.Exit 2 is not a failure — see the note above. Report the
WARNING:lines.
Worktree Cleanup (Merging Session History)
When a feature worktree is being removed after a PR merge, the worktree's session history must be merged into main's SESSION_LOG.md — never copied with cp.
Merge process:
- Read
main/SESSION_LOG.mdSession History entries - Read
<worktree>/SESSION_LOG.mdSession History entries - Interleave both sets of entries by timestamp (newest first)
- Update main's Current State to reflect the post-merge project state (e.g., mark the completed work as done, update next steps)
- Write the merged result to
main/SESSION_LOG.md - Trim Session History to the last 30 entries
Important: Do NOT use cp <worktree>/SESSION_LOG.md main/SESSION_LOG.md — this destroys session history from other worktrees that was previously merged into main.
Worktree Cleanup (Merging .envrc)
When a feature worktree is being removed after a PR merge, the worktree's .envrc must be merged into main's .envrc — never copied with cp.
.envrc is a flat key=value shell file. Compare line by line.
Merge process:
- Read
main/.envrc - Read
<worktree>/.envrc - Compare line by line:
- If only one version has a real value (the other has a placeholder or is empty), keep the real value
- If both have the same value, keep it as-is
- If values differ and one is clearly more recent or complete, keep the more complete/recent value
- If values differ and neither is clearly "better", keep main's value and add a comment flagging the conflict:
# MERGE CONFLICT: worktree had "<worktree value>"
- If the worktree version has variables that main does not, append them
- Write the merged result to
main/.envrc
Important: Do NOT use cp <worktree>/.envrc main/.envrc — main's copy may contain updates made independently while the feature worktree was active.
Worktree Cleanup (Merging CLAUDE.local.md)
When a feature worktree is being removed after a PR merge, the worktree's CLAUDE.local.md must be merged into main's CLAUDE.local.md — never copied with cp.
CLAUDE.local.md is a structured markdown document with tables and sections. Unlike SESSION_LOG.md, it is not chronological — it requires section-by-section comparison.
Merge process:
- Read
main/CLAUDE.local.md - Read
<worktree>/CLAUDE.local.md - Compare section by section (e.g., "Cloud Account Details", "Infrastructure Details", "Cost Summary")
- For each section:
- If only one version has content (the other has placeholders like
[account ID or name]or...), keep the version with real content - If both have the same value, keep it as-is
- If values differ and one is clearly more recent or complete (e.g., an updated cost figure, a filled-in URL replacing a placeholder), keep the more complete/recent value
- If values differ and neither is clearly "better", keep main's value and add a comment flagging the conflict:
<!-- MERGE CONFLICT: worktree had "value" -->
- If only one version has content (the other has placeholders like
- Write the merged result to
main/CLAUDE.local.md
Important: Do NOT use cp <worktree>/CLAUDE.local.md main/CLAUDE.local.md — main's copy may contain updates made independently while the feature worktree was active.
SESSION_LOG.md Format
# Session Log
## Current State
- Agent: [Claude Code | Cursor]
- Branch: [current branch]
- Last session: [YYYY-MM-DD HH:MM]
- Active work: [issue ID and description]
- Blockers: [list or "None"]
- Next steps: [bullet list]
## Session History
### YYYY-MM-DD HH:MM — [Agent Name]
**What was done:**
- [bullet list]
**Decisions made:**
- [bullet list]
**Open questions:**
- [list or "None"]
Rules
- Keep entries concise — bullet points, not paragraphs
- Focus on decisions and blockers, not play-by-play
- The "Current State" section should be enough to resume work without reading history
- Session History provides deeper context if needed
- Always update SESSION_LOG.md before ending a session, even if work was minor
- Timestamps are required — both
Last session:in Current State and every session history heading MUST includeHH:MM(24-hour local time), not just the date. Rundate +"%Y-%m-%d %H:%M"to get the current timestamp. This is critical for accurate ordering when multiple agents work in parallel.
Worktree Rules
- One worktree, one SESSION_LOG.md — each worktree maintains its own independent session log. Never read or write another worktree's SESSION_LOG.md.
- Branch determines the target — at session end, the branch you worked on determines which worktree's SESSION_LOG.md to update. If you're unsure, ask the user.
- Bare repo root has no SESSION_LOG.md — in bare+worktree repos, SESSION_LOG.md lives inside worktree directories (e.g.,
main/SESSION_LOG.md,tt-154.../SESSION_LOG.md), never at the bare repo root. - Merge, never copy — during worktree cleanup, merge all gitignored files into main:
.envrc(line-by-line),CLAUDE.local.md(section-by-section), andSESSION_LOG.md(interleave by timestamp). Never usecpto overwrite. - When in doubt, ask — if you cannot determine which worktree the session belongs to, ask the user rather than guessing.