fix(dev-agent): prevent PRs from targeting wrong base branch#3
Open
fix(dev-agent): prevent PRs from targeting wrong base branch#3
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two bugs caused dev-agent PRs to target stale feature branches instead of
main, requiring manualgh pr edit --base mainon every PR.Problem
enter-worktree.shforks fromHEAD— 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 createthen infers the wrong base branch from git history.gh pr createhas no--baseflag — 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/HEAD→origin/main→origin/master) and fork worktrees from that instead ofHEAD. Fails with a clear error if no default branch can be determined.SKILL.md: Add--base mainto thegh pr createtemplate.sdlc-checklist.md: Add--base mainto the PR creation checklist item.Testing
feat/3-adk-fastapi-chatinstead ofmainorigin/main, PRs explicitly targetmain🤖 Generated with Claude Code