/git-sweep:auto-sweep [--dry-run] [--base <branch>]from git-sweep
Cleans leftover local branches and agent worktrees without prompting. Deletes branches already in the base, removes clean agent worktrees, and archives abandoned agent branches. Use after landing a branch or when worktrees pile up.
Ships in git-sweep. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
The script decides everything: which base to judge against, which branch is proven, which agent branch is abandoned. Run it, then relay its summary.
"${CLAUDE_PLUGIN_ROOT}/scripts/auto-sweep.ts" $ARGUMENTS
One plain command, nothing appended. It works from any checkout of the repository; the checkout it runs in is current, so its branch and worktree stay.
--dry-run prints the same summary and changes nothing. Use it when the
user asks what a sweep would do.--base <branch> names the base. Without it the script takes sweep.base,
then dev or develop, then origin/HEAD, then main, master or trunk.Exit 0 means every operation went through; 1 means the audit failed (reason
on stderr) or an operation failed (listed under Failed); 2 means a bad
argument.
Relay the summary in a few lines: how many branches were deleted, which agent
worktrees were removed, and every archived branch with its restore command,
git branch <name> refs/archive/<name>. Name the kept branches only when the
user asks, or when one looks like work the user is waiting on.
The sweep tidies more than it frees: most disk space sits in named worktrees,
which it leaves. When the summary ends with a count of clean worktrees on work
the base already holds, say so and name /git-sweep as the way to remove them.
It runs on the current repository only; for several, run it once in each.
Leave what the script kept as it is: do not delete, unlock or prune by hand.
An unproven branch that is not an agent's, a worktree outside
.claude/worktrees/agent-*, a backup branch and every remote branch are the
interactive /git-sweep's to judge, with the user.
| Case | Outcome |
|---|---|
| Branch proven in the base (ancestry, no merge delta, merged PR) | deleted |
Clean agent worktree on a proven branch, its ignored paths all regenerated (node_modules/, a plugin's tsconfig.json…) or symbolic links | removed, branch deleted, link targets left |
| Detached worktree, an agent's included | kept, listed under its path with its state (clean, HEAD in <base>, its changes, or a HEAD the base lacks) |
| Agent worktree whose directory is gone | registration dropped |
| Unproven agent branch, PR closed unmerged and last commit both 14+ days old | archived, then deleted with its clean worktree |
| Unproven agent branch, no PR, last commit 30+ days old | archived, then deleted with its clean worktree |
Base, protected, current, locked, dirty, or holding any other ignored path that is not a symbolic link (a plans/ directory) | kept, the path named |
Named worktree .claude/worktrees/<name>, or any outside .claude/worktrees/agent-* | not swept |
| Agent branch whose agent still runs (its worktree is locked) | kept |
| Remote branches and tracking refs | never deleted |
An agent branch is one named with sweep.agentPrefix (default
worktree-agent-) or checked out only in an agent worktree.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub bengous/claude-code-plugins --plugin git-sweep2 skills in this plugin
Other plugins' skills for the same job