/agent-traffic-control:gh-pr-create-orchestration-cwd-wrong-headfrom agent-traffic-control
Diagnose and prevent `gh pr create` opening a PR against the WRONG head branch when invoked from a parallel-orchestration setup with multiple worktrees. Use when: (1) you've dispatched subagents to work in sub-worktrees but you're finalizing PRs from a separate orchestration worktree, (2) `gh pr create` succeeds but `gh pr view --json headRefName` shows your orchestration worktree's branch (e.g. `docs/sNNN-handoff`) instead of the feature branch the subagent committed to (e.g. `fix/issue-X`), (3) two PRs exist for the same logical change because a revived subagent opened a second one on the correct branch. Trigger: PR title is correct (heredoc body matches your intent) but the PR's `headRefName` doesn't match the feature worktree's branch — your CWD when invoking `gh` overrode the head selection.
Ships in agent-traffic-control. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description, though model invocation is off: only you can start it.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
gh pr create from orchestration worktree picks wrong head branchIn a parallel-execution setup, an orchestrator dispatches sub-agents to feature
worktrees (<repo>/.claude/worktrees/feature-A/, feature-B/, etc.) and waits
on their completion. When the orchestrator then runs gh pr create to open
the PR for one of those features, it gets opened against whatever branch is
currently checked out in the orchestrator's CWD — not the feature
branch the subagent committed to.
Result: a PR with the right title and body but the wrong head branch
(typically the orchestrator's docs/sNNN-handoff or main-tracking branch).
The PR's diff is unrelated to the change description, and the actual feature
work never gets a PR.
You're hitting this skill if all of:
gh pr create (with title + body via heredoc) from the
orchestrator's working directory.gh pr view <N> --json headRefName returns your orchestrator's branch
(e.g. docs/sNNN-handoff), NOT the feature branch (e.g.
fix/issue-XXX).gh pr diff <N> doesn't match the body text.Optional secondary signal:
gh pr create from the feature worktree where its CWD was). Now you
have two PRs.gh pr create defaults --head to the current branch in the CWD where you
invoked it. The orchestrator's CWD is typically a worktree that's checked
out on a different branch than the feature branch — that branch is what gets
pushed/used as head. The subagent's git commits in <repo>/.claude/worktrees/feature-X/
have NO effect on the orchestrator's CWD branch.
This is an easy trap because:
gh pr create invocation, so
there's nothing to visually trip on.Two equally good options. Pick whichever fits your workflow.
cd into the feature worktree before invoking ghcd /path/to/repo/.claude/worktrees/feature-A
gh pr create --title "..." --body "$(cat <<EOF ... EOF
)"
This relies on gh reading the CWD's branch automatically.
--head explicitly (no cd needed)gh pr create \
--head fix/issue-XXX \
--title "..." \
--body "..."
--head overrides CWD branch detection entirely. Slightly more verbose but
foolproof in mixed-worktree contexts.
# Verify which PR is wrong
gh pr view <wrong-N> --json headRefName,title
# Close the wrong one with a clear reason
gh pr close <wrong-N> --comment "Closing — opened against wrong head \
branch from orchestration worktree. PR <correct-N> is canonical."
# Open the correct one (if a sister subagent didn't already)
cd /path/to/feature-worktree
gh pr create --title "..." --body "..."
After opening the PR:
# These two should match:
gh pr view <N> --json headRefName --jq .headRefName
git -C /path/to/feature/worktree branch --show-current
Then spot-check the diff:
gh pr diff <N> | head -20
The first 20 lines should match the kind of changes described in the PR body (e.g. if the PR body says "rename X → Y", the diff should show that).
S160 incident (2026-05-08): orchestrator was on branch
docs/s159-handoff in worktree .claude/worktrees/fix-issues/. After the
pick #5 subagent finished work on branch
fix/s160-issue490-rename-status-labels in worktree
.claude/worktrees/s160-pick-3/, the orchestrator ran gh pr create from
its own CWD. The resulting PR #599 had:
docs/s159-handoff (the orchestrator's branch — totally
unrelated to the rename)The orchestrator only noticed when checking
gh pr view 599 --json headRefName. By then, the revived pick #5 subagent
had opened PR #600 on the correct branch. PR #599 was closed with a "wrong
head branch" comment; PR #600 became canonical.
gh CLI doesn't warn if the CWD branch and the recently-pushed
feature branch differ — both are valid heads from gh's perspective.gh pr create, run
git rev-parse --abbrev-ref HEAD and confirm it matches the branch you
pushed for THIS feature.subagent-bash-cd-wrong-worktree (subagent's cd lands in the
orchestrator's worktree)credit-stall-mid-orchestration-revive-collision (revived subagent
races the orchestrator's recovery actions)gh pr create docs: https://cli.github.com/manual/gh_pr_create —
--head flag documentation.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub wan-huiyan/agent-traffic-control --plugin agent-traffic-controlOther plugins' skills for the same job
118 skills in this plugin
/agent-refusal-with-evidence-beats-literal-complianceA dispatched agent that does exactly what you asked can ship a defect you would
have stopped yourself, because it can see something at the worksite that you
could not see when you wrote the brief. Use when: (1) you are writing a brief
that prescribes a specific fix, threshold, wording or value rather than the
outcome you want; (2) an agent reports that it did not do what you asked and
you are deciding whether that is insubordination or judgement; (3) an agent
asserts "this is fine" or "not needed" with no measurement behind it; (4) you
are reviewing overnight output and want to know which decisions were checked
and which were assumed. Two halves, and both are needed: give the agent
explicit permission to satisfy the INTENT of an instruction while refusing its
letter, and REQUIRE the evidence with the refusal — what it built or measured,
what that showed, what it did instead. Evidence is the whole difference between
a refusal you can bank and one you have to re-litigate. Four agents correctly
declined an instruction in a single run; one built the suggested fix, measured
that it turned a silent safe refusal into a permanently red pipeline, and
reverted it unpushed.
/auto-merge-rearms-while-agent-live-kill-then-disarm-verify