agentleFS
kaushik-hollakaushik-holla/agent-skills/skills/git-pr-workflow/SKILL.md

git-pr-workflow

Skill2 starsChanged 12 days agoMITView on GitHub

Ship small, reviewable pull requests and review others' PRs well, covering branch and commit hygiene with Conventional Commits, stacked PRs, writing PR descriptions, self-review, reviewer comment taxonomy, safe history rewriting (rebase, autosquash, force-with-lease, range-diff), recovery with reflog and bisect, and etiquette for AI-generated code. Includes a pre-flight script that catches secrets, conflict markers, debug leftovers, missing tests, oversized diffs, and messy commits before you push. Use when preparing, splitting, describing, or reviewing a pull request, cleaning up commit history, recovering from a git mistake, or setting team PR conventions.

  • Reads credentials
  • Deletes or force-pushes
  • Commits and pushes

5 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

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

  • 0

    Common

    Most of the 5 edited versions we read keep these.

  • 2

    Distinctive

    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:

    Before opening or updating a PR (yours or one an agent produced).

    line 16
  2. Very specific:

    Use assets/pull_request_template.md (copy to .github/pull_request_template.md).

    line 60
  3. Very specific:

    After a rebase, help reviewers with git range-diff origin/main@{1} @{1} @ (or GitHub's "compare" link).

    line 73
  4. Very specific:

    Check out and run it: when behavior matters: gh pr checkout 123, run tests, try the feature.

    line 78
  5. Distinctive:

    Keep agent PRs as small as human ones.

    line 111
  6. Very specific:

    Keep repo instructions (AGENTS.md, CLAUDE.md, .cursor/rules) current so agents follow the same conventions as humans.

    line 114

“Common” is measured: kept by at least 6 in 10 of the 5 edited versions of this file we could read. “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

Git and Pull Request Workflow

A pull request is a request for someone else's attention. Make it small, explain why it exists, prove it works, and make the reviewer's first five minutes productive. The same rules apply when an AI agent wrote the code: you are the author of record.

When To Use

  • Before opening or updating a PR (yours or one an agent produced).
  • Splitting a large change into reviewable pieces.
  • Reviewing someone else's PR.
  • Cleaning up history, resolving a bad rebase, or finding the commit that broke something.
  • Setting or documenting team conventions.

Author Workflow

1. Scope the change

  • One logical change per PR. Refactors, formatting, and dependency bumps go in separate PRs from behavior changes.
  • Aim for under ~400 changed lines (excluding lockfiles and generated files). Review quality drops sharply on larger diffs.
  • For big features, stack PRs: feat/1-schema -> feat/2-api -> feat/3-ui, each mergeable on its own (feature flags help). Tools like Graphite, git-branchless, or ghstack make this easier; plain branches with git rebase --update-refs work too.

2. Commit with intent

Conventional Commits make history searchable and enable automated changelogs and versioning:

feat(retrieval): add hybrid BM25 + vector search with RRF

Dense-only retrieval missed exact product codes (recall@10 0.71 on the
SKU slice). Hybrid with reciprocal rank fusion raises it to 0.93 with no
change on paraphrase queries. Reranker unchanged.

Refs: #482
  • Subject: type(scope): imperative summary, at most ~72 chars. Types: feat, fix, docs, refactor, perf, test, build, ci, chore, revert; ! marks a breaking change.
  • Body: why, and what you measured. The diff already shows what.
  • While iterating, commit freely with git commit --fixup <sha>; clean up before review with git rebase -i --autosquash origin/main.

3. Self-review before anyone else

git fetch origin && git rebase origin/main
python scripts/pr_preflight.py --run "uv run pytest -q" --run "uvx ruff check ."
git diff origin/main...HEAD          # read your own diff top to bottom, as a reviewer would

scripts/pr_preflight.py reports PR size, possible secrets and .env files, conflict markers, breakpoint() / console.log / .only leftovers, notebooks with outputs, large binaries, source changes without tests, and wip / fixup! commits, then runs your checks. Fix every error; consciously accept or fix each warning.

4. Write the description

Use assets/pull_request_template.md (copy to .github/pull_request_template.md). A good description has:

  • What and why in two sentences, with the issue link.
  • How, including rejected alternatives and where the reviewer should start reading.
  • Risk and rollout: compatibility, flags, migrations, rollback plan.
  • Evidence: tests run, screenshots, trace links, eval deltas for prompt or model changes.

Open as a draft early if you want feedback on direction; mark ready only when CI is green and the self-review is done.

5. Respond to review

  • Reply to every comment: fixed (with the commit), disagree (with a reason), or follow-up (with an issue link).
  • Push review fixes as new commits so reviewers can see what changed; squash at merge or autosquash before the final approval, per team convention.
  • After a rebase, help reviewers with git range-diff origin/main@{1} @{1} @ (or GitHub's "compare" link).

Reviewer Workflow

  1. Read the description first, then decide whether the approach is right before nitpicking lines. A wrong approach is cheaper to flag now than after 30 line comments.
  2. Check out and run it when behavior matters: gh pr checkout 123, run tests, try the feature.
  3. Review in order of cost: correctness and security, then design and API surface, then tests, then readability. Use the code-reviewer and security-auditor agents for a structured pass.
  4. Label every comment so the author knows what blocks merge:
LabelMeaning
blocking:Must change before merge (bug, security, data loss, broken contract)
suggestion:Better option; author decides
question:I don't understand; may reveal a bug or a missing comment
nit:Style or taste; never blocks
praise:Call out good work; it teaches as much as criticism
  1. Be specific and kind: quote the line, explain the risk, propose a fix ("blocking: this retries non-idempotent POSTs; a timeout after success double-charges. Could we pass an idempotency key?").
  2. Approve when it is better than main and safe, not when it is how you would have written it.

Git Safety Toolkit

SituationCommand
Update branch onto latest maingit fetch origin && git rebase origin/main
Squash fixups into their targetsgit rebase -i --autosquash origin/main
Push rewritten history safelygit push --force-with-lease --force-if-includes (never plain --force on shared branches)
Compare a branch before/after rebasegit range-diff @{u} @ or git range-diff main old-branch new-branch
Undo the last commit, keep changesgit reset --soft HEAD~1
Recover "lost" commits after a bad reset/rebasegit reflog, then git branch rescue <sha>
Find the commit that broke a testgit bisect start HEAD <good-sha> && git bisect run uv run pytest tests/test_x.py -q
Revert a merged PRgit revert -m 1 <merge-sha>
Remove a committed secretRotate the secret first, then purge with git filter-repo; deleting it in a new commit is not enough
Resolve repeated conflicts oncegit config rerere.enabled true

AI-Assisted PRs

  • The human opening the PR owns it: read every line, run it, and be able to explain it.
  • Keep agent PRs as small as human ones; ask the agent to split work (one concern per PR) rather than reviewing a 3,000-line drop.
  • Disclose meaningful AI assistance in the description when your team or project asks for it.
  • Watch for agent-specific failure modes: invented APIs, tests that assert the implementation rather than behavior, silently weakened checks (skipped tests, loosened types, # noqa), and unrelated "drive-by" edits.
  • Keep repo instructions (AGENTS.md, CLAUDE.md, .cursor/rules) current so agents follow the same conventions as humans.

Checklist

  • One logical change, under ~400 lines, or split / stacked
  • Rebased on the latest target branch; history clean (no wip / fixup!)
  • Conventional Commit subjects with "why" in the body
  • pr_preflight.py clean (or warnings consciously accepted)
  • Tests added or updated; CI green
  • Description covers what, why, how, risk, and evidence
  • Every review comment answered

Common Mistakes

  • "Misc fixes" PRs mixing refactors, formatting, and behavior changes.
  • Force-pushing over a teammate's commits with --force instead of --force-with-lease.
  • Deleting a leaked key in a follow-up commit without rotating it.
  • Reviewing line by line before checking whether the approach is right.
  • Unlabeled review comments, leaving the author guessing what blocks merge.
  • Merging an agent's PR because CI is green without reading the diff.

References

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.