agentleFS
ricobergerricoberger/dotfiles/.agents/skills/github-pr-create/SKILL.md

github-pr-create

Skill19 starsChanged 34 days agoMITView on GitHub

Check whether a pull request already exists for the current branch. Create one if it does not, and keep its body up to date with the commits on the branch. The body is built one of two ways, depending on whether the repository defines a pull request template: - Template mode — a .github/PULL_REQUEST_TEMPLATE.md file exists. The PR body is built from that template (see Template Mode). - Commit mode — no template file exists. The PR body is built…

  • Commits and pushes

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 8 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈8

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Check whether a pull request already exists for the current branch.

    line 14
  2. Very specific:

    When .github/PULL_REQUEST_TEMPLATE.md exists, use it as the source of the PR body:

    line 27
  3. Distinctive:

    Start from the exact contents of the template file.

    line 30
  4. Distinctive:

    When updating an existing PR, refresh only the parts derived from commits (e.g.

    line 41
  5. Distinctive:

    When no template file exists, the pull request body is built from all commits on the branch.

    line 48
  6. Distinctive:

    Check for an existing pull request:

    line 96
  7. Distinctive:

    If no pull request exists (the command above fails), ask the user whether one should be created.

    line 102
  8. Distinctive:

    If a pull request already exists, refresh its body:

    line 113
  9. Distinctive:

    Leave the title unchanged unless the first commit's subject changed.

    line 132

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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

GitHub Pull Request Creation

Check whether a pull request already exists for the current branch. Create one if it does not, and keep its body up to date with the commits on the branch.

The body is built one of two ways, depending on whether the repository defines a pull request template:

  • Template mode — a .github/PULL_REQUEST_TEMPLATE.md file exists. The PR body is built from that template (see Template Mode).
  • Commit mode — no template file exists. The PR body is built from the branch's commit messages (see Commit Mode).

Template Mode

When .github/PULL_REQUEST_TEMPLATE.md exists, use it as the source of the PR body:

  • Start from the exact contents of the template file. Keep its headings, section order, comments, and checklist items intact.
  • Fill in the template's sections using information derived from the branch's commits — e.g. write the summary/description from the commit subjects and bodies, and tick any checklist items that the commits clearly satisfy. Do not paste the raw commit log in place of the template; preserve the template's structure.
  • For sections you cannot confidently fill from the commits, ask the user for the missing information and use their answer to complete the section. If the user does not provide it, leave the section as it is in the template (keep the placeholder text or empty checkboxes) so the author can complete it later.
  • When updating an existing PR, refresh only the parts derived from commits (e.g. the description) so they reflect every commit on the branch. Preserve any content a human already filled into other sections; do not overwrite the whole body back to the blank template.

Commit Mode

When no template file exists, the pull request body is built from all commits on the branch. Each commit contributes its full message (subject line, blank line, body), and commits are separated from one another by blank lines, in chronological order (oldest first):

subject of commit 1

body of commit 1


subject of commit 2

body of commit 2

The body must be built from the exact bytes of each commit message, including the 72-character wrapping. Do not re-flow, unwrap, or re-format the text. Always pipe it into --body-file - (inline --body "..." risks stripping or normalizing the hard line breaks).

Steps

  1. Determine the base branch:

    base="$(gh pr view --json baseRefName --jq .baseRefName 2>/dev/null \
      || git remote show origin | sed -n 's/.*HEAD branch: //p')"
  2. Build the body into a temporary file, choosing the mode by whether a template exists:
    • Template mode (.github/PULL_REQUEST_TEMPLATE.md exists): start from the template and fill its sections from the branch commits, as described in Template Mode. Use the commits for reference:

      git log --reverse --format='%B%n' "origin/$base..HEAD"
    • Commit mode (no template): build the body from the raw commit messages. %B is a commit's raw message (subject + blank line + body), and the trailing %n%n separates consecutive commits with a blank line:

      git log --reverse --format='%B%n' "origin/$base..HEAD"
  3. Check for an existing pull request:

    gh pr view --json url
  4. If no pull request exists (the command above fails), ask the user whether one should be created. Only continue if the user confirms. Create it as a draft, using the first commit's subject as the title and the body built in step 2 (pipe the body in via --body-file -):

    title="$(git log --reverse --format='%s' "origin/$base..HEAD" | head -n1)"
    # <body-source> is the template-filled body or the commit log, per step 2.
    <body-source> | gh pr create --draft --title "$title" --body-file -
  5. If a pull request already exists, refresh its body:

    • In commit mode, regenerate the body so it includes every commit on the branch (this matters when the branch has more than one commit, or after adding commits to an existing pull request):

      git log --reverse --format='%B%n' "origin/$base..HEAD" | gh pr edit --body-file -
    • In template mode, refresh only the commit-derived sections of the existing body and preserve everything the author already filled in, then update it:

      # <updated-body> keeps the template structure and human-authored content,
      # refreshing only the commit-derived sections.
      <updated-body> | gh pr edit --body-file -

    Leave the title unchanged unless the first commit's subject changed. If a single commit has no body, its contribution is just the subject line.

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.