Install
openclaw skills install @conorbronsdon/recoverScan for orphaned worktrees and stale branches after crashes or abandoned sessions. Offers safe cleanup options.
openclaw skills install @conorbronsdon/recoverScan for orphaned worktrees, stale branches, and partial work left behind by crashed or abandoned Claude Code sessions. Read-only by default — reports findings and waits for approval before cleanup.
Invocation: deliberately model-invocable — scanning is read-only. Every cleanup action is gated on explicit user approval.
Don't assume main. Resolve it once and use it everywhere below:
DEFAULT=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|^origin/||')
DEFAULT=${DEFAULT:-$(git remote show origin 2>/dev/null | sed -n 's/.*HEAD branch: //p')}
DEFAULT=${DEFAULT:-main} # no remote at all — fall back and note it in the report
git worktree list --porcelain
Identify:
.git metadata modified in the last hours — treat as possibly live. git worktree list cannot tell whether a session is actually running; without a lock/heartbeat file or process evidence, classify as unknown activity and never as orphaned.For each orphaned worktree:
git -C <worktree-path> status --short
git -C <worktree-path> branch --show-current
git -C <worktree-path> log --oneline -3
git log "$DEFAULT"..<branch-name> --oneline
Classify each as:
git branch --no-merged "$DEFAULT"
git remote prune origin --dry-run
git for-each-ref --sort=-committerdate --format='%(refname:short) %(committerdate:relative) %(subject)' refs/heads/
Classify:
git worktree prune --dry-run
RECOVER — [DATE]
WORKTREES:
- Active: [N]
- Orphaned: [N]
- [path] — [status] — [branch] — [last commit]
- Stale entries: [N]
BRANCHES:
- Merged (safe to delete): [list]
- Stale (>7 days, not merged): [list]
- Active: [list]
PROPOSED ACTIONS:
1. [action] — [target] — [reason]
OVERALL: [CLEAN / N items need attention]
Only proceed when explicitly approved. Options:
git worktree remove <path>git merge <branch> --no-ffgit cherry-pick <hash>git branch -d <branch>git branch -D <branch>git worktree prunegit remote prune origin