Improve merge flow guidance for worktree-bound local branches
Problem
When gh pr merge --delete-branch runs after a successful PR merge, git emits a warning that it cannot delete the local branch because it is checked out in a cbox worktree. The manager agent interprets this warning as a merge failure and initiates unnecessary recovery actions — even though the remote merge succeeded and the branch was deleted on GitHub. This false-negative pattern has caused repeated confusion during sandbox PR merges, wasting manager cycles on a benign, expected git behavior unique to worktree-based workflows.
Context
Possible Solutions
Plan
Implementation Progress
- Detect and clarify benign local-delete failures for worktree-checked-out branches.
- Ensure merge-success path distinguishes remote merge success from local cleanup warnings.
-
Add docs/tests for expected behavior.
-
Operators no longer misinterpret this warning as merge failure.
- Merge automation can continue safely when remote merge succeeded.
-
cbox docs mention this behavior where relevant.
-
Source issue: repeated confusion during manager merges of sandbox PRs.
Implementation notes
_remove_worktree()inlibs/cbox/cbox/cli.pynow detects "checked out at" ingit branch -dstderr and prints a dim informational note instead of a yellow warning.- Merge verification guidance uses
gh pr view ... --json state --jq '.state'directly in docs. - 3 new tests in
libs/cbox/test_cleanup.pycover_remove_worktreemessage handling. - Docs updated in
docs/agent/cbox.md(new "Merge Flow" section) andlibs/cbox/skills/master-plan-cbox-manager/SKILL.md(new "PR Merge" section).
Review Feedback
- [ ] Review cleared