To share in #coding-agent slack channel.
Executive Summary
Is there a way to specify the base branch the coding agent should use upon assignment using gh? Consider this:
gh issue edit $TASK_ISSUE --add-assignee "@copilot" -R $REPO
QUESTION: Is there a --base-branch option? I did RTFM and did not see such a thing.
Details
I am working on a low-key system that uses a combination of scripting, and skills to shepherd issues from "assigned to copilot" to "merged to the specified (almost always non-main) base branch. The script has things like this:
status "Phase 1: Launching copilot --yolo for task #$TASK_ISSUE"
PHASE1_PROMPT="Invoke skill \`shepherd-task-to-ready\` with these inputs:
- TASK_ISSUE: $TASK_ISSUE
- BASE_BRANCH: $BASE_BRANCH
- REPO: $REPO"
status "Phase 1 prompt:"
echo "$PHASE1_PROMPT"
echo "$PHASE1_PROMPT" | copilot --yolo
status "Phase 1: copilot exited. Verifying state..."
# --- Verify Phase 1 outcome ---
PR_NUMBER=$(find_linked_pr) || fail "No open PR found linked to issue #$TASK_ISSUE after Phase 1."
status "Found PR #$PR_NUMBER"
There is a bunch of text in the skill that assigns the issue to copilot and tries to specify the base branch, but it doesn't work reliably. Here's the skill if you're curious: link to skill.
DETAIL_QUESTION: What I'm looking for is a way for gh to programmatically do the analog of the Select base branch component here:
Copilot research
Showing my work that lead me to ask the question here.
Prompt
Consider this question about the gh CLI:
Is there a way to specify the base branch the coding agent should use using gh?
gh issue edit $TASK_ISSUE --add-assignee "@copilot" -R $REPO
Is there a --base-branch option?
Response
No, gh issue edit does not have a --base-branch option.
The way to specify a base branch for the Copilot coding agent is not via gh issue edit — instead, you use gh api to set it via the GitHub API when creating the Copilot agent task. Specifically, you'd POST to the issue with the base branch encoded in the request body, or create a PR with a specific base.
The more direct approach is to use the Copilot API endpoint:
gh api repos/$REPO/copilot/tasks
--method POST
-f issue_number=$TASK_ISSUE
-f base_branch=main
Or, since assigning @copilot triggers the agent automatically, you can create the branch first and then set it as the default in your repo context before assigning.
To share in
#coding-agentslack channel.Executive Summary
Is there a way to specify the base branch the coding agent should use upon assignment using
gh? Consider this:QUESTION: Is there a
--base-branchoption? I did RTFM and did not see such a thing.Details
I am working on a low-key system that uses a combination of scripting, and skills to shepherd issues from "assigned to copilot" to "merged to the specified (almost always non-
main) base branch. The script has things like this:There is a bunch of text in the skill that assigns the issue to copilot and tries to specify the base branch, but it doesn't work reliably. Here's the skill if you're curious: link to skill.
DETAIL_QUESTION: What I'm looking for is a way for
ghto programmatically do the analog of the Select base branch component here:Copilot research
Showing my work that lead me to ask the question here.
Prompt
Consider this question about the
ghCLI:Is there a way to specify the base branch the coding agent should use using
gh?Is there a
--base-branchoption?Response
No, gh issue edit does not have a --base-branch option.
The way to specify a base branch for the Copilot coding agent is not via gh issue edit — instead, you use gh api to set it via the GitHub API when creating the Copilot agent task. Specifically, you'd POST to the issue with the base branch encoded in the request body, or create a PR with a specific base.
The more direct approach is to use the Copilot API endpoint:
gh api repos/$REPO/copilot/tasks
--method POST
-f issue_number=$TASK_ISSUE
-f base_branch=main
Or, since assigning @copilot triggers the agent automatically, you can create the branch first and then set it as the default in your repo context before assigning.