claude.ai/code: head branch not deleted after MCP-driven PR merge despite agent instructions

Resolved 💬 1 comment Opened May 16, 2026 by DanceNinjas Closed Jun 14, 2026

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

  1. Connect a GitHub repo to a claude.ai/code environment
  2. Authorize the GitHub MCP (one-time OAuth)
  3. In a session, give an explicit instruction like: "When done, open a PR, merge it, then delete the branch"
  4. Have the agent make some change
  5. Trigger the merge
  6. 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

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗