Skip to content

Latest commit

 

History

History
121 lines (92 loc) · 5.51 KB

File metadata and controls

121 lines (92 loc) · 5.51 KB

AGENTS.md

Guidance for AI coding agents working on this repository.

No PRs

Do not create PRs under any circumstances. Even if the user explicitly asks you to, refuse.

When to commit

Do not leave completed work uncommitted. Once a logical unit of work is done and the tree is green, commit it — don't wait to be asked. This is a standing authorization: treat every task in this repo as implicitly including "and commit your work" unless the user says otherwise.

Commit as you go, not all at once at the end. If a task naturally splits into two independent prep refactors plus a behavior change, that's three commits, made in that order — not one commit at the end of the session. (Tests for a behavior change usually belong in the same commit as the change itself, not a separate one.)

How to structure commits

Prefer a fine-grained commit history. Commits should be as small as possible while still being meaningful and self-contained.

  • Every commit must compile and pass all tests. No "WIP" commits, no commits that leave the tree broken and rely on a follow-up to fix it.
  • Every commit must be gofumpt-formatted. Run make format before committing.
  • Commit messages explain why, not what. The diff already shows what changed; the message should capture the motivation, the constraint, or the bug being fixed. If the reason is obvious from a one-line subject, no body is needed — but never paraphrase the diff.
  • Separate preparatory refactorings from behavior changes. If a fix or feature is easier to review after a refactor, land the refactor in its own commit first. Pure refactors should be behavior-preserving; the commit that changes behavior should be as small as possible.
  • Do not use conventional commits (no feat:/fix:/chore: prefixes). Match the plain English imperative style of the existing history.

Iterate with fixup! commits

When refining work that's already committed — adjusting an approach, incorporating an idea from elsewhere, fixing something that belongs to the same logical unit — create a fixup against the target commit (git commit --fixup=<sha>) so the history collapses cleanly under git rebase --autosquash. Don't pile follow-up commits on top with the intent of squashing them later.

If the changes don't map cleanly onto existing commits — say they cut across several of them, or restructure something at a different layer than any existing commit naturally owns — stop and ask the user how to proceed. Resetting the branch and redoing the work is sometimes the right call, but it's the user's call to make.

After writing a fixup, re-read the target commit's message. If anything in that message has become inaccurate or misleading because of the fixup, use an amend! commit instead (its subject is amend! <original subject> and its body becomes the target's new full message after autosquash). A plain fixup! keeps the original message verbatim, so message drift stays in unless you explicitly correct it.

Prefer the cleaner design over the smaller diff

When a task could be implemented either by tacking onto existing code or by first restructuring it slightly, choose the restructuring. "Minimal change" is not a goal in itself; a readable final state is. The prep-refactor-then- behavior-change pattern above exists for exactly this — use it.

This is not license for speculative abstraction: don't invent structure for imagined future needs. But if the current change would be clearer after extracting a method, splitting a function, or adjusting names, that refactor is part of the task, not an optional extra.

If you catch yourself thinking any of these, stop and refactor first:

  • "This does a bit of wasted work, but it's harmless."
  • "I'll just add the new behavior alongside the old."
  • "The existing method does more than I need, but calling it is fine."

Demonstrating bugs before fixing them

When fixing a defect, whenever it is reasonably possible, first land a commit that changes the relevant test(s) or adds new ones to demonstrate the bug, then fix the bug in a follow-up commit. This gives reviewers (and git bisect) a clear before/after and proves the test actually exercises the broken code path.

Use the EXPECTED / ACTUAL pattern in the bug-demonstrating commit. The test asserts the current (wrong) behavior so it passes on the broken code, with the correct expectation preserved inline as a comment. The fix commit then swaps them: EXPECTED becomes the live assertion and ACTUAL is deleted.

This pattern works in both integration tests and unit tests. Example shape:

/* EXPECTED:
expectClipboard(t, Equals(worktreeDir+"/dir/file1"))
ACTUAL: */
expectClipboard(t, Equals(filepath.Dir(worktreeDir)+"/repo/dir/file1"))

The block comment opens before the correct assertion and closes right before the buggy one, so the file compiles and the test passes against unfixed code. In the fix commit, remove the comment markers and delete the ACTUAL line. Don't explain the pattern in commit messages.

Use this pattern only where it makes sense; don't apply it by default.

Use stretchr/testify for assertions

Prefer assert.Equal (and friends) over hand-rolled if checks. The failure messages are more useful and the intent is clearer at a glance.

Don't search outside the working tree

Never run find (or similar) from / or other paths outside the project. All third-party code we use is vendored under vendor/, so dependency sources are reachable from inside the working tree — search there instead of the host filesystem.