agentleFS
syangasyanga/astack/skills/worktree-cleanup/SKILL.md

worktree-cleanup

Skill0 starsChanged 53 days agoMITView on GitHub

Worktree cleanup. Use for cleanup, resource audits, close this lane, or close out.

10 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 10 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Stop disposable resources before removing their worktrees:

    line 18
  2. Distinctive:

    Test databases: derive the exact target from test setup.

    line 23

“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “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

Worktree cleanup

First, check the lane's conversation, notes, and linked PRs for unfinished work or unrecorded follow-ups. For explicitly abandoned work, check the recorded disposition of remaining requirements. If anything needs handling or recording before closeout, report it and stop before auditing resources or making changes. Stop on missing completion or abandonment evidence too.

"Close this lane" means the current T3 thread unless specified otherwise. Resource questions are read-only.

For authorized cleanup, process queued retirements before the current lane's resources.

Inventory worktrees and associated resources, including leftovers outside deleted worktrees. Establish ownership from thread and launch records. Retain unknown targets and resources shared outside the cleanup scope. Retain active, pinned, or data-bearing targets whose disposal is undecided. Current-thread tools cannot establish other threads' inactivity.

For artifacts from orchestrate or multi-phase-plan, follow program closeout before removing their stores or workspaces. A worker lane's cleanup does not authorize disposal of its shared program store.

Stop disposable resources before removing their worktrees:

  • Processes: match PID, start time, and command. Account for supervisors and children.
  • Previews: use the cleanup record or original launch evidence. HTML-only previews have no processes. Stop preview quick tunnels before their servers. Preserve T3's access tunnel and retained deliverables.
  • Docker: verify the daemon and container ownership. Compose names can span worktrees. Inspect volume consumers, including stopped containers. Avoid global pruning.
  • Test databases: derive the exact target from test setup. Stop clients before scoped teardown. Preserve shared servers and data.

Remove only merged or explicitly abandoned worktrees. Check ignored and untracked files and post-squash commits. Review tracked files marked assume-unchanged or skip-worktree. Git status can hide their local edits. Retain detached commits through a branch. Keep main, locked, active, and open-PR worktrees. Preserve branch refs unless deletion was requested.

Recheck before git worktree remove. Force removal requires explicit disposal authorization for the affected files. Verify teardown before deleting recovery records.

Report removed, queued, and held targets separately, including owners, reasons, retired links, and failures.

After the lane's work and resource checks pass, durably queue any otherwise eligible current checkout for post-exit retirement. Then settle this T3 thread with t3_thread_organize without asking. Leave it active after an early stop, failure, or unresolved hold. Settlement closes execution. Queued resources remain until a later pass verifies removal.

Expand to simulators or caches only when requested. Editor backups may contain otherwise unrecorded work.

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.