# Ship to milestone branch instead of main

Issues in a milestone merge into the milestone's own branch instead of `main`. The team tries the whole milestone on a preview or on staging, then merges it into `main` by hand.

Works with any ub-agents version: loop policy that sends issue PRs to the milestone branch. `milestones: gate` in the queue is optional and finishes one milestone at a time. A preview per milestone needs a host that deploys every branch.

## Why it exists

When every merge to main deploys to production, a feature split into small issues reaches users half finished. Here a milestone is the feature. When the milestone has no branch yet, the implementer creates one from main, and every issue in the milestone merges into that branch instead of main. Once the first issue lands, one pull request from the branch into main opens and lists what has landed so far; a small workflow can keep it current. Whenever main changes, it is merged into the branch, by the agents working on the branch or by a workflow, so the milestone always runs on current main. A trivial conflict, such as a lockfile or a small hotfix line, is fixed on the spot; anything harder goes to the team with concrete suggestions for resolving it. The team tries the whole milestone on the branch's preview, or on staging when the host doesn't deploy every branch. When it decides to release, it checks the milestone PR's gates and merges it by hand.

Several milestones can run side by side. To finish them one at a time instead, turn on the queue's [milestone gate](https://agents.uberblick.ai/docs/configuration/queue.md).

## What you gain

- Small issues and small reviews, without shipping a feature in pieces.
- One place, a preview or staging, where the team tries the whole milestone before anyone sees it.
- A release that is a single, deliberate merge into main.

## Where a person steps in

Trying the milestone and merging it into main, and resolving a conflict between main and a milestone branch that is too complex for the agents.

## The flow

```flow
flow v0
# Milestone branches: issues land on their milestone's branch, the team lands the milestone in main.

columns note main sync stop

section "Each issue"
box start col=main title="Team member" tone=neutral "files an issue in a milestone"
box issue-preparer "prepares it, attaches the ready label"
box implementer "builds the change, opens its PR into the milestone branch"
box create-branch col=sync row=implementer title="create the branch" "from main, on the milestone's first issue"
box review-merge col=main title="reviewer + integrator" "merges the PR into the milestone branch, closes the issue"
box update-branch col=sync row=review-merge title="update the branch" "merges main in, fixes a trivial conflict"

section "The milestone"
box branch col=main title="Milestone branch" tone=system "every landed issue, tried together"
panel description col=note row=branch tone=muted
  strong "Milestone description"
  text "names the milestone branch"
  muted "and its preview URL, if any"
box milestone-pr col=main title="Milestone PR" tone=neutral "from the branch into main, lists what landed"
end production "In main · deployed"

panel human col=stop row=branch span=3 tone=stop
  strong "The team decides"
  text "tries the milestone"
  muted "decides to release the milestone"
  rule
  muted "resolves a complex conflict with main"

start --> issue-preparer : needs-preparation
issue-preparer --> implementer : ready
implementer --> review-merge : handed-off
review-merge --> branch : merged
implementer --> create-branch from=right.1 to=left.1 : no branch yet
create-branch --> implementer from=left.2 to=right.2 label=end : Branch line added
description -.-> branch tone=muted
review-merge --> update-branch from=right.1 to=left.1 : main has changed
update-branch --> review-merge from=left.2 to=right.2 label=end : branch up to date
update-branch --> human tone=stop : complex conflict, with suggestions
branch -.-> milestone-pr tone=muted : opens with the first issue
human --> milestone-pr tone=stop : releases it
milestone-pr --> production : gates pass, merged by hand

legend
  box tone=neutral "team member"
  box "agent role"
  box tone=system "milestone branch"
  panel tone=stop "a person decides"

play "First issue"
  tempo 1.8s
  step start actor="Team member" "Files an issue in the “Team invoices” milestone"
  step issue-preparer 2.4s actor="Issue preparer" "Prepares the issue and attaches the ready label"
  step implementer 2.4s actor="Implementer" "Checks whether the milestone already has a branch"
  step create-branch 3s actor="Implementer" "No branch yet: creates it from main"
  step implementer 2.6s actor="Implementer" "Builds the change, opens a PR against the milestone branch"
  step review-merge 2.6s actor="Integrator" "PR reviewed; main is unchanged"
  step branch 3s actor="Integrator" "Adds the PR to the milestone branch, closes the issue"
  step milestone-pr 2.6s actor="Workflow" "Opens the milestone PR into main, listing what landed"

play "Next issue"
  tempo 1.8s
  step start actor="Team member" "Files the next issue in the same milestone"
  step issue-preparer 2.4s actor="Issue preparer" "Prepares the issue and attaches the ready label"
  step implementer 2.6s actor="Implementer" "Creates a PR against the existing milestone branch"
  step review-merge 2.6s actor="Integrator" "PR reviewed; main is unchanged"
  step branch 2.6s actor="Integrator" "Adds the PR; the milestone now holds both changes"

play "Main moved"
  tempo 1.8s
  step implementer 2.4s actor="Implementer" "Opens a PR against the milestone branch"
  step review-merge 2.6s actor="Integrator" "PR reviewed, but main has changed"
  step update-branch 3s actor="Integrator" "Merges main into the milestone branch"
  step review-merge 2.6s actor="Integrator" "Back on the PR: the branch is up to date"
  step branch 3s actor="Integrator" "Adds the PR; the milestone runs on current main"

play "Trivial conflict"
  tempo 1.8s
  step review-merge 2.6s actor="Integrator" "PR reviewed, but main has changed"
  step update-branch 3s actor="Integrator" "Only the lockfile conflicts: regenerates it, merges main"
  step review-merge 2.6s actor="Integrator" "Back on the PR: the branch is up to date"
  step branch 3s actor="Integrator" "Adds the PR; the milestone runs on current main"

play "Complex conflict"
  tempo 1.8s
  step review-merge 2.6s actor="Integrator" "A reviewed PR is waiting, and main has changed"
  step update-branch 3s actor="Integrator" "main and the branch changed the same logic: it stops"
  step human 3s actor="Integrator" "Escalates with concrete suggestions for resolving it"
  step human 3s actor="Maintainer" "Resolves the conflict on the milestone branch"

play "Milestone lands"
  tempo 1.8s
  step human 3s actor="Team" "Tries the milestone on its preview or staging, decides to release"
  step milestone-pr 3s actor="Team" "Checks the gates on the milestone PR"
  step production 3s actor="Team" "Merges the milestone PR into main by hand"
```

## Adopt it

Give your coding agent this prompt:

```text
I'm thinking about adding "Ship to milestone branch instead of main" (https://agents.uberblick.ai/workflows/milestone-branches/) to the ub-agents loop in one of my repositories. Read that page, then walk me through what you think of it: how it changes where the loop merges issues, what it is good for, and what could go wrong.

If you are not already in the repository that runs ub-agents, ask me which one to look at. Then look for evidence that it would help there: whether a merge to main deploys or releases on its own, whether features are split across several issues that ship half done, whether the host gives each branch a preview, how milestones are used today, and how often main changes under long-running work. Read its ub-agents.yaml and loop policy under .agents/, and tell me plainly whether you would adopt it, adopt it with changes, or leave it.

If you recommend it, propose an adoption plan. In the loop policy, give each milestone a "Branch: milestone/SLUG" line in its description, plus a "Preview:" line if the host deploys every branch, have the first issue's implementer create the branch from main, have issue PRs target the milestone's branch, and have the integrator close the issue after merging there, since GitHub only closes issues on merges into the default branch. Once a milestone's first issue lands, open one pull request from its branch into main that lists what has landed, by hand or with a small workflow, and leave merging it to a person. Whenever main has changed, merge it into the milestone branch, by merge and never by rebase: the agents that work on the branch can do it before they build or merge, or a workflow can do it when main moves. Fix a trivial conflict on the spot, such as a lockfile or a small hotfix line, and stop for a person on anything harder, with concrete suggestions for resolving it. Without branch previews, the team tries a milestone by deploying its branch to staging. Leave the queue's milestones setting as it is, so milestones can run side by side, unless I want them to finish one at a time; then suggest milestones: gate. Make sure CI runs for pull requests into any branch. Keep the change the smallest that works, preserve the repository's checks and human merge decisions, and show me the diff before writing anything.
```
