Create Pull Request
Branch Strategy
- Target branch:
canary(development branch, cloud production) mainis the release branch — never PR directly to main
Steps
1. Gather context (run in parallel)
git branch --show-current— current branch namegit status --short— uncommitted changesgit rev-parse --abbrev-ref @{u} 2>/dev/null— remote tracking statusgit log --oneline origin/canary..HEAD— unpushed commitsgh pr list --head "$(git branch --show-current)" --json number,title,state,url— existing PRgit diff --stat --stat-count=20 origin/canary..HEAD— change summary- Reuse an existing acceptance link from the task when it covers the delivered behavior. If a lookup is needed, first follow Publish auth preflight, then run
publish_lh acceptance run list --jsonand match onbranch. Do not blindly unset API keys: the production credential may exist only in the environment. A lookup never requires creating a new round.
2. Handle uncommitted changes on default branch
If current branch is canary (or main) AND there are uncommitted changes:
- Analyze the diff (
git diff) to understand the changes - Infer a branch name from the changes, format:
<type>/<short-description>(e.g.fix/i18n-cjk-spacing) - Create and switch to the new branch:
git checkout -b <branch-name> - Stage relevant files:
git add <files>(prefer explicit file paths overgit add .) - Commit with a proper gitmoji message
- Continue to step 3
If current branch is canary/main but there are NO uncommitted changes and no unpushed commits, abort — nothing to create a PR for.
3. Push if needed
- No upstream:
git push -u origin $(git branch --show-current) - Has upstream:
git push origin $(git branch --show-current)
4. Search related GitHub issues
gh issue list --search "<keywords>" --state all --limit 10- Only link issues with matching scope (avoid large umbrella issues)
- Skip if no matching issue found
5. Acceptance gate
A feature or fix needs a published acceptance round before the PR is opened (AGENTS.md → Acceptance). If step 1 found none for this branch, run the acceptance skill first and come back with its https://app.lobehub.com/acceptance/<id> link. When the delivery was already verified on the real product earlier in the session, that skill's ingest path publishes the existing observations and artifacts directly — no re-run, no re-plan. Pure refactors or tooling changes with no user-visible outcome may skip it — state that in the PR body instead of leaving the line out.
6. Create PR with `gh pr create --base canary`
- Title:
<gitmoji> <type>(<scope>): <description> - Body: based on PR template (
.github/PULL_REQUEST_TEMPLATE.md) - Obey the
AGENT-INSTRUCTIONSHTML comments in that template. Keep them commented out, and do not copy them into the visible description. - Link related GitHub issues using magic keywords (
Fixes #123,Closes #123) - Link the LobeHub task if applicable (
LobeHub task: [T-<n>](url)) - Put the acceptance link (or the explicit skip reason) under Test in the Summary section.
- Follow the source-label, privacy, and AI assistance rules in PR Template below when creating or updating a PR. Do not request prompt disclosure or block the normal PR workflow waiting for consent to publish a conversation.
- Write the body to a temporary file and use
--body-fileto preserve formatting.
7. Link the PR to its acceptance
An acceptance round published before the PR existed carries no PR, and reusing that round is correct, so nothing else ever tells the acceptance about the PR. Right after gh pr create, record the link through the production publish environment. If step 1 reused a known acceptance and skipped the lookup, publish_lh is not defined yet: run Publish auth preflight now to define and verify it.
publish_lh acceptance link-pr <acceptanceId> "$(gh pr view --json url --jq .url)"
Do this for each PR in a stack; they share one acceptance. Skip it when the PR states that no acceptance is needed. A later round links itself only when its result.json names the PR (pullRequest); a PR inferred from the branch is recorded on the round but never linked. If the installed CLI lacks link-pr, or the server rejects it as unknown, mention that in the reply instead of retrying.
8. Open in browser
gh pr view --web