agentleFS
leroyguillaumeleroyguillaume/claude/pr-conventions/SKILL.md

pr-conventions

Skill7 starsChanged 3 days agoMITView on GitHub

Pull requests and GitLab merge requests (`gh`, `glab`): rebasing, stacks, drafts, source-branch deletion, title and body. TRIGGER when: opening a PR or MR (`gh pr create`, `glab mr create`, an API call that creates one); marking one ready (`gh pr ready`, `glab mr update --ready`, dropping `Draft:` from an MR title); changing its base or target branch; opening, rebasing or retargeting a stack of dependent PRs or MRs; writing a PR or MR title or description. SKIP when: GitHub PR labels and release notes (`github-pr-conventions`), or repo settings (`github-repo-settings`). On GitHub, load `github-pr-conventions` alongside.

  • Commits and pushes

1 other project uses a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 2 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Very specific:

    Before gh pr create / glab mr create, not after a reviewer trips over a conflict marker.

    line 35
  2. Distinctive:

    If the rebase conflicts, resolve it and re-run the tests and the linters before opening the PR — a conflict resolution is fresh code that …

    line 53
  3. Distinctive:

    If a stacked PR merged into its parent anyway, its change now ships with the parent: move its closing keyword into the parent's description …

    line 146
  4. Very specific:

    On GitLab, carry the Changelog: trailer: when the project's release notes read it (gitlab-ci-conventions): with squash merges, it goes in …

    line 160

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Pull request conventions (gh and glab)

GitLab calls a pull request a merge request (MR), and its base branch the target branch. Everything here applies to both; where the command differs, the glab one stands beside the gh one. Labels on GitHub are github-pr-conventions.

Rebase onto its base before opening it

A PR is opened from a branch that has just been rebased onto its up-to-date base branch — main, or the parent's branch for a stacked PR (see below) — always, even when the branch is an hour old and the diff looks unrelated to everything that landed since:

git fetch origin
git rebase origin/main

Before gh pr create / glab mr create, not after a reviewer trips over a conflict marker. What it buys, and why "it'll merge fine anyway" is not a reason to skip it:

  • The PR's diff is the change and nothing else. A branch cut from a stale main drags everything that moved in between into the comparison, and the reviewer spends their attention telling the two apart.
  • CI runs against the code that will actually be merged. Green on a three-week-old base says nothing about green on today's main; the failure then surfaces after the merge, where it is everybody's problem instead of mine.
  • Conflicts get resolved by whoever wrote the code, while the reasons are still fresh, rather than by whoever hits the merge button.

Rebase, never merge main into the branch. A Merge branch 'main' into … commit carries no information, and it makes the branch impossible to read as a series of changes.

If the rebase conflicts, resolve it and re-run the tests and the linters before opening the PR — a conflict resolution is fresh code that nothing has checked yet. On a branch that was already pushed, force-push with --force-with-lease, never a bare --force.

A merge deletes its source branch

Every GitLab MR is opened with --remove-source-branch, whatever the project's default says — without it, glab mr create falls back to the project setting, and merged branches pile up on the remote:

glab mr create --remove-source-branch --target-branch main --source-branch <branch> …

Through the API, that is remove_source_branch: true. On an MR opened without it, check before fixing it: glab mr update --remove-source-branch toggles the option, so running it on an MR that already has it turns it off.

glab mr view <iid> -F json --jq .force_remove_source_branch
glab mr update <iid> --remove-source-branch

Stacked MRs are safe: when a parent merges and its branch is deleted, GitLab retargets the MRs based on it onto the parent's own target branch.

GitHub has no per-PR flag: the repo's head-branch auto-deletion does it (github-repo-settings). On either platform, a branch the merge left behind goes in CLAUDE.md's post-merge cleanup.

A stacked PR is opened as a draft

A PR whose base is another PR's branch — not the default branch — is opened as a draft, and stays a draft until everything under it has merged:

gh pr create --draft --base <parent-branch> --head <branch> …
glab mr create --draft --remove-source-branch --target-branch <parent-branch> --source-branch <branch> …

On GitLab, draft status is the Draft: title prefix: a title edit that drops it — in the UI, glab mr update --title or the API — marks the MR ready.

The reason is the merge button. On a stacked PR it merges into the parent's branch, not into the default branch:

  • The change silently folds into the PR below it, which then carries two changes under one title and one description.
  • Its closing keyword never fires. Closes #123 only acts on a merge into the default branch, so the issue stays open with nothing left to close it.

Draft status is what makes that button unavailable while the stack is waiting. A draft leaves the stack's dependency visible, and gets a normal review in the meantime. Say in each stacked PR's description which PR it sits on.

Mark it ready only when its base is the default branch again: the parent has merged, the PR has been retargeted, and the branch has been rebased onto it (see above; with squash merges, git rebase --onto origin/main <old-parent-tip>, so the parent's pre-squash commits are dropped):

gh pr edit <number> --base main
gh pr ready <number>
glab mr update <iid> --target-branch main
glab mr update <iid> --ready

Read the base before marking anything ready — one PR, or every PR of a stack after rebasing it, one by one; never a batch marked ready from memory:

gh pr view <number> --json baseRefName --jq .baseRefName
glab mr view <iid> -F json --jq .target_branch

Anything but the default branch stays a draft. Only the bottom PR of a stack, the one based on the default branch, is ever ready for review.

A PR with others stacked on it tells their owners when it moves — rebased, force-pushed, or merged once the user says so — so they rebase in turn. When another session owns them, that goes as a message (herdr-delegation), not as a poll on their side.

If a stacked PR merged into its parent anyway, its change now ships with the parent: move its closing keyword into the parent's description before the parent merges, so the issue still closes.

Title and body

  • The title follows the repo's commit-subject style (read git log --oneline): a squash merge makes it the commit subject on the default branch.
  • A fix for a publicly known vulnerability names its ID in the title (CVE-YYYY-NNNNN, or the GHSA-… ID when there is no CVE): the title is the release-notes line users read to decide whether to upgrade. It lands in the notes' security section: the security label on GitHub (github-pr-conventions), Changelog: security on GitLab.
  • On GitLab, carry the Changelog: trailer when the project's release notes read it (gitlab-ci-conventions): with squash merges, it goes in the MR's squash commit message, or the release notes miss the change.
  • Link the issue it resolves with Closes #123 in the body (Closes group/project#123 for an issue in another GitLab project), so the merge into the default branch closes it. Never close an issue by hand on the user's behalf.
  • A follow-up spotted while opening the PR goes in the body as Follow-up: #123, after the issue is opened (see github-issue-conventions) — never as a comment in the code.
  • A breaking change says what breaks, and how to migrate, in the body — a removed or renamed API, CLI flag, env var, config key or chart value; a changed default, wire format or schema that needs a migration; a dropped platform or version. Anything that forces a user to change something to upgrade.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.