Open a PR
Turn a pushed feature branch into a reviewable PR. Idempotent: if a PR already exists for the branch, report it and stop - never open a second.
Steps
git branch --show-current- on a protected branch (default/integration), STOP; a PR is opened FROM a feature branch.Confirm the branch is pushed and current:
git rev-parse HEADequalsgit rev-parse @{u}- unpushed work goes throughgit-commit-pushfirst.Existing-PR check:
gh pr list --head <branch> --state open --json number,url --jq '.[0]'. Non-empty - report the URL and STOP (nothing to open).Resolve the target from profile
pr_target(defaultauto- the integration branch when one exists, else the default branch).Title: an explicit argument wins; else the latest commit subject (
git log -1 --pretty=%s). Honor profileartifact_languagefor title and body when set (e.g. write them in English even when the working language differs).Body: profile
pr_templatedecides which template applies -auto(default) fills the repo's own (.github/PULL_REQUEST_TEMPLATE.mdor.github/pull_request_template.md) when one exists,noneskips it even when present, which is the setting for a repo whose template is written for a human filling a web form. Either way, with no template in play use the pack defaultassets/pr-template.md. Fill the chosen template's sections honestly - real content per section, "None" where one genuinely does not apply; never leave its hint comments. When profilepr_risk_size: on, prepend the deterministic Risk/Size line (below).The section profile
verify_sectionnames (defaultHow to verify) is not optional: it states what a reviewer or QA runs to validate the result, not that CI passed, and it is the inputgit-verify-prexecutes. A PR that leaves it empty cannot earnai:verified- it never declared what "working" means.Open it:
gh pr create --base <target> --title <title> --body-file <file>(--body-fileavoids shell-quoting traps). On non-GitHub platforms use the profilecli(glab mr create, ...).Report the PR URL and number.
Risk & Size (only when profile pr_risk_size: on)
Compute both mechanically so the same diff always yields the same flags:
- Size from
git diff <target>...HEAD --shortstat: thresholds from profilepr_size_thresholds(defaultsmall <= 5 files & 50 lines; large >= 20 files or 400 lines; else medium). - Risk = the highest-matching category from profile
pr_risk_globs(path globs mapped to high / medium / low). No profile globs - skip Risk rather than guess.
State one value each, e.g. Risk: low | Size: small.
Verify
- Exactly one open PR for the branch; it targets the resolved base; the body has real content (no template hint comments left).
Scope / hand-off
- Committing/pushing first -
git-commit-push; driving the opened PR through its rounds -git-finalize-pr; merging -git-merge-pr.
Constraints
- One branch, one PR, for the life of the branch: never a second, and never a closed one reopened to carry different work.
- The verification section is never satisfied by "CI passes". It states what a person or agent does to observe the result, and
git-verify-prexecutes it later against the running change - a section written for nobody to execute produces a PR that cannot earnai:verified. - Never state a Risk level the globs did not produce: a measured flag and a guessed one read identically, and only one of them is worth acting on.