Skip to content

fix(dev-agent): prevent PRs from targeting wrong base branch#3

Open
BenPerel wants to merge 1 commit intomainfrom
fix/worktree-and-pr-base-branch
Open

fix(dev-agent): prevent PRs from targeting wrong base branch#3
BenPerel wants to merge 1 commit intomainfrom
fix/worktree-and-pr-base-branch

Conversation

@BenPerel
Copy link
Copy Markdown
Owner

Summary

Two bugs caused dev-agent PRs to target stale feature branches instead of main, requiring manual gh pr edit --base main on every PR.

Problem

  1. enter-worktree.sh forks from HEAD — if the main repo checkout is on a feature branch (common in multi-agent setups), new worktree branches inherit that as their parent. gh pr create then infers the wrong base branch from git history.

  2. gh pr create has no --base flag — it guesses the target branch from the fork point in git history. When the worktree was forked from a non-main branch, it guesses wrong.

Changes

  • enter-worktree.sh: Resolve origin's default branch (origin/HEADorigin/mainorigin/master) and fork worktrees from that instead of HEAD. Fails with a clear error if no default branch can be determined.
  • SKILL.md: Add --base main to the gh pr create template.
  • sdlc-checklist.md: Add --base main to the PR creation checklist item.

Testing

  • Verified in model-armor-gandalf where this bug caused PR #47 to target feat/3-adk-fastapi-chat instead of main
  • After fix: new worktrees fork from origin/main, PRs explicitly target main

🤖 Generated with Claude Code

Two bugs caused PRs to target stale feature branches instead of main:

1. enter-worktree.sh forked new branches from HEAD, which could be any
   branch checked out in the main repo. Now resolves origin's default
   branch (via origin/HEAD, then origin/main, then origin/master) and
   forks from that instead.

2. gh pr create had no --base flag, so it inferred the base from git
   history — which picked the wrong branch when the worktree was forked
   from a non-main ref. Now explicitly sets --base main.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant