Skip to content

cleanup-feature: verify remote branch deletion after gh pr merge --delete-branch #154

@jankneumann

Description

@jankneumann

Problem

/cleanup-feature relies on gh pr merge --delete-branch to remove the feature branch from the remote after merge. gh can succeed at the merge while silently failing at the branch deletion (e.g. branch protection rules, missing permission, race with another tool). The skill currently treats overall success of the gh command as proof that the remote branch is gone.

Proposed fix

After gh pr merge --delete-branch returns success, explicitly verify the remote branch is actually deleted:

```bash
gh api -X GET repos/{owner}/{repo}/branches/{branch} 2>&1 | grep -q "Not Found" \
|| git ls-remote --exit-code --heads origin > /dev/null 2>&1 \
&& echo "WARN: remote branch still exists after merge"
```

(Use whichever check is more reliable in practice — git ls-remote is cheaper.)

If the branch still exists, attempt one explicit git push origin --delete <branch>. If that also fails, surface a clear warning with the manual remediation command.

Acceptance

  • Cleanup logs include a "verified remote branch deleted" line on the happy path.
  • If deletion silently fails, cleanup emits a WARN and the manual git push origin --delete command.
  • Unit/integration test that simulates a branch-still-present-after-merge condition.

Source

Follow-up from wire-autopilot-phase-subagents change run (2026-05-10).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingenhancementNew feature or requestfollowupDeferred follow-up work from a prior changeopenspec:wire-autopilot-phase-subagentsFollow-up from wire-autopilot-phase-subagents

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions