
PR Description Writer — Summarize branch changes
Point it at a branch diff and it reads the files — the change type, the per-area table of what changed, the line counts, and the test files touched — and writes a reviewer-ready pull request description with a summary and a review checklist. Deterministic, so it fits a pre-commit hook or CI; it never commits, pushes, or makes network calls. #Ingénierie
The problem
The branch is done; the PR description is a blank box. People paste the last commit message, or write "various fixes," and the reviewer has to read the whole diff to find out what actually changed, where, and whether it is tested. A thin description slows the review and hides the risky file in a wall of green. Writing a good one by hand every time is tedious, so it does not happen.
How it works
- Reads a unified diff from a file, standard input, or
git diff BASE...HEAD. - Parses the diff deterministically — no code is run, no network is touched:
- Changed files — each
diff --githeader, with its kind (added, modified, deleted, renamed, binary) read from the file-mode and rename markers. - Line counts — counts the
+and-body lines per file (the+++/---headers are excluded). - Change type — one of
feat,fix,docs,test,refactor,chore, chosen from the files: all-docs →docs, all-tests →test, a new source file →feat, removal-heavy →refactor, in-place edits →fix. - Areas — groups files by top-level directory into named sections (Source, Tests, Docs, Scripts, Config, CI, …).
- Tests touched — lists the changed files whose path looks like a test.
- Changed files — each
- Renders a markdown PR description: title, type, summary, a per-area file table, the tests section, and a reviewer checklist.
The scan is deterministic: the same diff always produces the same description, so it fits in a pre-commit hook or CI step as well as at the keyboard.
Usage
# from a diff file
python3 scripts/pr_description_writer.py --diff examples/sample.diff
# from a pipe (nothing is run but the parse)
git diff main...HEAD | python3 scripts/pr_description_writer.py --stdin
# let the tool run read-only "git diff main...HEAD"
python3 scripts/pr_description_writer.py --git --base main --head HEAD
# the raw scan as JSON, for your own tooling
python3 scripts/pr_description_writer.py --diff examples/sample.diff --json
# a gate: exit 1 if the diff changed no test file
python3 scripts/pr_description_writer.py --diff examples/sample.diff --require-tests
Other options: --title "..." (set the PR title; the default is built from the type and file count), --base / --head (refs for --git).
Limits (read these)
- The description is a scaffold, not the intent. The tool reports what the diff shows — which files, how large, which type. It cannot write why the change was made or what the reviewer should worry about. Edit the summary and tick the checklist yourself; the structure is the time-saver.
- The type is a heuristic, not a verdict.
featversusfixis inferred from the shape of the diff (a new file, in-place edits). A refactor that adds a file will read asfeat. Override the title and type in your own words when the shape misleads. - Parsing is by diff text, not by running git history. The tool reads the diff you give it (or the read-only
git diffit runs). It never commits, pushes, checks out, or edits your tree, and makes no network calls. Binary files are listed but not line-counted. - Renames are shown as
old → new. Files are grouped by their top-level directory; a known directory gets a friendly name, an unknown one is used as-is.


