You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
claude-code template: recommend GitHub's "Automatically delete head branches" setting in the README #202
New GitHub repos keep a PR's branch after the PR is merged. Projects built from the claude-code template make a lot of short-lived branches. Claude sessions open one branch, and often one worktree, per change. The merged branches pile up on GitHub until someone cleans them up by hand.
In one downstream project, 21 of the 22 remote branches were already merged when someone looked. Every one of them had to be checked against master before it was safe to delete, because git push --delete deletes whatever it's given, merged or not.
Proposal
Recommend GitHub's "Automatically delete head branches" setting in the README's project setup steps. It's a per-repo setting, so it can't go in .devcontainer/:
gh api -X PATCH repos/<owner>/<repo> -F delete_branch_on_merge=true
Or go to Settings → General → Pull Requests → Automatically delete head branches. It needs admin rights on the repo.
Notes for the README:
It only affects PRs merged after the setting is turned on. Branches that are already merged still have to be deleted by hand.
Only the GitHub branch is deleted. Local branches and worktrees stay until git fetch --prune plus git branch -d, or git worktree remove.
Branch protection rules and rulesets can stop a branch from being deleted (GitHub docs).
This repo has the setting off too (delete_branch_on_merge: false), so it could be turned on here as well.
Acceptance
The README's setup section recommends the setting and shows the gh api command.
Activity