Skip to content

AGENTS.md: a branch must not change the same thing twice #95

Description

@usekaneo

What is missing

AGENTS.md (and the CLAUDE.md copy of it) says what has to be true of
every commit — the gates, the language, the ticket prefix — but says nothing
about the relationship between the commits of one branch. So nothing stops
a branch from introducing something in one commit and rewriting it in the
next, and the reviewer ends up reading work that was already thrown away.

Where it came from

CON-11 (#94). The branch had four commits, and the file-touch count looked
like this:

  • src/routes/PageView.tsx, src/routes/HistoryView.tsx, src/domain/search.test.ts, src/domain/pages.ts — 3 commits each
  • sixteen further files — 2 commits each

Two files were created and then deleted again inside the same branch:
src/ui/hide-page.ts became src/ui/archive-page.ts, and
src/nostr/publish-page.tombstone.test.ts became
src/nostr/publish-page.archive.test.ts. Neither ever existed on main, so
every line of both was pure noise for anyone reading the branch. The same
went for the wording: a confirmation text was written, then shortened, then
shortened again; the feature was called "hiding" with a "tombstone" revision
before it was called archiving.

Rebuilt from the final tree, the branch is two commits, each file appears
exactly once, and both commits pass the gates on their own. Nothing of the
content was lost — the trees are identical. The whole difference was
reviewability.

What the rule should say

Before a branch is handed over for review, its commits must read as if the
work had been done once, in order:

  • No file is changed by two commits of the same branch unless the second
    change is a genuine consequence of later work, not a correction of the
    first.
  • Nothing a branch adds is removed or renamed by the same branch.
  • Every commit passes typecheck, lint, test and build on its own,
    which is what makes the split honest rather than cosmetic.

How it is checked

The count is one command, and it belongs in the rule so nobody has to invent
it:

git log --format='%h' main..HEAD | while read c; do git show --format= --name-only $c; done | sort | uniq -c | sort -rn

Anything above 1 is a file to justify or to fold together.
git diff main..HEAD --stat against the sum of the individual commits shows
the same thing from the other side.

The repair is git reset <main> && git add <group> && git commit per group,
verified with git diff --quiet HEAD <backup-branch> — the tree must come
out identical to what was reviewed.

Scope

  • AGENTS.md, Conventions section, next to the gates bullet.
  • CLAUDE.md mirrors it and has to be updated with it.
  • No code, no tooling. A hook could count the touches, but the judgement
    ("is this a correction or a consequence?") is not mechanical, so this stays
    a written rule for now.

Task: ojdyaqnwk4fazrpldi5oriwm

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions