recover

recover is a command for Claude Code from conorbronsdon/agent-context-os. It costs 19 tokens per session (1,298 once invoked), scanned A, original, MIT.

A read-only command that scans a Git repository for abandoned worktrees, stale branches, and unfinished work from interrupted agent sessions.

In plain words
What is it for?
Use it after a crash, forced session termination, warnings about stale processes, reconciliation checks, or periodic Git maintenance.
Why use it?
It helps identify leftover repository state after crashes or parallel work while requiring approval before cleanup.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/conorbronsdon/agent-context-os/recover
Clone the repo
git clone --depth 1 https://github.com/conorbronsdon/agent-context-os

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for recover

README.md
[![agentmods](https://agentmods.dev/badge/commands/conorbronsdon/agent-context-os/recover.svg)](https://agentmods.dev/commands/conorbronsdon/agent-context-os/recover)
Your own site
<a href="https://agentmods.dev/commands/conorbronsdon/agent-context-os/recover"><img src="https://agentmods.dev/badge/commands/conorbronsdon/agent-context-os/recover.svg" alt="Measured on agentmods" height="20"></a>
Per session 19 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,298 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00019 $0.01298
Opus 5 $0.00010 $0.00649
Sonnet 5 $0.00004 $0.00260
Haiku 4.5 $0.00002 $0.00130

Measured today against content hash 4c80a012cc1b, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

recover scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/commands/recover.md · 132 lines

How it starts

The opening of the file, as written. The whole thing — 132 lines — stays where its author put it; the contents beside it link to each section on GitHub.

/recover — Worktree & Branch Cleanup

Scan for orphaned worktrees, stale branches, and partial work left behind by crashed or abandoned agent sessions. Read-only by default — reports findings and waits for approval before any cleanup.

Invocation: explicitly user-invoked. Scanning is read-only, but the workflow can lead to destructive cleanup; every cleanup action remains separately gated on explicit user approval.

Configuration

This core operates on git worktrees and branches only; it reads no state files, so tracked workspace path configuration does not apply. The one setting it depends on is the default branch, which it detects (step 0) rather than hardcoding.

When to Use

  • After a system crash or forced session termination
  • When parallel-session hooks warn about stale processes
  • When /reconcile finds 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:

git rev-parse --git-dir >/dev/null 2>&1 || { echo "not a git repository — nothing to recover"; exit 0; }
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.

Read the full file on GitHub · 132 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed 4c80a012cc1b
  2. 5d ago First seen · 132 lines · 19 tokens per session scan A b5a842065aa8

Subscribe to this mod's changes

recover is a command published in the GitHub repository conorbronsdon/agent-context-os (22 stars, last pushed yesterday), licensed MIT. It adds 19 tokens to every session and 1,298 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.