← ClaudeAtlas

session-handoff-detect-prior-orphan-prlisted

Pre-flight detection of a prior incomplete /session-handoff run that already created a branch, PR, handoff doc, and/or worktree — so the current invocation doesn't open a duplicate PR. Use when (1) you're about to write `docs/handoffs/session_N_handoff.md` as part of /session-handoff, (2) you just created or considered creating a `docs/sN-handoff` branch and `git` reports "branch already exists" or `+` (checked out elsewhere), (3) you find a worktree under `.claude/worktrees/` whose name vaguely matches the current session number, (4) `git status` in a worktree you don't recognize shows "nothing to commit" but the working tree contains a session handoff doc you haven't seen written this turn. Root cause: a prior orchestrator (parallel session, aborted earlier run, or a /session-handoff that ran partway and lost its context) created the branch + handoff doc + push + PR before the current orchestrator picked up. Without this check, you'll write a fresh handoff doc in the main checkout, commit to a different bra
wan-huiyan/agent-traffic-control · ★ 2 · Code & Development · score 79
Install: claude install-skill wan-huiyan/agent-traffic-control
# /session-handoff pre-flight: detect prior orphan branch + PR before writing a new handoff doc ## Problem You're running /session-handoff at the end of a long, multi-step session. You start drafting `docs/handoffs/session_N_handoff.md` in the main checkout. Everything looks fine — `git status` in the main checkout shows the file as untracked, you write 200 lines, you're ready to commit. Then you go to create the PR branch and `git worktree add` fails with "branch already exists." Or worse, you don't check and silently create a duplicate PR. Root cause: a prior orchestrator already did most of /session-handoff for this session. That orchestrator: 1. Created branch `docs/sN-handoff` off main 2. Created a worktree (often mis-labeled like `.claude/worktrees/sN+1-handoff` instead of `.claude/worktrees/sN-handoff`) 3. Wrote `docs/handoffs/session_N_handoff.md` in that worktree 4. Committed and pushed to `origin/docs/sN-handoff` 5. Opened a PR (often a thin one with just the handoff doc, missing the rest of the 7-bucket dispatch) 6. Then lost context, was interrupted, or didn't finish the rest of the workflow The current orchestrator has no memory of that work — it's a different session instance — and sees only the fresh state. The detection signals are subtle: - `git branch --list 'docs/sN-handoff'` shows `+ docs/sN-handoff` (the `+` means checked out in another worktree). - `git worktree list | grep -i sN` reveals a worktree at an unfamiliar path. - That worktree contains `