Skip to content
Back to skills

Remove Archived Worktrees

BSecurity

Removing archived sessions' `.claude/worktrees/` checkouts, which archiving leaves on disk. Use when the disk is low or full, or when asked to clean up worktrees or what archived sessions left behind.

  • 80 stars
  • 0 votes
  • 0 copies
  • 4 views
  • Added November 30, 2026
datagogit

Security analysis

B85/100
  • highPerforms destructive filesystem operations

Pro shows the line behind each finding and how to fix it

Scanned November 30, 2026

npx -y skills add bikeindex/bikebook --skill remove-archived-worktrees --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Remove Archived Worktrees?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Remove Archived Worktrees
[![Security: B — Skills Directory](https://www.skillsdirectory.com/api/skills/bikeindex-remove-archived-worktrees/badge)](https://www.skillsdirectory.com/skills/bikeindex-remove-archived-worktrees)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: remove-archived-worktrees
description: >-
  Removing archived sessions' `.claude/worktrees/` checkouts, which archiving leaves on
  disk. Use when the disk is low or full, or when asked to clean up worktrees or what
  archived sessions left behind.
---

# Removing archived sessions' worktrees

**Who runs this:** from a session with history, one `general-purpose` `Agent` with `model: "haiku"`, since the steps are fixed and `prune_worktrees` holds the checks; relay its report. One session already known to be archived is just step 3's command, run in the session.

1. **List them:** `ls "$(git worktree list --porcelain | sed -n '1s/^worktree //p')/.claude/worktrees" | grep '^bridge-cse_'`. `bridge-cse_<id>` belongs to `session_<id>`.
2. **`get_session` each, all in one turn.** Only a `session_status` of `SESSION_STATUS_ARCHIVED` goes on. Never judge by age, a quiet transcript or no running process: an idle session resumes into its worktree. A lock says nothing either way, since `claude remote-control` holds it past the archive.
3. **Remove them all in one call**: `prune_worktrees session_<id>...`, naming only the archived ids. It carries on past a refusal and works from any checkout.
4. **Report** the space freed (`df -h /System/Volumes/Data` before and after) and each one kept:

   | it refuses because | do |
   |---|---|
   | a process is running in it | a Claude session still exiting: the next sweep gets it |
   | a marker names it as taken over | leave it: the session that took it over removes it |
   | it has uncommitted changes, or commits no branch or remote holds | ask the user, naming the session's title and what's there |

Any other name under `.claude/worktrees/` (`agent-*`, `review-*`, a hand-named one) has no session to ask. List those with their sizes for the user; the session that added one removes it, with `git worktree remove <path>`.

A refusal is the answer: no `--force`, no `git worktree unlock` and no `rm -rf` to get past one.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in data →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.