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
In the set of tools listed, I can see 'create branch' and 'delete file' tools but not 'delete branch'. Is this intentionally excluded?
Is it in the roadmap to add the tool with some guardrails like only allow deleting unprotected branches or branches created by the MCP server tool?
Appreciate any inputs.
Hello I'd like to pick this up. I've implemented a delete_branch tool following the same pattern as the existing create_branch, with the guardrail suggested above: it fetches the branch first and refuses to delete protected branches, returning a clear error to the model instead of attempting the deletion.
The Behavior:
Required params: owner, repo, branch
Checks branch protection via GET /repos/{owner}/{repo}/branches/{branch} before deleting
Deletes via DELETE /repos/{owner}/{repo}/git/refs/heads/{branch}
ReadOnlyHint: false, scoped to repo
Tests cover success, protected-branch refusal, branch-not-found, and delete-failure cases. Happy to adjust the guardrail scope (e.g. also blocking the default branch) based on maintainer preference. Opening a PR shortly.
My agents push short-lived work branches and ship the work to main.
After that the branch is stale, and the agent cannot remove it.
Today a person has to delete each one on the Branches page.
A delete_branch tool could call DELETE /repos/{owner}/{repo}/git/refs/heads/{branch}.
It should refuse the default branch and respect rulesets and branch protection.
Yes this is implemented in #2790 (targeting main), which closes this issue.
On the guardrails you raised:
Branch protection: before deleting, the tool calls GET /repos/{owner}/{repo}/branches/{branch} and refuses with a clear error if the branch is protected, so it won't delete a classic-protected branch.
Rulesets: the pre-check only reads the classic protected flag. If a ruleset blocks the deletion, the DELETE call itself fails and the tool surfaces that API error to the model instead of reporting success — so a ruleset-protected branch is still safe, just caught at the delete step rather than the pre-check.
Default branch: not special-cased yet. It's normally protected (so usually caught above), but I'm happy to add an explicit default-branch refusal if maintainers want a belt-and-suspenders guard.
Tests cover success, protected-branch refusal, branch-not-found, and delete-failure, and pass locally. The branch has the latest main merged in to clear the earlier conflicts; CI is still running on the new head.
Activity
bfedorov-clgx commentedon Apr 23, 2026
hello team!
I agree with colleague, it's highy necessary feature. Please add delete_branch tool.
nmime commentedon Jun 1, 2026
Can it be added?
huzaifa678 commentedon Jun 28, 2026
Hello I'd like to pick this up. I've implemented a delete_branch tool following the same pattern as the existing create_branch, with the guardrail suggested above: it fetches the branch first and refuses to delete protected branches, returning a clear error to the model instead of attempting the deletion.
The Behavior:
Required params: owner, repo, branch
Checks branch protection via GET /repos/{owner}/{repo}/branches/{branch} before deleting
Deletes via DELETE /repos/{owner}/{repo}/git/refs/heads/{branch}
ReadOnlyHint: false, scoped to repo
Tests cover success, protected-branch refusal, branch-not-found, and delete-failure cases. Happy to adjust the guardrail scope (e.g. also blocking the default branch) based on maintainer preference. Opening a PR shortly.
illichso commentedon Nov 16, 2026
+1 for a delete_branch tool in the repos toolset.
My agents push short-lived work branches and ship the work to main.
After that the branch is stale, and the agent cannot remove it.
Today a person has to delete each one on the Branches page.
A delete_branch tool could call DELETE /repos/{owner}/{repo}/git/refs/heads/{branch}.
It should refuse the default branch and respect rulesets and branch protection.
Is this planned?
huzaifa678 commentedon Nov 16, 2026
Yes this is implemented in #2790 (targeting
main), which closes this issue.On the guardrails you raised:
GET /repos/{owner}/{repo}/branches/{branch}and refuses with a clear error if the branch is protected, so it won't delete a classic-protected branch.protectedflag. If a ruleset blocks the deletion, theDELETEcall itself fails and the tool surfaces that API error to the model instead of reporting success — so a ruleset-protected branch is still safe, just caught at the delete step rather than the pre-check.Tests cover success, protected-branch refusal, branch-not-found, and delete-failure, and pass locally. The branch has the latest
mainmerged in to clear the earlier conflicts; CI is still running on the new head.