DEV Community

Cover image for Cleaning Github repositories, PRs and issues in bulk like a Pro
Lucas Andrade
Lucas Andrade

Posted on

Cleaning Github repositories, PRs and issues in bulk like a Pro

Hey folks!

If you maintain multiple repositories or work with organizations on GitHub, you probably know the pain: closing stale PRs, deleting merged branches, managing Dependabot alerts, archiving old repos... It's tedious, repetitive, and takes time away from actual coding. And it's not possible to do that in bulk, I don't know why, and it bothers me.

So I built GitHub AutoMaintainer, a CLI tool in Go that automates all of this.


What it does

Close stale PRs automatically

automaintainer close-prs --org my-org --days 30
Enter fullscreen mode Exit fullscreen mode
  • Closes PRs older than X days
  • Adds a comment explaining why
  • Supports --dry-run to preview changes

Delete merged branches

automaintainer delete-branches --org my-org --exclude main,develop
Enter fullscreen mode Exit fullscreen mode
  • Cleans up branches already merged into default
  • Exclude specific branches from deletion

Close inactive issues

automaintainer close-issues --org my-org --days 90
Enter fullscreen mode Exit fullscreen mode
  • Grace period with "stale" label before closing
  • Option to lock issues after closing
  • Filter by labels

Manage repositories in bulk

automaintainer repos list --org my-org --inactive 365
automaintainer repos archive --org my-org -i
automaintainer repos delete --org my-org -i
Enter fullscreen mode Exit fullscreen mode
  • List repos with filters (inactive, archived)
  • Archive or delete in bulk
  • Interactive mode (-i) for visual selection

Handle Dependabot alerts

automaintainer security list --org my-org --severity high
automaintainer security dismiss --org my-org --severity low --days 180
Enter fullscreen mode Exit fullscreen mode
  • List alerts by severity and state
  • Dismiss old low-priority alerts

Nice terminal UI

I used the Charmbracelet libraries to make the output actually pleasant:

Styled tables

┌────────────────────────┬───────────────┬────────────┐
│ REPOSITORY             │ LAST ACTIVITY │ STATUS     │
├────────────────────────┼───────────────┼────────────┤
│ my-org/api             │ 2024-01-15    │ ● active   │
│ my-org/legacy          │ 2022-03-10    │ ○ archived │
└────────────────────────┴───────────────┴────────────┘
Enter fullscreen mode Exit fullscreen mode

Progress bars for long-running operations

Scanning repos [████████████████░░░░] 42/100 my-org/current-repo
Enter fullscreen mode Exit fullscreen mode

Preview mode - select before executing

automaintainer close-prs --org my-org --preview
Enter fullscreen mode Exit fullscreen mode

Opens an interactive TUI where you navigate with arrows, toggle with space, and confirm only what you want.


Other features

GitHub URLs as arguments

# Both work
automaintainer close-prs --org my-org
automaintainer close-prs https://github.com/my-org
Enter fullscreen mode Exit fullscreen mode

Dry run mode - preview everything before making changes

Colored output - green for active, gray for archived, red for critical alerts


Installation

brew install olucasandrade/automaintainer/automaintainer
Enter fullscreen mode Exit fullscreen mode

Or download the binary from releases.


Why Go?

  • Single binary, no dependencies
  • Cross-platform (Linux, macOS, Windows)
  • Great performance for bulk operations
  • Excellent CLI ecosystem (Cobra, Bubble Tea)

What's next

  • Full interactive dashboard
  • Label sync between repos
  • Exportable reports
  • GitHub Enterprise support

The code is fully open source: github.com/olucasandrade/homebrew-automaintainer

If you maintain repos, work with open source, or just want to automate boring GitHub tasks, give it a try and let me know what you think.

Issues, PRs, and suggestions are always welcome. The goal is simple: make life easier for those who already make life easier for others through code.

Top comments (0)