agentleFS
tenforward-audiotenforward-audio/swe-harness/.agents/skills/clean-up-worktree/SKILL.md

clean-up-worktree

Skill0 starsChanged 3 months agoMITView on GitHub

Safely remove an explicitly named local Git worktree and optionally its local branch after the user authorises cleanup of an integrated or handed-off candidate, or deliberately abandons planning or research. Use only after material work and evidence are preserved. Do not use for integration, inferred lifecycle transitions, remote branch deletion, canonical-checkout removal, or forced loss of unreviewed work or user data.

The file

We split this skill into the rules it gives an agent

8 rules. About 0 are common, 7 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the root AGENTS.md, the contributing guide, and the canonical workflow.

    line 14
  2. Distinctive:

    If no finding merits retention, say so explicitly rather than creating noise.

    line 62
  3. Very specific:

    When a tracked card exists, use manage-project-work for the separately named close, reject, accept, or return transition.

    line 63
  4. Distinctive:

    Stop and report the exact blocker if any identity, preservation, or authority check fails.

    line 68
  5. Distinctive:

    Remove the exact worktree through Git without a force flag, then verify that its registration and path are gone.

    line 73
  6. Distinctive:

    Delete only the explicitly authorised local branch.

    line 75
  7. Distinctive:

    Do not run broad pruning or delete another stale worktree as a side effect.

    line 81
  8. Distinctive:

    Leave every remote ref untouched.

    line 82

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Clean Up a Worktree

Execution mode

inline

Confirm the exact local cleanup

  1. Read the root AGENTS.md, the contributing guide, and the canonical workflow. Read the research archive for an abandoned planning or research workspace.
  2. Require an explicit user request or an unambiguous agreement to a cleanup offer that names the local worktree and branch. Classify the outcome as:
    • an accepted reviewed candidate whose integration or handoff is complete, or untracked work the user explicitly declared complete; or
    • planning or research the user deliberately chose to abandon.
  3. Resolve the exact worktree path, attached branch, current commit, coordinating checkout, common base when relevant, and any associated card or review evidence. Never select a target from a guessed path, wildcard, or stale lane name.
  4. State every proposed effect before acting. One confirmation may authorise a named lifecycle change, findings record, worktree removal, and local branch deletion only when each effect is listed explicitly.

Local cleanup authority never includes push, remote branch deletion, tag, release, history rewriting, or deletion of durable review evidence. Do not offer cleanup merely because review or acceptance completed; acceptance or an explicit completion decision and the integration, handoff, or deliberate abandonment must all be established.

Prove that removal will not lose work

  • Refuse to remove the coordinating or canonical checkout. Confirm the target appears exactly once in Git's worktree inventory and that the named branch is checked out only there.
  • Inspect tracked, untracked, and ignored content. Do not use forced worktree removal to bypass dirtiness, a lock, nested repository state, unreadable files, or uncertainty about user data.
  • For an integrated candidate, verify that the branch still identifies the reviewed commit, the user accepted or explicitly declared the work complete, the recorded integration result contains the reviewed scope, and no later or unique work exists. Use ancestry for merge or fast-forward integration; for squash or cherry-pick, use the recorded commit mapping and patch comparison rather than pretending ancestry proves equivalence.
  • For completed handoff, verify the recipient preserves the exact pinned candidate under a durable reference independent of the local branch and that the returned evidence no longer depends on the local worktree.
  • For deliberate abandonment, inspect every commit and local change since the common base. Summarise what would be discarded and stop unless the user's authority clearly covers it.
  • Preserve material abandoned findings in the narrowest durable Markdown owner in the coordinating checkout. Use project documentation for current claims, an ADR for a consequential durable decision, or ../../RESEARCH.md for a useful negative or exploratory result. Checkpoint that record before cleanup. If no finding merits retention, say so explicitly rather than creating noise.
  • When a tracked card exists, use manage-project-work for the separately named close, reject, accept, or return transition. Cleanup authority alone does not alter queues or boards.

Stop and report the exact blocker if any identity, preservation, or authority check fails. Never delete first and investigate afterwards.

Remove in recoverable order

  1. Remove the exact worktree through Git without a force flag, then verify that its registration and path are gone.
  2. Delete only the explicitly authorised local branch. Prefer normal deletion when Git recognises it as merged. Force-delete it only when the completed preflight proves a squash or cherry-pick integration, proves a completed handoff retains the exact commit under an independent durable reference, or proves deliberate abandonment with all material findings and work preserved, and the user explicitly authorised that branch's deletion.
  3. Do not run broad pruning or delete another stale worktree as a side effect. Leave every remote ref untouched.
  4. Report the findings record or evidence retained, the exact local worktree and branch removed, any partial failure, and that remote branches were not changed. State whether recovery still depends on a recorded commit or reflog.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.