agentleFS
Cloud-PeekCloud-Peek/agent-skills/skills/pr-from-branch/SKILL.md

pr-from-branch

Skill1 starsChanged 4 months agoApache-2.0View on GitHub

Use when the user wants to draft a GitHub pull request title and body from the current branch, choose existing repo labels, and open the PR with gh after confirmation.

  • Commits and pushes

The file

We split this skill into the rules it gives an agent

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

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Verify first. If any check fails, stop and report what is missing.

    line 12
  2. Very specific:

    If gh is missing, direct the user to https://cli.github.com/ and gh auth login.

    line 20
  3. Distinctive:

    If the user provides a base branch argument, use it.

    line 26
  4. Very specific:

    Verify origin/<base> exists before diffing.

    line 29
  5. Distinctive:

    Stop and report if the checkout is detached, the current branch is the base branch, there are zero commits ahead of base, or the diff is …

    line 41
  6. Distinctive:

    Use a conventional-commits prefix only if recent merged PR titles use one.

    line 49
  7. Distinctive:

    Write from the diff, not just commit messages.

    line 82
  8. Distinctive:

    Only use existing repo labels:

    line 86
  9. Very specific:

    Do not run gh pr create until the user confirms.

    line 98
  10. Very specific:

    Write the approved body to a temp file and run gh pr create with one --label flag per confirmed label.

    line 102
  11. Distinctive:

    After success, print the PR URL.

    line 112

≈ “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

PR From Branch

Draft a pull request from the current git branch, show the draft to the user, and only create the PR after confirmation.

Prerequisites

Verify first. If any check fails, stop and report what is missing.

git rev-parse --is-inside-work-tree
gh --version
gh auth status

If gh is missing, direct the user to https://cli.github.com/ and gh auth login.

Gather Branch Context

Resolve the current branch and base branch.

  • If the user provides a base branch argument, use it.
  • Otherwise auto-detect the GitHub default branch, falling back to main, then master.
  • Fetch the base branch.
  • Verify origin/<base> exists before diffing.

Read:

git branch --show-current
git log --reverse --pretty=format:"%h %s%n%b%n---" "origin/<base>..HEAD"
git diff --stat "origin/<base>...HEAD"
git diff --name-only "origin/<base>...HEAD"
git diff "origin/<base>...HEAD"

Stop and report if the checkout is detached, the current branch is the base branch, there are zero commits ahead of base, or the diff is huge. For huge diffs, rely on stat, commit messages, touched paths, and sampled key files.

Draft

Title rules:

  • Imperative mood, sentence case, no trailing period.
  • Aim for about 50 characters; keep under about 72.
  • Use a conventional-commits prefix only if recent merged PR titles use one.
  • Include ticket references from the branch name when that matches repo convention.

Check recent style:

gh pr list --state merged --limit 10 --json title --jq '.[].title'

Body template:

## Summary

<1-3 sentences describing what changed and why>

## Changes

- <Meaningful changes, grouped by area when useful>

## Why

<Optional, only when the motivation is not obvious>

## Test plan

- <Specific commands, scenarios, and tests added>

## Notes

<Optional follow-ups, limits, or review notes>

Write from the diff, not just commit messages. Be specific and do not invent rationale.

Labels

Only use existing repo labels:

gh label list --limit 200 --json name --jq '.[].name'

Choose area labels by matching touched paths to existing labels. Always add size:patch when it exists; otherwise skip it and mention that in the draft.

Confirm Before Creating

Print the proposed title, body, and labels. Ask the user whether to open the PR as-is, edit it, or change base, draft status, or labels.

Do not run gh pr create until the user confirms.

Create

Write the approved body to a temp file and run gh pr create with one --label flag per confirmed label.

Offer --draft, --reviewer, --assignee @me, or --web when relevant. If the branch is not pushed, let gh push it or push first after user approval.

Handle edge cases explicitly:

  • PR already exists: offer gh pr view --web or gh pr edit.
  • Uncommitted changes: mention them and ask whether to commit or stash.
  • Branch behind base: mention it and offer to rebase or merge.

After success, print the PR URL.

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.