编程

recover

试用

Scan for orphaned worktrees and stale branches after crashes or abandoned sessions. Offers safe cleanup options.

它能做什么

<!-- x-source: agent-workspace/SKILL.md @ 7b7211e -->

技能文档

/recover — Worktree & Branch Cleanup

Scan 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.

When to Use

  • After a system crash or forced session termination
  • When parallel session hooks warn about stale processes
  • When you find commits on unknown branches
  • Periodic hygiene (monthly or after heavy parallel work)

Instructions

0. Detect the default branch

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

1. List all worktrees

git worktree list --porcelain

Identify:

  • Recently touched worktrees: files or .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.
  • Candidate-orphaned worktrees: no recent modification and no activity signal — proceed to inspection, still gated on user approval before any cleanup
  • Stale entries: Git tracks a worktree but the directory is gone

2. Inspect orphaned worktrees

For each orphaned worktree:

git -C  status --short
git -C  branch --show-current
git -C  log --oneline -3
git log "$DEFAULT".. --oneline

Classify each as:

  • CLEAN: No unmerged commits, no uncommitted changes — safe to remove
  • HAS COMMITS: Unmerged commits exist — needs merge decision
  • HAS CHANGES: Uncommitted work — needs save decision
  • BOTH: Unmerged commits AND uncommitted changes — needs careful handling

3. List stale branches

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:

  • MERGED: Already in the default branch — safe to delete
  • STALE: Last commit >7 days ago, not merged — flag for review
  • ACTIVE: Recent commits — leave alone

4. Check for prunable git state

git worktree prune --dry-run

5. Report

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]

6. Cleanup (with approval only)

Only proceed when explicitly approved. Options:

  • Remove orphaned worktree (CLEAN): git worktree remove
  • Merge unmerged commits: git merge --no-ff
  • Cherry-pick specific commits: git cherry-pick
  • Delete merged branches: git branch -d
  • Delete stale branches (confirmed discard): git branch -D
  • Prune stale entries: git worktree prune
  • Prune remote refs: git remote prune origin

Design Principles

  • Read-only by default. Report, wait for approval.
  • Preserve work. Default to merge/cherry-pick over discard.
  • Specific. Show exact commit hashes, file lists, branch names.
  • Fast. Git commands only. Under 15 seconds for scan.

相关技能

执行 Git 操作(提交、分支、合并、变基、冲突解决与恢复)时强制套用安全规则。

作者 Iván535 次安装31 星标

诊断生产力系统反复失效的根因,给出最小干预——容量测算、瓶颈定位、可靠的本地记录。

作者 Iván855 次安装69 星标

在本地磁盘以分类纯 Markdown 文件保存需要长期留存的事实,与智能体内置记忆并存。

作者 Iván559 次安装18 星标

把自然语言描述转为结构化 JSON,并由 mcp-diagram-generator MCP 服务生成 Draw.io、Mermaid 或 Excalidraw 图表文件。

作者 nssa.io1.0k 次安装47 星标

以 AI 机器人身份加入视频会议,提供语音、虚拟形象与屏幕共享四种模式。

作者 johnpatternai22 次安装8 星标

conorbronsdon 的更多技能

浏览全部技能

审计并改写文本,去除其中的 AI 生成写作痕迹。

作者 conorbronsdon69 次安装

Pre-investment research and deal-memo generation for angel investors. Use when asked to "diligence [company]", "research this startup for an investment", "build a deal memo", or to prep for a founder call. Runs parallel web research with strict citation rules and produces a nine-section memo that separates verified facts from claims. Never outputs an invest/pass recommendation.

作者 conorbronsdon1 次安装

Multi-agent deep review for code PRs in any repo. Use when asked to "deep review this PR," "multi-agent review," "review

作者 conorbronsdon2 次安装

Audit an LLM evaluation or benchmark repo for integrity and credibility practices. Use when asked to "audit my benchmark," "is my eval trustworthy," "check my leaderboard for contamination," "review this benchmark's methodology," or "what would a reviewer attack in my eval." Greps the target repo for evidence across seven dimensions (pre-registration, contamination, holdout hygiene, judge validity, statistical honesty, reproducibility, leaderboard exclusions) and emits a scored report with file:line evidence, severity, and concrete fixes.

作者 conorbronsdon1 次安装

Researches and maps a guest’s podcast appearance history to identify their last topics, unclaimed angles, and receptiveness for targeted outreach.

作者 conorbronsdon1 次安装

Structured session lifecycle for Claude Code — start, checkpoint, end, and daily heartbeat commands that maintain project state across conversations.

作者 conorbronsdon1 次安装