claude.ai/code: head branch not deleted after MCP-driven PR merge despite agent instructions
What happens
When Claude Code on web/mobile (claude.ai/code) merges a PR via the GitHub MCP, it does not delete the head branch afterward, even when the session's instructions explicitly tell it to.
Repro
- Connect a GitHub repo to a claude.ai/code environment
- Authorize the GitHub MCP (one-time OAuth)
- In a session, give an explicit instruction like: "When done, open a PR, merge it, then delete the branch"
- Have the agent make some change
- Trigger the merge
- Observe: PR merges successfully, but the head branch remains on origin
Also confirmed when the delete-branch instruction lives in a SKILL.local.md override file in the cloned repo.
Workaround
Enable "Automatically delete head branches" at the repo level: gh repo edit OWNER/REPO --delete-branch-on-merge. This delegates the cleanup to GitHub itself, which fires on every merge regardless of source.
Why this matters
Without the workaround, every Claude Code mobile session that creates and merges a PR leaves an orphan branch behind. Over a few weeks of mobile use, users accumulate dozens of stale claude/* branches that they have to clean up manually.
Environment
- Claude Code on claude.ai/code (web/mobile sandbox)
- GitHub MCP connected via Anthropic's OAuth
- Model: claude-sonnet-4-6
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗