Skip to content
Agentmart
Submit a tool

prune-merged-branches

Delete the local git branches that are merged, and remove their worktrees.

Skill by seanogdev

IndexedMIT
Write a review

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/seanogdev-prune-merged-branches

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Delete the local git branches that are merged, and remove their worktrees. A branch counts as merged into its own PR base, or into the fallback base. Local only. It never changes the remote.

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found
Runs as
Node.js package

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/prune-merged-branches

Tools it pre-approves 10

From allowed-tools in SKILL.md: the agent may use these without asking you each time.

  • Bash(node
  • *prune-merged-branches/scripts/prune.ts*),
  • Bash(git
  • worktree
  • list*),
  • branch*),
  • log*),
  • Bash(gh
  • pr
  • view*)

What's inside

Skill name
prune-merged-branches
Description
Delete the local git branches that are merged, and remove their worktrees. A branch counts as merged into its own PR base, or into the fallback base. Local only. It never changes the remote.
License
MIT
Allowed tools
Bash(node, *prune-merged-branches/scripts/prune.ts*),, Bash(git, worktree, list*),, Bash(git, branch*),, Bash(git, log*),, Bash(gh, pr, view*)
Instructions
65 lines in SKILL.md · view on GitHub

Before installing

  • Ships executable scripts
  • Pre-approves some shell commands

Files (2)

  • SKILL.md
  • prune.ts · scripts/

SKILL.md (first lines)

# Prune merged branches

Each path in this skill is relative to the directory that holds this file. Expand it to a full path
before you run a command.

This skill deletes local branches and removes their worktrees. It changes nothing on the remote. It
never pushes. It never deletes a remote branch. It never closes a pull request. It reads GitHub
read-only, to learn each branch's PR base and merge status.

Run it from the main checkout. Do not run it from inside a linked worktree.

Arguments from the user: `$ARGUMENTS`

## Steps

1. Run the dry run:

   ```bash
   node scripts/prune.ts $ARGUMENTS
   ```

   Without `--apply` the script changes nothing. It prints a plan only. It queries GitHub once per
   branch, so it takes a few seconds.

2. Present the plan in your own words. Cover four groups:

   - The worktrees the script removes.
   - The branches the script deletes. Say how each one counts as merged. Name either the PR and its
     base branch, or the fallback base.
   - The branches the script keeps. Give the ahead-count and the PR state for each one.
   - The branches the script skipped. An uncommitted change in the worktree is the reason.

3. If the plan is empty, say so. Then stop.

4. If the plan is not empty, and the user passed no `--apply`, ask the user to confirm. Then run:

   ```bash
   node scripts/prune.ts --apply $ARGUMENTS
   ```

   Worktree removal deletes `node_modules`. It takes a minute or more for each worktree. Run this
   command in the background, so it does not time out.

5. Report what the script removed. Then show `git worktree list`.

## What counts as merged

A branch is merged when one of these is true:

- GitHub reports its PR as `MERGED` into that PR's own base branch. A branch merged into another
  feature branch in a stack counts. A squash merge counts. A rebase merge counts.
- Its tip is an ancestor of the fallback base, `origin/<default>`. This covers a merge commit and a
  fast-forward merge. It needs no network.

## Gotchas

- The script never deletes a branch when the local tip differs from the commit GitHub merged. A
  difference means there are unpushed commits after the merge. The script lists that branch under
  "merged on GitHub but local tip differs". The user deletes it by hand.
- GitHub detection needs an authenticated `gh`. Without one, or with `--no-gh`, only the
  git-ancestor check runs. A squash-merged branch then stays. Flag any branch that looks merged by
  PR, so the user can delete it by hand.
- The script skips a worktree with uncommitted tracked changes. `--force-dirty` includes it.

From seanogdev/skills, MIT.

Signals

Stars
0
Forks
0
Open issues
0
Last commit (this folder)
Oct 1, 2026 (27 days ago)

From GitHub (fetched Oct 24, 2026).

Details

License
MIT
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

More from seanogdev

Cite this page

prune-merged-branches skill. Agent Mart. https://agentmart.dev/skills/seanogdev-prune-merged-branches (last updated 2026-10-24)