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
- andymai/brepjstheir own version, first seen Oct 9, 2026
- leochiu-a/git-pr-aitheir own version, first seen Oct 5, 2026
- whz1106/whz-harnesstheir own version, first seen Sep 24, 2026
- thapar25/claude-skillstheir own version, first seen Aug 12, 2026
- Bridev04/clauderailtheir own version, first seen May 17, 2026
Other versions5 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 5
- andymai/brepjs★ 151same name
- leochiu-a/git-pr-ai★ 80same name
- whz1106/whz-harness★ 2same name
- Bridev04/clauderail★ 0same name
- thapar25/claude-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository9 other files it gives its agents.
- agent-observabilitySkill
- data-qualitySkill
- langgraph-patternsSkill
- llm-evalsSkill
- mcp-server-builderSkill
- ml-experiment-trackingSkill
- prompt-engineeringSkill
- python-qualitySkill
- rag-pipelinesSkill
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
- Distinctive: line 16
Before opening or updating a PR (yours or one an agent produced).
- Very specific: line 60
Use assets/pull_request_template.md (copy to .github/pull_request_template.md).
- Very specific: line 73
After a rebase, help reviewers with git range-diff origin/main@{1} @{1} @ (or GitHub's "compare" link).
- Very specific: line 78
Check out and run it: when behavior matters: gh pr checkout 123, run tests, try the feature.
- Distinctive: line 111
Keep agent PRs as small as human ones.
- Very specific: line 114
Keep repo instructions (AGENTS.md, CLAUDE.md, .cursor/rules) current so agents follow the same conventions as humans.
“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.
Files
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, orghstackmake this easier; plain branches withgit rebase --update-refswork 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 withgit 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 wouldscripts/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
- 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.
- Check out and run it when behavior matters:
gh pr checkout 123, run tests, try the feature. - Review in order of cost: correctness and security, then design and API surface, then tests, then readability. Use the
code-reviewerandsecurity-auditoragents for a structured pass. - Label every comment so the author knows what blocks merge:
| Label | Meaning |
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 |
- 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?"). - Approve when it is better than main and safe, not when it is how you would have written it.
Git Safety Toolkit
| Situation | Command |
| Update branch onto latest main | git fetch origin && git rebase origin/main |
| Squash fixups into their targets | git rebase -i --autosquash origin/main |
| Push rewritten history safely | git push --force-with-lease --force-if-includes (never plain --force on shared branches) |
| Compare a branch before/after rebase | git range-diff @{u} @ or git range-diff main old-branch new-branch |
| Undo the last commit, keep changes | git reset --soft HEAD~1 |
| Recover "lost" commits after a bad reset/rebase | git reflog, then git branch rescue <sha> |
| Find the commit that broke a test | git bisect start HEAD <good-sha> && git bisect run uv run pytest tests/test_x.py -q |
| Revert a merged PR | git revert -m 1 <merge-sha> |
| Remove a committed secret | Rotate the secret first, then purge with git filter-repo; deleting it in a new commit is not enough |
| Resolve repeated conflicts once | git 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.pyclean (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
--forceinstead 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
- Conventional Commits: https://www.conventionalcommits.org/en/v1.0.0/
- Google engineering practices, code review: https://google.github.io/eng-practices/review/
- Conventional Comments: https://conventionalcomments.org/
- Git docs,
git rebase --autosquashandrange-diff: https://git-scm.com/docs/git-rebase, https://git-scm.com/docs/git-range-diff - git-filter-repo: https://github.com/newren/git-filter-repo
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
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.

