# Git Open Pr

> Opens a pull request for the current branch against its target, filling the repo's template. Driving it to green afterwards is git-finalize-pr.

- Skill: `ainova-systems/git-open-pr` (Agent Skill, multi-file: 2 files)
- Install (CLI): `npx skillmds@latest add ainova-systems/git-open-pr`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ainova-systems/git-open-pr/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ainova-systems (https://skillmd.com/u/ainova-systems)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/ainova-systems/git-open-pr

---


# 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

1. `git branch --show-current` - on a protected branch (default/integration), STOP; a PR is opened FROM a feature branch.
2. Confirm the branch is pushed and current: `git rev-parse HEAD` equals `git rev-parse @{u}` - unpushed work goes through `git-commit-push` first.
3. 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).
4. Resolve the target from profile `pr_target` (default `auto` - the integration branch when one exists, else the default branch).
5. Title: an explicit argument wins; else the latest commit subject (`git log -1 --pretty=%s`). Honor profile `artifact_language` for title and body when set (e.g. write them in English even when the working language differs).
6. Body: profile `pr_template` decides which template applies - `auto` (default) fills the repo's own (`.github/PULL_REQUEST_TEMPLATE.md` or `.github/pull_request_template.md`) when one exists, `none` skips 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 default `assets/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 profile `pr_risk_size: on`, prepend the deterministic Risk/Size line (below).

   The section profile `verify_section` names (default `How 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 input `git-verify-pr` executes. A PR that leaves it empty cannot earn `ai:verified` - it never declared what "working" means.
7. Open it: `gh pr create --base <target> --title <title> --body-file <file>` (`--body-file` avoids shell-quoting traps). On non-GitHub platforms use the profile `cli` (`glab mr create`, ...).
8. 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 profile `pr_size_thresholds` (default `small <= 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-pr` executes it later against the running change - a section written for nobody to execute produces a PR that cannot earn `ai: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.

