Skip to content

base_branch support for stacked PRs #54

@chanakyav

Description

@chanakyav

Parent Epic

Part of #52 — Sequential stacked PR chains

Summary

Add base_branch support so PRs can target a parent task's branch instead of the repo's default branch. This enables true stacked PRs where PR #2 targets PR #1's branch.

Context

Today, all PRs implicitly target main (or whatever the default branch is). Prompts tell the agent gh pr create --draft without specifying --base. For stacked workstreams, PR #2 needs to target PR #1's branch so it only contains its own diff.

Changes

persistence.py

prompts.py

  • All prompts that mention gh pr create add --base <base_branch> when base_branch is set
  • Self-review diffs against base_branch: git diff <base_branch> instead of hardcoded main
  • Fix prompt to diff against base_branch too

github_api.py

  • Add get_default_branch()gh repo view --json defaultBranchRef --jq .defaultBranchRef.name, cached
  • Update find_pr_for_branch() to optionally verify the base branch matches

orchestrator.py

  • Orchestrator reads base_branch from task record
  • Passes base_branch to prompt generators
  • Falls back to get_default_branch() when base_branch is NULL
  • Fix _do_update_description() to use base_branch instead of hardcoded main for git diff

cli.py

  • cmd_start accepts --base flag for manual stacked PR support
  • Stores base_branch in task record

Depends On

Testing

  • PR created with --base <parent_branch> when base_branch is set
  • PR created without --base when base_branch is NULL (targets default branch)
  • get_default_branch() caches correctly
  • Prompts include correct diff target
  • _do_update_description() uses base_branch for git diff

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions