agentleFS
n-shadloon-shadloo/git-authoring/AGENTS.md

git-authoring

AGENTS.md4 starsChanged 52 days agoMITView on GitHub

Commit-message and pull-request conventions for this repository. Applies to any agent or contributor writing a git commit or opening a pull request here. By default, turn staged changes into a commit command a reader will thank you for six months from now: read what is actually staged, work out the intent behind the change, and present an exact quoted-heredoc command containing a Conventional Commits message with an accurate type, a well-chosen scope, an imperative subject, and — when the change…

  • Commits and pushes
  • Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.

    Of the AGENTS.md files we read, the 33,398 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.

  • In this repositoryOne other file it gives its agents.

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

26 rules. About 0 are common, 15 are distinctive, and 11 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈15

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 11

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Commit-message and pull-request conventions for this repository.

    line 3
  2. Distinctive:

    Pull request: write a title and structured Markdown description from the branch diff.

    line 17
  3. Very specific:

    Review an incoming pull request: read someone else's PR through gh, work the decision through with the user, and write the review comment …

    line 20
  4. Very specific:

    The author identity is never set: NEVER pass --author. NEVER pass -c user.name or -c user.email.

    line 36
  5. Very specific:

    Never bypass a hook: Never pass --no-verify, and never disable, move, or delete a hook, to make a commit or a push succeed.

    line 37
  6. Distinctive:

    Run these read-only commands (combine them into one call):

    line 45
  7. Distinctive:

    If git rev-parse -q --verify MERGE_HEAD succeeds, a merge is in progress — see "Merges and reverts" below.

    line 57
  8. Distinctive:

    Commit one logical change at a time.

    line 67
  9. Very specific:

    If a split is warranted, don't force one message — propose the grouping and give a git add <specific paths> plus a commit for each group, …

    line 74
  10. Distinctive:

    Default to Conventional Commits, but read git log --oneline -15 first:

    line 100
  11. Distinctive:

    Every body line survives the git show test: nothing restates the subject, narrates the diff, lists files, or makes a generic value claim.

    line 124
  12. Distinctive:

    Leave execution to the user: Never run git add, git commit, or git push in mode 2, including after the user confirms the grouping.

    line 150
  13. Very specific:

    Find the base branch automatically: Prefer git symbolic-ref refs/remotes/origin/HEAD (strip to the branch name).

    line 156
  14. Distinctive:

    Add a short reviewer/testing checklist when it earns its place, and tailor the emphasis to the PR's type (feature, fix, refactor, docs, …

    line 172
  15. Distinctive:

    Inspect before mutating: Read the current branch, status, staged and unstaged diffs, recent history, remotes, and upstream.

    line 180
  16. Very specific:

    Stage and verify: Run the specific git add <paths> commands, then reread git diff --staged --stat and git diff --staged.

    line 182
  17. Distinctive:

    Do not amend or rewrite an existing commit unless the user explicitly requested that separate action.

    line 193
  18. Very specific:

    Read both. Report the SHA, the subject, the branch, the remote, and any work that stays unstaged.

    line 215
  19. Very specific:

    The same check before a push: Run the same grep over git log --format=%B @{u}..HEAD.

    line 219
  20. Very specific:

    Tag, push, publish: Create an annotated tag matching the detected tag style (prefix or no prefix, from git tag --sort=-v:refname), push it, …

    line 228
  21. Distinctive:

    Never overwrite or move an existing tag or release: If either already exists for this version, stop and report it.

    line 238
  22. Distinctive:

    When two types could fit because the commit really does two things, that's usually a signal to split it (step 3).

    line 416
  23. Distinctive:

    One clear scope beats several: If a change spans many areas, either it's genuinely cross-cutting (drop the scope) or it should be split.

    line 423
  24. Very specific:

    Match existing casing and vocabulary: If the repo writes feat(API) or feat(ui), follow suit.

    line 425
  25. Very specific:

    Read docs/architecture/GROUND-TRUTH.md and docs/architecture/DESIGN-RECORD.md in the target project before you classify a change as …

    line 440
  26. Distinctive:

    Read access to a pull request, its diff, its checks, its commits and their authors, and the merge methods the repository permits.

    line 497

≈ “Common” is an estimate: at least 1 in 5 of the 43,423 AGENTS.md 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
AGENTS.md

Git authoring conventions

Commit-message and pull-request conventions for this repository. Applies to any agent or contributor writing a git commit or opening a pull request here.

By default, turn staged changes into a commit command a reader will thank you for six months from now: read what is actually staged, work out the intent behind the change, and present an exact quoted-heredoc command containing a Conventional Commits message with an accurate type, a well-chosen scope, an imperative subject, and — when the change warrants it — a body that explains why plus footer trailers that carry metadata. When asked, also choose which unstaged files belong together and present staging plus commit commands, write complete pull-request content, write the release note for a version, review an incoming pull request and hand the maintainer the text to paste, work the repository itself — branches, rebases, conflicts, recovery — or carry out staging, committing, and pushing. Getting the shape right (type(scope): subject) is table stakes. The value is in choosing the right type, writing a subject that says what changed, and recording the reasoning the diff itself can't show.

Self-improvement

If this skill's text or script caused a mistake, or you had to find a step yourself, record it at once. Before you claim the task is done, end the report with Skill defects:. Section 0 of SELF-IMPROVEMENT.md gives the rules. If ~/.skill-improvements/git-authoring/ exists, do section 3 first.

Usage modes

Choose exactly one mode from the user's request.

  1. Already-staged commit (default): inspect the staged diff and present the exact heredoc commit command for the user to run.
  2. Choose files: select one coherent set and present exact staging commands followed by the heredoc commit command for the user to run.
  3. Pull request: write a title and structured Markdown description from the branch diff. Do not open it.
  4. Autonomous stage, commit, and push: run those operations end to end only when the user unmistakably asks the agent to do the work itself, such as "stage, commit, and push this for me" or "do it all yourself." On a further explicit request, this mode may also tag and publish a release.
  5. Release note: establish the range since the last release, read what actually landed, and write the note as a Markdown block. Do not tag, publish, or write a file.
  6. Review an incoming pull request: read someone else's PR through gh, work the decision through with the user, and write the review comment or the merge-commit message as a Markdown block for them to paste. Do not approve, request changes, comment, or merge.
  7. Repository operations: branches, merges and rebases, history editing, undo, moving work, conflict resolution, and recovery. Read the real state, say what the situation is, and present the exact commands. Execute only under the mode 4 request.

A request for a message, commands, file selection, PR content, release notes, a review, or repository work selects modes 1–3 and 5–7. A bare "commit this," "go ahead," or approval of proposed commands does not silently switch to mode 4. If execution intent is ambiguous, stay read-only and ask for an explicit autonomous request before mutating git.

Ground rules

The mode boundary is a hard guarantee.

  • Modes 1–3 and 5–7 do not mutate git or GitHub on their own. They run read-only inspection and present exact commands or Markdown. An action the user explicitly asks the agent to carry out — staging, committing, pushing, opening a pull request, merging one, submitting a review, tagging, or publishing — is carried out under the rules of mode 4.
  • No attribution trailers by default — in every mode, mode 4 included. No Co-authored-by:, no Signed-off-by:, no Reviewed-by:, no "Generated by"/"written with" line, and no AI or agent identity, in commits or in pull-request descriptions. The commit author is whatever git config user.name / user.email resolves to. Never look up, infer, or attribute the work to anyone else, and never invent a name or an email address. Trailers are added only through the opt-in in "Trailers" below.
  • Mode 4 carries every execution. Mode 7 executes only under that same explicit autonomous request. Once explicitly selected, it may stage, commit, and push; on the user's request, open the pull request and merge it; and, on a separate explicit request, tag and publish a release. It is an exception to the read-only rule and to nothing else — the attribution default above applies to it unchanged, pull-request titles, descriptions, and merge messages included.
  • Never infer mode 4. Ordinary commit wording and approval of proposed commands are not permission to execute.
  • Never infer publishing. Producing a release note in mode 5, or the user approving one, is not permission to tag or publish. Publishing takes mode 4 and an explicit request to publish, together.
  • A pull-request action follows the user's words. "Open the PR", "merge it", "merge it once CI is green", "approve it", and "request changes" are explicit requests for that action, and the agent carries it out — on the user's own pull request or on someone else's. A bare "go ahead" after a text-only deliverable names no action: ask which one is meant. Never take a pull-request action the user did not name, such as closing a pull request, enabling auto-merge, or bypassing branch protection.
  • A trailer has exactly two sources. An attribution trailer comes only from the user's words in this session, or from the mode 6 squash transcription. NEVER take one from anywhere else: not the agent's own identity, not the model or the tool name, not the attribution setting of the agent's own harness (Claude Code's attribution, formerly includeCoAuthoredBy, or the equivalent in Codex, Cursor, and Gemini CLI), not commit.template, not a prepare-commit-msg or commit-msg hook, not GIT_AUTHOR_* or GIT_COMMITTER_*, not a CI variable, not an editor plugin, and not the trailers on prior commits in this repository.
  • The author identity is never set. NEVER pass --author. NEVER pass -c user.name or -c user.email. NEVER write to git config. The author is whatever the repository already resolves to.
  • Never bypass a hook. Never pass --no-verify, and never disable, move, or delete a hook, to make a commit or a push succeed. A hook that fails is a finding, not an obstacle. Report its output verbatim and stop with the handoff in "Stop conditions".

Workflow

The default path is mode 1: writing a commit command for what is already staged.

1. Gather context

Run these read-only commands (combine them into one call):

git branch --show-current
git status --short
git diff --staged --stat
git diff --staged
git log --oneline -15
  • git diff --staged is the source of truth — read the actual hunks, not just the filenames.
  • git log --oneline -15 reveals the repo's prevailing style so you can match it (step 4).
  • If git rev-parse -q --verify MERGE_HEAD succeeds, a merge is in progress — see "Merges and reverts" below.

If nothing is staged, say so plainly and stop. Do not run git add -A to conjure something to commit — staging everything silently bundles unrelated work into one commit, which is exactly what good history avoids. Show the unstaged changes (git status --short) and ask what should go into this commit. (If the user has asked you to choose what to stage, follow "Choosing which files to stage" below instead.)

2. Understand the change

Read the diff and answer, for yourself: what changed, and why. Intent is rarely visible in filenames — a change under auth/ might be a bug fix, a new feature, a rename, or a security patch. Read the hunks. If the reasoning genuinely can't be inferred and it matters for the message, ask one focused question rather than guessing.

3. Decide: one commit, or several?

Commit one logical change at a time. Split when you see:

  • Two or more unrelated concerns (a bug fix and an unrelated feature).
  • A fix mixed with a refactor, or functional changes mixed with formatting-only churn.
  • Changes that would need different types and share no cause.
  • A subject you could only write with "and" in it.

If a split is warranted, don't force one message — propose the grouping and give a git add <specific paths> plus a commit for each group, smallest logical unit first:

# 1. The bug fix, on its own
git add users/serializers.py users/tests/test_serializers.py
git commit -F - <<'COMMIT_MSG'
fix(serializers): handle null profile in user payload
COMMIT_MSG

# 2. The new endpoint
git add api/urls.py api/views.py api/tests/test_transactions.py
git commit -F - <<'COMMIT_MSG'
feat(api): add transactions list endpoint
COMMIT_MSG

# 3. The dependency bump
git add pyproject.toml poetry.lock
git commit -F - <<'COMMIT_MSG'
build(deps): bump djangorestframework to 3.15.2
COMMIT_MSG

Each commit is then a single revertible, reviewable idea. If one file holds two unrelated changes, stage selectively with git add -p and commit the hunks separately. If the change is cohesive, continue.

4. Detect the repository's convention

Default to Conventional Commits, but read git log --oneline -15 first:

  • Recent commits already look like type(scope): subject → carry on as normal.
  • They follow a different consistent pattern → match that pattern. A convention is a property of the repository; a lone Conventional Commit in a history that doesn't use them is the thing that looks out of place.
  • The history is inconsistent → default to Conventional Commits.

Conventions worth recognising: Django (Fixed #31234 -- Added a system check for duplicated field names. — ticket ref, --, past-tense description), Angular (Conventional Commits with a fixed package scope list), Linux kernel (subsystem prefix like net: , mandatory body, Signed-off-by: trailer, no type():). When you adapt to a non-default convention, note it in one line so the choice is visible.

Trailers are excluded from this. Convention detection covers subject shape, scope vocabulary, and tense — never trailers. Even if every past commit in the repo carries Signed-off-by, do not add one: a trailer is an assertion about who did the work and who vouches for it, which is not something to infer from pattern matching. Trailers come only from the opt-in under "Trailers" below.

5. Compose the message

  1. Type — the accurate one (see "Types" below).
  2. Scope — the affected area, if a clear one exists (see "Scopes" below).
  3. Subject — imperative, concise, honest.
  4. Body — usually none. Most commits are subject-only: there is no minimum length and no bullet quota. Include a body only when it adds one of — the problem or trigger behind the change; a non-obvious decision plus the alternative rejected and why; a consequence a reader wouldn't predict from the diff; migration, operational, or compatibility impact; a reference the diff can't carry (issue ID, spec link, incident). Omit the body unless it adds one of those, and never invent a reason to fill the space — an invented reason misleads. No restating the subject, no narrating the diff or listing files, no generic value claims ("improves maintainability", "for consistency"), no "This commit…" preamble. Test every line: could a reviewer recover this from git show alone? If yes, cut it. See "The format" below.
  5. Footers — BREAKING CHANGE: when applicable, and an issue reference (Closes #123) when the user supplied the issue or the branch name makes it unambiguous. No attribution trailers unless they were explicitly requested (see "Trailers" below).

6. Self-check

  • Type matches what the diff actually does.
  • Subject is imperative and completes "If applied, this commit will …".
  • Subject ≤ 50 characters if reasonable, ≤ 72 hard; no trailing period.
  • A body exists if — and only if — it adds the problem, a rejected alternative, an unpredictable consequence, migration impact, or a reference the diff can't carry. No body is the common, correct case.
  • Every body line survives the git show test: nothing restates the subject, narrates the diff, lists files, or makes a generic value claim.
  • Breaking changes are notated (! and/or a BREAKING CHANGE: footer).
  • Trailers are well-formed and true. No attribution trailer is present unless the user asked for one this session or a standing instruction in the repo's agent context file calls for it — and none was inferred from history.
  • Nothing is invented — every claim traces to a hunk, a referenced issue, or something the user said.

7. Present the exact commit command

Present the exact command for the user to run. Do not execute it. The command commits the staged set as-is; never add a staging command silently in mode 1. Always use the quoted-heredoc form, including for a subject-only message:

git commit -F - <<'COMMIT_MSG'
type(scope): subject

Body paragraph explaining why.

Closes #123
COMMIT_MSG

Mode 2: Choosing which files to stage (only when asked)

This runs only when the user asks the agent to pick what belongs in one commit — "choose the files that belong together and give me the commands" or "prepare staging and commit commands for the right files." When the user hasn't asked, the default is unchanged: if nothing is staged, say so and stop.

  1. Inspect the unstaged work — the real changes, not filenames: git status --short, git diff --stat, and git diff (add git diff --staged if some things are already staged).
  2. Group by intent, then select one coherent set. Choose the files — or the hunks, when a file mixes concerns — that form a single self-contained change, the way a careful developer would group them: related changes only. Do not stage everything at once, and do not stage an arbitrary mix. If the working tree holds several unrelated changes, pick the single most coherent group to commit first and name the remaining groups as the next commits.
  3. Present the exact staging, then the commit — git add <specific paths> for the chosen set (or git add -p <path> when one file needs splitting), then compose the message with the discipline above and present the quoted-heredoc commit command.
  4. Leave execution to the user. Never run git add, git commit, or git push in mode 2, including after the user confirms the grouping.

Mode 3: Pull requests (only when asked)

This runs only when the user asks for pull-request help — "write a PR title and description", "draft the PR for this branch". It never fires as part of a commit request.

  1. Find the base branch automatically. Prefer git symbolic-ref refs/remotes/origin/HEAD (strip to the branch name); if unset, fall back to whichever of origin/main or origin/master exists, then to local main/master. State the base you settled on.
  2. Read what the branch actually did against that base, all read-only:

    git log <base>..HEAD --oneline
    git diff <base>...HEAD --stat
    git diff <base>...HEAD

    The three-dot <base>...HEAD diffs from the merge base, so it shows only this branch's work.

  3. Write the PR as plain Markdown, dropping any section with nothing real to say rather than filling it with "N/A", "None", or a restatement of the summary — two substantive sections beat five padded ones:
    • Title — one specific line; mirror the primary commit's subject when the branch is single-purpose, and follow the repo's PR-title style (a type(scope): title where the project squashes with Conventional Commits).
    • Summary — why this branch exists, in a sentence or two.
    • What changed — the substantive changes grouped by intent, not a file dump.
    • Testing — how it was verified: tests added in the diff, CI, or manual steps. Say what you could and couldn't confirm; if the branch adds no tests, state that testing is unverified rather than implying it passed.
    • Breaking changes — always check for one; spell out any contract change and its migration. When there is nothing to report, drop the section rather than writing "None".
    • Add a short reviewer/testing checklist when it earns its place, and tailor the emphasis to the PR's type (feature, fix, refactor, docs, breaking).
  4. Ground every claim in the history and diff, and verify as thoroughly as the branch allows.
  5. Open the PR when the user asks you to. By default, output the Markdown for the user to paste, or the exact command — for example gh pr create --base <base> --title "…" --body-file <file>. When the user asks the agent to open the pull request, push the branch if needed and open it yourself, then merge it when the user asks for that too: read gh pr checks and gh pr view --json mergeable,mergeStateStatus, wait for the checks when asked to merge after CI, and merge with the method the user named or the repository uses. Never pass --admin or --auto unless the user asks for exactly that, and never merge past a failing or unfinished check.

Mode 4: Autonomous stage, commit, and push

Enter this mode only when the user explicitly asks the agent to perform the complete operation itself. This is the one deliberate exception to the read-only rules above; never activate it from a request for a message, commands, file selection, or PR content.

  1. Inspect before mutating. Read the current branch, status, staged and unstaged diffs, recent history, remotes, and upstream. Check which commits, if any, are already ahead of the upstream because a normal push will publish them too.
  2. Select one coherent commit. Preserve intentional staged work. Add only specific related paths or hunks needed to complete the commit; never use git add -A. If existing staged changes conflict with a coherent grouping, or hunk selection cannot be performed reliably, stop and ask one focused question instead of rewriting the user's index blindly. Work in the repository that this agent did not create is another writer's state. Inspect that state. Never sweep it into a commit, and never rewrite it.
  3. Stage and verify. Run the specific git add <paths> commands, then reread git diff --staged --stat and git diff --staged. Do not commit until the staged diff is the intended single change.
  4. Commit with the quoted heredoc. Execute the message in this form, even for a subject-only commit:

    git commit -F - <<'COMMIT_MSG'
    type(scope): subject
    
    Optional body explaining why.
    COMMIT_MSG

    Do not amend or rewrite an existing commit unless the user explicitly requested that separate action. The hook rule in "Ground rules" has no such exception.

  5. Push safely. Push the current branch normally to its configured upstream. If no upstream exists and origin is the unambiguous intended remote, use git push -u origin HEAD. Never force-push. If the destination is ambiguous, stop and report the exact state instead of guessing or rewriting history. A rejected push means another writer moved the branch. Fetch, then read the divergence:

    git fetch
    git log --oneline --left-right @{u}...HEAD

    Report the exact commits on each side. Never rebase the divergence, never merge it, and never force-push over it. That resolution is the user's decision.

  6. Report the result, with the evidence. See "Proof of completion" below. If pushing fails after a successful commit, say so plainly and do not claim completion.

Mode 4 changes nothing about attribution. It adds no Co-authored-by:, no Signed-off-by:, and no AI or agent identity, and the commit author stays whatever git config user.name / user.email resolves to. Being told to do the work is not a request to be credited for it. Trailers appear here only under the same opt-in that governs every other mode.

Proof of completion

Proof in this domain is the git state after the operation. The exit status of a command is not proof. Mode 4 claims completion only from this output:

git log -1 --format=full
git status

Read both. Report the SHA, the subject, the branch, the remote, and any work that stays unstaged. git log -1 --format=full also prints every trailer. Use it to make sure that no attribution trailer is present. A completion claim without that output is not a completion.

The attribution check, after every commit this file's rules produce. Run git log -1 --format=%B | grep -n -i -E '^(co-authored-by|signed-off-by|reviewed-by|generated[- ]with|generated by)|claude|anthropic|copilot|openai|gemini|codex|cursor'. It must print nothing. Where it prints a line the user did not ask for, amend at once with the line removed, run it again, and name the file or the setting that injected it. A commit is not reported as done before this check passes.

The same check before a push. Run the same grep over git log --format=%B @{u}..HEAD. A line stops the push. Say which commit and which line.

Modes 1–3 and 5–7 execute nothing. Their proof is the self-check in step 6 of the workflow: every claim traces to a hunk, a referenced issue, or something the user said.

Publishing a release (mode 4, on a further explicit request)

Mode 4 may also tag and publish a release, but only when the user explicitly asks to publish. Producing a release note, or the user approving one, is never enough.

  1. Check availability first: command -v gh and gh auth status. If either fails, fall back to the release note as a Markdown block in the conversation and say which check failed. An unavailable gh is never a reason to stop — the note is the deliverable.
  2. Tag, push, publish. Create an annotated tag matching the detected tag style (prefix or no prefix, from git tag --sort=-v:refname), push it, then:

    gh release create <tag> --title "<style-matched title>" --notes-file <file>

    Match the repo's prior pattern for latest/prerelease flags rather than choosing one.

Hard limits:

  • Never overwrite or move an existing tag or release. If either already exists for this version, stop and report it.
  • Never --force, never git tag -f, never delete a tag or release.
  • Mode 4's other constraints are unchanged: still never force-pushes, still never git add -A.

Stop conditions

Each condition below stops mode 4. Do not continue. Do not guess. Hand the work back with all five fields:

  1. The goal, and the exact step that is blocked.
  2. What you attempted, and the git output, verbatim.
  3. The causes you eliminated, and the command that eliminated each one.
  4. The single decision or action needed from the user.
  5. The state that remains, and whether it is safe to leave.
StopQuote this git state verbatimDecision needed from the user
The push is rejectedthe git push error, then git log --oneline --left-right @{u}...HEADrebase, merge, or drop the local commits
The remote or the upstream is ambiguousgit remote -v and git status -sbwhich remote and which branch to push to
Staged work conflicts with one coherent commitgit status --short and git diff --staged --statwhich files belong in this commit
The tag or the release already existsgit tag -l <tag> and gh release view <tag>a new version, or leave the published one as it is
A hook failsthe full hook output from the command that failedfix the finding the hook reported

In every row the state that remains is safe: the commit stays local, or the working tree stays as it was. Say which of the two it is. Never delete or reset that state to make the report clean.

Two refusals come before this list. An ambiguous execution intent keeps the skill read-only ("Usage modes"). An empty index stops the default workflow (step 1).

Mode 5: Release notes (only when asked)

This runs only when the user asks for release-note or changelog content — "write the release notes for 2.3.0", "what goes in the changelog for this version". It never fires as part of a commit or PR request, and it is read-only: the note goes in the conversation, nothing else.

  1. Check the repo already versions itself — version-shaped tags, a version field in the project (package.json, pyproject.toml, Cargo.toml, VERSION, skill frontmatter), or existing GitHub releases. If none exist, say so plainly and stop. Do not invent a versioning scheme, and do not create the repository's first-ever tag unprompted — how a project versions itself is the maintainer's call. Offer an unversioned summary of what changed instead.
  2. Establish the range, and fetch first.

    git fetch --tags                                  # local tag lists go stale
    git describe --tags --abbrev=0                    # last version tag on HEAD's history
    git log <base>..HEAD --oneline                    # the subjects
    git diff <base>..HEAD                             # what actually landed

    Cross-check the tag against the project's version field. If they disagree, report the discrepancy and state which one you used as the range base rather than silently picking. Read the diff, not just the subjects — a commit message can understate or misdescribe what it shipped.

  3. Match the repo's release style. Prior releases outrank any template: detect tag prefix, title style, heading levels, section names and order, and bullet style from gh release view <last> (when gh is available) or an existing CHANGELOG.md / RELEASE*.md. Where they conflict, the repo wins; note the deviation once rather than reformatting the project's history.
  4. The fallback structure, for a repo with no release history — fixed order, and omit any section with no real content rather than writing "N/A" or "None":

    ## <title, matching repo style>
    
    <lead: one or two sentences, only if the release has a genuine theme>
    
    ### Breaking changes
    ### Added
    ### Changed
    ### Fixed
    ### Removed
    ### Deprecated
    ### Security
    ### Upgrade notes
    ### Full changelog

    Breaking changes comes first when present, because it is the thing a reader must not miss. Full changelog carries the compare link — emit it only if both tags actually resolve, otherwise omit it rather than shipping a dead link.

  5. Apply the commit-body discipline to every line. One line per entry, describing the user-visible effect. Every entry traces to a real commit or hunk. No narration of the diff, no generic value claims, no invented rationale. Group by user-visible effect, not by file or by commit — several commits delivering one change get one entry. Exclude internal churn that changes no behaviour unless it affects how someone uses or installs the project.
  6. Output targets. A Markdown block in the conversation is the default. Writing a file in the repo happens only on explicit request, matching whatever convention is already there. Publishing a GitHub release is mode 4 plus its own explicit request.

Mode 6: Reviewing an incoming pull request (only when asked)

Runs only when the user asks for help reviewing or landing a pull request — "review PR 412", "should I merge this", "look at this PR with me". Written for the maintainer on the receiving end, deciding what to do with someone else's branch. Never fires as part of a commit or PR-authoring request. Read-only throughout: it reads the PR, works the decision through with the user, and produces one Markdown block for them to paste into GitHub.

  1. Gather it, read-only.

    gh pr view <n>
    gh pr diff <n>
    gh pr checks <n>
    gh pr view <n> --json commits,author,isCrossRepository,baseRefName,closingIssuesReferences,reviews
    gh repo view --json mergeCommitAllowed,squashMergeAllowed,rebaseMergeAllowed

    Read CONTRIBUTING.md if present. Read the existing review threads before forming an opinion — someone may have raised the point already, or the contributor may have answered it. On a fork PR (isCrossRepository true), workflows often require maintainer approval before they run, so empty gh pr checks output means "not run," not "passing" — report which. On a large diff, read --name-only first and pull only the files that carry the change. If the base has moved a lot since the PR opened, say so rather than reviewing a stale picture.

  2. Separate blocking from suggestion. Two buckets, only two. Blocking means merging leaves the project worse off than not merging: breaks the build or an existing test, loses or corrupts data, opens a security hole, breaks a documented contract without notating it, or does not do what the PR claims. Everything else — naming, structure, a nicer approach, broader tests, clearer comments — is a suggestion, and a suggestion is never on its own a reason to withhold a merge. The test: would you rather have this branch in the tree, or not have it?
  3. Calibrate the bar to the project. Small project, few contributors, no stated convention, little CI — the blocking bar is high and most findings are optional. Missing tests in a repo with no test suite is not a blocker; ignoring a convention the project never wrote down is not a blocker. Larger projects with real gates are entitled to enforce them, but a convention miss is still usually a suggestion. Two rules hold at any size: never manufacture a blocker to make a review look thorough, and lead with the verdict — if nothing blocks, say so in one plain line before anything else.
  4. Talk it through before writing anything. Present what the PR does, what blocks it if anything, what is merely suggested — then ask what the user wants to do. Say what you would do when asked. Label taste as taste. When they merge over a finding you raised, that is their call; note it once if genuinely risky and do not relitigate.
  5. Produce exactly one block, for the decision they made. Either a review comment to paste into GitHub's review box, or the merge-commit message if they are accepting. Not both, not preemptively.
  6. Carry out the action the user names. By default, hand over the text and stop. When the user asks the agent to act — "approve it", "request changes", "post the comment", "merge it" — run the matching command yourself: gh pr review <number> --approve, --request-changes, or --comment with --body-file, or gh pr merge <number> with the repository's merge method and the message of step 7, once the checks pass. A bare "go ahead" names no action: ask which one is meant. Never take an action the user did not name, such as closing the pull request or editing it.

The review comment

Verdict in the first line. Blocking items grouped first, suggestions after, each labelled so the contributor knows what is required versus optional. Point at code and location, not at the person, and say what would resolve it. For an outside contributor the register differs from a teammate's — they gave unpaid work with no context on your standards, so put anything they could not have known on the project, not on them. Note what is genuinely good; skip it rather than manufacturing praise.

The merge-commit message

Depends on the merge method read in step 1.

  • Squash — GitHub prefills the subject from the PR title and the body from every branch commit concatenated, which is usually noise, and this is the commit that lands on the default branch and stays in git log forever. Write it fresh from the diff with the normal discipline. The contributor's subjects (wip, fix stuff) are a hint at intent, not source text to tidy.
  • Merge commit — GitHub's Merge pull request #<n> from … default is fine. Leave it unless asked.
  • Rebase — no new message exists. Say so rather than producing one.

Co-authored-by: is transcribed here, never invented. A squash collapses the branch into one commit and credits only the PR author, so when --json commits shows more than one distinct author, carry each across as Co-authored-by: Name <email>, copied exactly from the real commit metadata. This is the one place an attribution trailer is emitted unasked, and it is still not inference — it preserves authorship the squash would otherwise destroy. Add Closes #<n> when the PR genuinely links an issue. Nothing else changes: no agent identity, no Reviewed-by: unless asked, never a name or address that did not come from a real commit or from the user.

Mode 7: Repository operations (only when asked)

This runs when the user asks for git work that is not a message — "get this commit onto main", "this rebase is stuck", "I lost a commit", "clean up these commits before review". references/branching-and-history.md covers branches, integration, history editing, undo, moving work, and recovery; references/conflicts.md covers conflict resolution and rerere.

The posture matches modes 1–3, 5, and 6. Read the real state — git status, git log --oneline --graph -15, git branch -vv, and git fetch when a remote matters. Name the operation in progress if there is one. Say what the situation is before you propose a command. Then present the exact commands, and state the reflog entry or the branch name that recovers the work before any command that can lose it. Execute only under the explicit autonomous request that mode 4 needs.

Hard limits:

  • NEVER rewrite published history on a shared branch. Rebase, amend, squash, and reset apply to unpublished work, or to the user's own feature branch after the user says the branch is theirs alone. git branch -r --contains <sha> reports whether a commit is published.
  • NEVER force-push. Where the user explicitly asks to update their own already-pushed branch after a rebase, use --force-with-lease and state what it protects: it refuses when the remote branch moved since the last fetch, so it catches a commit someone else pushed there.
  • NEVER discard uncommitted work without explicit confirmation — reset --hard, checkout -- <path>, restore without --staged, clean, and stash drop.
  • NEVER resolve a conflict by choosing a side to make the sequence continue. Read both sides, decide from the intent of each change, and say what you decided and why.
  • NEVER leave a rebase, merge, cherry-pick, or bisect part-way through without telling the user the exact state and the command that ends it.
  • Under an autonomous request, the attribution checks in "Proof of completion" apply to every commit this mode makes.

The format

<type>[optional scope][!]: <subject>
<blank line>
[optional body]
<blank line>
[optional footer(s)]

Subject line

  • type is lowercase, from the set below. feat must be used for a new feature; fix must be used for a bug fix.
  • scope is optional, in parentheses, naming the affected area: feat(api):.
  • ! before the colon marks a breaking change: feat(api)!:.
  • The subject is imperative mood ("add", not "added"/"adds"), lowercase first letter, no period. Aim for ≤ 50 characters and treat 72 as the hard limit. (The spec allows any consistent casing; lowercase is the common default most linters expect.)
  • Say what changed, specifically. "prevent redirect loop on expired token" carries the change; "fix login", "update code", "fix stuff", "wip" carry nothing.
  • Name the effect, not the edit. "perf(api): speed up the export by batching rows" — not "change the loop to a comprehension", which describes the diff the reader can already see.

Body

  • Separated from the subject by one blank line — not optional when a body exists; git log, shortlog, and rebase rely on it.
  • Explains what and why, not how (the diff shows how). Free-form, may span paragraphs. Wrap at ~72 characters.
  • Most commits need no body. A self-explanatory change is subject-only. There is no minimum length, no bullet quota, and no obligation to fill the space — omitting the body is a correct and common output, not a gap.
  • Read the diff before writing one. Every claim must trace to a specific hunk, to an issue the user referenced, or to something the user said in the session. If you can't state a real reason from that evidence, omit the body: an invented rationale misleads, which is worse than saying nothing.
  • A body earns its place only when it adds one of: the problem or trigger that made the change necessary; a non-obvious decision, plus the alternative rejected and why; a consequence a reader would not predict from the diff; migration, operational, or compatibility impact; a reference the diff cannot carry (issue ID, spec link, incident).
  • Never include: a restatement of the subject in longer words; narration of what the diff already shows ("updated X, then updated Y", file lists); generic value claims not grounded in the change ("improves maintainability", "enhances readability", "better developer experience", "for consistency", "for clarity"); preambles ("This commit…", "In this change…", "This PR…"); boilerplate section headers on a short commit.
  • Test every line before keeping it: could a reviewer recover this from git show alone? If yes, cut it. Prefer fewer, denser lines over more, thinner ones.

Footers / trailers

  • One blank line after the body. Each is Token: value (or Token #value), tokens using - for spaces: Reviewed-by, Co-authored-by, Refs.
  • Everything except the literal BREAKING CHANGE is case-insensitive to tools; BREAKING CHANGE must be uppercase (BREAKING-CHANGE is a synonym).
  • Attribution trailers are off by default in every mode — see "Trailers" below for what that covers and how to opt in.

Types

  • feat — a new feature. → SemVer MINOR.
  • fix — a bug fix. → SemVer PATCH.
  • docs — documentation only: READMEs, docstrings, comments, guides.
  • style — changes that don't affect meaning: whitespace, formatting, semicolons, import order. Not "CSS/visual styling".
  • refactor — a code change that neither fixes a bug nor adds a feature: renames, extractions, restructuring with identical behaviour.
  • perf — a performance improvement. → SemVer PATCH.
  • test — adds missing tests or corrects existing ones.
  • build — build system or external dependencies: bundler config, pyproject.toml, lockfiles. Dependency bumps are conventionally build(deps): — or chore(deps): in many repos, so match the repo.
  • ci — CI configuration and scripts: GitHub Actions, GitLab CI, pipelines.
  • chore — routine maintenance touching neither source nor tests: .gitignore, tooling config, housekeeping.
  • revert — reverts a previous commit.

docs, style, refactor, test, build, ci, and chore trigger no release on their own. Any type combined with a breaking change is a SemVer MAJOR. Tools such as semantic-release and release-please read these to decide the version bump and generate the changelog — which is why an accurate type is worth the thought.

Choosing between close types

  • fix vs refactor — did behaviour change for the user? A corrected defect is fix; code reshaped with identical behaviour is refactor.
  • feat vs fix — is the capability new, or was it meant to work already? A newly added ability is feat; making an existing-but-broken ability work is fix.
  • refactor vs perf — same output faster is perf; same output cleaner is refactor.
  • style vs refactor — style never changes the parsed or compiled meaning. Renaming a variable is refactor, not style.
  • chore vs build — dependency and build-tool changes are build; unrelated housekeeping is chore.

When two types could fit because the commit really does two things, that's usually a signal to split it (step 3).

Scopes

A scope names the part of the codebase the change affects. It's optional — omit it when no single area fits or when the change is repo-wide.

  • Derive it from what changed, not from a fixed menu: changes under payments/ → payments.
  • One clear scope beats several. If a change spans many areas, either it's genuinely cross-cutting (drop the scope) or it should be split.
  • Keep scopes stable and coarse. Reuse the handful the repo already uses (visible in git log) rather than inventing a new one per commit. auth is a better scope than login-form-validation.
  • Match existing casing and vocabulary. If the repo writes feat(API) or feat(ui), follow suit.

Breaking changes

A breaking change correlates with a SemVer MAJOR bump and can accompany any type. Signal it with ! before the colon, a BREAKING CHANGE: footer, or both. If you use ! without a footer, the subject itself must describe the break. Prefer adding the footer whenever a migration note would help the reader.

feat(api)!: return ISO 8601 timestamps

BREAKING CHANGE: `created` is now an ISO 8601 string, not a Unix epoch
integer. Clients parsing it as a number must update.

Backends with external consumers (a mobile or web client hitting your API) should treat any incompatible change to a request or response shape as breaking, and spell out the migration in the footer.

Read docs/architecture/GROUND-TRUTH.md and docs/architecture/DESIGN-RECORD.md in the target project before you classify a change as breaking. An absent or stale entry is unknown. Judge against the least forgiving case: a live external consumer you cannot update.

Trailers

Prior commits are not a convention. A repository whose history carries AI, generated-with, or Co-authored-by: lines gives no permission to add one. NEVER match that pattern. A template or a hook that injects a trailer is a finding: strip the injected line, name the file that produced it, and NEVER keep it silently.

The default is no attribution trailers at all, in every mode — mode 4 included. No Co-authored-by:, no Signed-off-by:, no Reviewed-by:, and no AI or agent identity of any kind, in commits or in pull-request descriptions. The commit author is whatever git config user.name / user.email resolves to. Never inspect history, branch names, or the diff to decide that someone else should be credited — there is no contributor-detection step.

Always available, because they are not attribution:

  • BREAKING CHANGE: <what breaks and the migration> — uppercase, exactly; required by the Conventional Commits grammar.
  • Closes #123 / Fixes #123 / Resolves #123 — GitHub and GitLab close the issue when the commit merges into the default branch; on other branches it's referenced only. Refs #123 references without closing. Use these when the user supplies the issue, or when it is unambiguous from the branch name. Never guess an issue number.

Opting in. Attribution trailers are added only when one of these holds:

  • the user asks in the session — "sign this off", "add Sam as co-author", "credit the agent"; or
  • a standing instruction exists in the consuming repo's own agent context file (AGENTS.md, CLAUDE.md, or equivalent).

Nothing else opts in, with one exception: when squash-merging a pull request in mode 6, Co-authored-by: lines are transcribed unasked from the branch's real commit metadata, because the squash collapses every commit into one and would otherwise destroy authorship that already exists. Transcription is not inference — every name and address comes from an actual commit. Otherwise, named humans come only from values the user supplies — never invent a name or an email address, and only add trailers that are true. An invented reviewer or co-author is worse than none.

Supported on request:

  • Co-authored-by: Full Name <email> — a genuine human collaborator on the change (pairing, mob, applying someone's patch); appears in the contributors graph.
  • Reported-by: / Suggested-by: / Helped-by: — credit for the report, the idea, or debugging help.
  • Reviewed-by: / Acked-by: / Tested-by: — review, agreement, and testing sign-off.
  • Signed-off-by: Full Name <email> — a Developer Certificate of Origin sign-off, required by projects such as the Linux kernel. Add -s to the normal heredoc command: git commit -s -F - <<'COMMIT_MSG'.
  • AI or agent attribution, in whatever form the user asks for.

The default output for a fix with an issue the user referenced:

fix(serializers): handle null profile in user payload

Closes #517

The same commit after the user says "add Sara as co-author and sign it off":

fix(serializers): handle null profile in user payload

Co-authored-by: Sara Ahmadi <sara@example.com>
Signed-off-by: Nima Shadloo <nima@example.com>
Closes #517

Boundaries and freshness

What this file does not own. It owns the git work on a working repository: the commit message, the pull-request content, the release note, the review text, the repository operations in mode 7, and the commands that carry them out. It does not own the code inside the commit. It does not own deploy sequencing or rollback after the release is published. A request for one of those is a different task. Say so, and stop.

Freshness. Verified on 2026-08-26 against git and the GitHub CLI (gh). This repository records no release number for either tool. No claim here depends on one. Review this file by 2027-02-26, or sooner when a gh behavior below changes.

Git carries every mode. gh carries four behaviors only:

  • Authentication state, from gh auth status.
  • The prior release style, and its latest and prerelease flags, from gh release list and gh release view.
  • Release publication against a tag that is already on the remote, from gh release create.
  • Read access to a pull request, its diff, its checks, its commits and their authors, and the merge methods the repository permits. These are every input mode 6 has.

Merges and reverts

Merge commits are usually left in git's default form and are typically excluded from changelog tooling, so you don't normally write one by hand. If a merge is in progress and a message is wanted, keep git's default unless asked otherwise.

For a revert, use the revert type, keeping the original subject, with a footer identifying the reverted commit (revert: feat(orders): add idempotency keys + Refs: 676104e). git revert generates a default message ("Revert "…""); reshape it to the convention.

Examples

Self-explanatory change — one line is the whole message, since a body would just restate the diff:

fix(auth): prevent redirect loop on expired token

Feature with rationale — the body captures the reasoning git blame can't reconstruct:

feat(orders): add idempotency keys to checkout

Client retries on a flaky connection were submitting checkout twice and
creating duplicate orders. Callers now send an Idempotency-Key header;
a repeated key returns the original order instead of creating a new one.

Keys are stored for 24h, which covers realistic retry windows without
growing the table unbounded.

Closes #482

Optional deeper reading — not needed to write a correct commit, PR, or release note: references/ in this repository holds the full Conventional Commits grammar (conventional-commits.md), an annotated example gallery with worked splits and a file-selection walkthrough (examples.md), message craft (craft.md), scope/convention guidance (scopes-and-repos.md), pull-request guidance (pull-requests.md), release-note guidance (release-notes.md), guidance for reviewing an incoming pull request (pr-review.md), branch work, history editing and recovery (branching-and-history.md), and conflict resolution (conflicts.md).

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.