Branches Cleaner Github Action
Branches Cleaner the Perfect Solution for Branches You No Longer Need!
FreeOpen SourceCI16,290 impressions#3 of its week
Branches Cleaner is a GitHub Action that automatically deletes merged, closed, and inactive branches while protecting specified base branches.
- for
- GitHub repo maintainers and development teams needing automated branch cleanup
- pricing
- open source
Key features
- Closed PR branch removal — Deletes feature branches from rejected or abandoned pull requests automatically.
- Merged branch cleanup — Removes branches that have already been merged into the main codebase.
- Inactive branch detection — Deletes branches with no commits for a configurable number of days (default 7).
- Protected branch safety — Never deletes branches listed as base or protected (e.g., main, develop).
- Scheduled execution — Runs on a cron schedule (e.g., daily at midnight) without manual intervention.
- Comprehensive testing — Includes unit, integration, and functional tests using Bats and Docker.
Use cases
- Remove stale feature branches after a sprint to keep the repo tidy
- Automatically clean up branches from closed PRs in a CI pipeline
- Enforce branch retention policies by deleting inactive branches older than a set threshold
Branches Cleaner Github Action FAQ
How do I specify which branches should never be deleted?+
Provide a comma-separated list of base branches in the `base_branches` input (e.g., `main,develop`).
Can I change the inactivity period before a branch is removed?+
Yes, set `days_old_threshold` to the desired number of days; it defaults to 7 if omitted.
What token is required for the action to work?+
Pass a GitHub token (e.g., `${{ secrets.GITHUB_TOKEN }}`) via the `token` input to authenticate with the GitHub API.
How is the action triggered?+
It can be triggered by any GitHub event; a common setup uses a scheduled cron trigger to run daily.
What should I do if I see exit code 127 errors?+
Ensure the workflow has read-and-write permissions enabled in the repository’s Actions settings.
Summarized by DevHunt from dub.sh · Sep 27, 2026. Details may change; check the official site.


.png?width=64)








