npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@rohitkatakam/cleanrepo

v1.1.0

Published

Cleanup your local and remote Git repo by removing merged and stale branches

Readme

CleanRepo: Interactive Git Branch Cleanup Tool

cleanrepo is a command-line utility designed to help you clean up your local and remote Git repositories by identifying and interactively deleting merged or stale branches.

Features

  • Identifies local and remote branches merged into a specified base branch.
  • Optionally identifies branches that haven't seen commits for a configurable number of days (stale branches).
  • Provides an interactive checklist interface (inquirer) to select which branches to delete.
  • Supports dry runs to preview branches that would be deleted without making changes.
  • Safely handles the current branch and the base branch.

Installation

To use cleanrepo from anywhere on your system, install it globally using npm:

npm install -g @rohitkatakam/cleanrepo

(Make sure you have Node.js and npm installed.)

Alternatively, for development or local use within the cloned project directory, you can link the package or run it directly using node:

# Link for development (from project root)
npm link

# Or run directly
node cli.js [options]

Usage

cleanrepo [options]

Options

| Option | Alias | Type | Default | Description | |---------------|-------|---------|---------|------------------------------------------------------------------------------------------------------------| | --base | -b | string | main | The base branch to compare against for identifying merged branches (both locally and on the remote). | | --remote | -r | boolean | false | Enable checking and deleting remote branches on origin. Requires git fetch --prune beforehand. | | --stale | -s | number | 120 | Check for branches (local and, if -r, remote) with no commits older than this many days. Activates stale check. | | --dry-run | -D | boolean | false | Show which branches would be deleted based on the criteria, but don't actually delete anything. |

Notes on --stale:

  • Providing -s or --stale without a number uses the default value (120 days).
  • Providing -s <days> or --stale <days> uses the specified number of days.
  • If the --stale flag is not provided at all, stale branches are not checked or deleted.
  • Staleness is based on the author date of the last commit on the branch.

Interactive Mode

When running without --dry-run, cleanrepo will present you with interactive prompts for each category of branches identified for deletion (e.g., local merged, remote stale):

  1. A checklist will appear, showing the candidate branches.
  2. All branches are selected by default.
  3. Use the Arrow Keys (Up/Down) to navigate the list.
  4. Press the Spacebar to toggle the selection status (checked/unchecked) of the highlighted branch.
  5. Press 'a' to toggle the selection for all branches.
  6. Press 'i' to invert the current selection.
  7. Press Enter to confirm your selection.

Only the branches you leave checked when you press Enter will be deleted.

Examples

1. Dry Run: See local and remote branches merged into main or stale for 120+ days:

cleanrepo -r -D -s
# Or using the default stale value:
cleanrepo -r -D --stale

(This will list candidates but not delete anything. Branch names will be highlighted.)

2. Interactively delete local branches merged into develop:

cleanrepo -b develop

(You will be prompted to select which merged local branches to delete.)

3. Interactively delete local and remote branches merged into main OR stale for 30+ days:

cleanrepo -r -s 30

(You will get separate prompts for local merged, local stale, remote merged, and remote stale branches if candidates are found in each category.)

4. Delete ONLY local branches stale for more than 180 days (compared to main):

cleanrepo -s 180

(This will only find and prompt for local stale branches.)