writingmaclulich.com

How to make git the system of record for your AI coding agents

Five changes that make git the system of record for your coding agents

  1. Commit what’s worth keeping before the session endsEach unit of work gets a fresh session, so only the commit carries over
  2. Read the rules from main, not the agent’s branchAn agent’s own edits to its rules don’t count until they’re reviewed and merged
  3. Read what an agent did from git, not from its messageMy supervisor takes the commit, the changed files and anything uncommitted from git
  4. Write a lesson only after a mistake repeatsThe same rule failing twice in one area earns a lesson, with five per area at most
  5. Ask git instead of keeping a second recordMy cleanup’s holds, claims and retry ledger became one question: is the branch merged into main, with nothing uncommitted?
How I run my own coding agents. The numbers are my settings, not measured results.

Agents forget by design, so git has to remember

If you run coding agents that forget everything between tasks and you want their rules, results and lessons to survive, this is how I do it with git.

It started when a reader picked out one line from my last post: Drew Breunig’s point that managing what an agent sees has to move out of the model and into the system around it.

Most of mine forget on purpose at the end of each piece of work, and that only works because git remembers it for them. I run them under Rigby, a small supervisor I wrote.

One head plans, lanes do the units, and Rigby merges what passes review

  1. Headplans the work and hands out units of it
  2. Lanesdo the units, each in its own copy of the project
  3. Rigbycarries messages between them and merges finished work once it has passed review

Commit what’s worth keeping before the session ends

A lane starts every unit in a fresh session. That keeps its context small and stops one task’s history leaking into the next.

The cost is that anything the lane learned or decided in that session is gone when it ends.

So the rule is simple: if it’s worth keeping, it has to be in a commit by the time the unit finishes.

Each unit gets a fresh session, and only the commit carries over

Each unit gets a fresh session, and only the commit carries overThree faded session boxes side by side, one per unit of work. Each one points down to a commit on a single branch line labelled main. The sessions are thrown away and the commits stay.session: unit 1commitsession: unit 2commitsession: unit 3commitmainthe sessions are thrown away, and the next unit starts from the commits
The head is the exception. It holds the plan, so it compacts instead of resetting.

So I treat the session as scratch space and the commit as the memory. You can do the same by making a commit part of finishing, for anything you’ll want next time.

That covers what a lane learns. What it works to has to survive too.

Read the rules from main, not the agent’s branch

The rules a lane works to aren’t in its prompt. They’re two small files the project commits: one maps code areas to their rules and tests, and the other holds lessons from past mistakes.

Rigby reads both from the main branch, never from the lane’s own copy.

A lane can’t loosen the rules it’s about to be judged by, even by accident, because its own edits to those files don’t count until they’re reviewed and merged.

The rules an agent is judged by come from main, never from its own branch

The rules come from main, never from the lane’s own branchA box for the main branch, holding the rules file and the lessons file, has arrows to both the lane’s brief and the reviewer’s brief. A dashed box below it, the lane’s own branch, has a short dashed line marked not read.main branchrules file · lessons filethe lane’s own branchits rule edits wait for reviewlane’s briefthe rules for its filesreviewer’s briefthe same rules, from the real diffnot read
Changing a rule is a commit like any other, so it gets reviewed like any other.

To do the same, read your agents’ rules from main, whatever their own branch says.

Rules say what a lane should do, but whether it did is a separate question, and the lane shouldn’t be the one to answer it.

Read “done” from git, not the agent’s message

When a lane finishes, it doesn’t get to describe what it did. The command that closes a unit reads the facts from git: the commit, the branch, the files that changed, and whether anything was left uncommitted.

The supervisor then works out the whole change itself, from where the unit started to the commit the lane reported.

It never takes a commit id, a file list or a verdict from the lane’s message.

A lane’s message can’t change what the supervisor believes it did

  1. Laneruns the done command
  2. Gitgives the commit, the files and a clean copy
  3. Supervisorrecomputes the change from the unit’s start
  4. Reviewergets the rules for the files that really changed
Words like DONE inside a message, or a quoted commit id, can’t move a unit forward.

That last step matters most. The reviewer’s rules are rebuilt from what the commit actually touched, so a file the head never mentioned still brings its rules with it.

One line in my operating notes sums it up: the mailbox, where agents leave each other messages, is for waking agents, and git is for facts.

So done is a commit, not a message. If you run a supervisor of your own, have it read the commit, the changed files and the uncommitted state from git.

Write a lesson only after a mistake repeats

A review that blocks a unit is worth keeping too. Rigby records which rule broke and where.

If the same rule fails twice in the same area, it’s proposed as a lesson for that area’s future briefs, five at most.

Proposing isn’t the same as adding. The lesson is written into the committed lessons file, and that change goes through review like code does.

A lesson retires when git says its code is gone or has gone quiet

  1. Promotedthe same rule failed twice in one area
  2. Cappedfive per area, because more stop being read
  3. Retiredno code left in the area, or ten commits there without a repeat
Both retirement checks are git queries against main.

Retirement is git as well. A lesson about code that’s been deleted, or about an area that’s had ten commits since without the mistake coming back, drops out on its own.

So I let a mistake earn its place and leave when git says it’s no longer needed. Cap them, because more than five per area stop being read.

Ask git instead of keeping a second record

My first cleanup kept its own records about which copies of the project were safe to remove: holds, claims, a retry ledger.

Each one was a correct fix, and each one was a new place for things to get stuck.

What replaced them is a question git already answers. A copy whose branch is merged into main, with nothing uncommitted, can go. Anything else is listed with the one command that removes it.

A record you keep can get stuck, and a fact you read from git can’t

  1. Beforeholds, claims, a retry ledger, custody moves
  2. Nowmerged into main, and nothing uncommitted
Leftover files on a finished copy go into a named stash before it’s removed.

Before you add a hold, a claim or a retry ledger to your own cleanup, ask whether git already answers the question.

Once I’d stopped keeping my own records, I started noticing how much other context has none.

Hold your agents’ other context to git’s standard

Running agents this way made something obvious to me. Code is the one part of a company where every change has a record of who made it, when, why, and what it replaced.

The rest of a company’s context mostly doesn’t. The decisions, the reasons behind them and what changed since live in chat threads, documents and people’s heads.

Code has a system of record, and most of a company’s other context doesn’t

Can you tell…CodeOther context
Who changed it and whenyessometimes
Whyyesrarely
What it was beforeyessometimes
Reviewed before it countsyesrarely
What was true on a given dayyesrarely
A generalisation from my own experience, not a survey.

An agent working from that gets whatever someone happened to paste in. Nobody can easily check whether it was current, or which version of a decision it saw.

Ask the table’s five questions of anything you give an agent.

That’s the part I’m working on now. At Neuma, where I’m a founding engineer, we’re building the system of record for a company’s intelligence, the context layer that powers its AI agents, workflows and tools.

How far to trust it

Three limits to know before you copy this

  1. Some state still isn’t in gitRigby keeps its own small database of which unit is with which lane, and a log of exactly what each agent was told, stored by digest
  2. The head’s plan isn’t eitherIt lives mostly in a long session, which compacts rather than resets. A head that fixes on a wrong idea can carry it across compactions, and I haven’t solved that yet
  3. The company comparison is my own viewA generalisation from running agents this way, not a survey

What to copy

If an agent needs to know it, or I’ll need to check it later, it belongs in a system of record, not a session.

For code that system is git, and these are the steps I follow:

  1. End every unit on a commit. Anything not committed is gone with the session.
  2. Commit a rules file that maps code areas to their rules and tests, and a lessons file for past mistakes. Read both from main, never from the agent’s own branch.
  3. Close a unit by reading git: the commit, the branch, the files that changed and whether anything was left uncommitted. Rebuild the whole change from where the unit started, and take no commit id, file list or verdict from the agent’s message.
  4. Build the reviewer’s rules from the files the commit really touched.
  5. When a review blocks a unit, record which rule broke and where. Propose a lesson when the same rule fails twice in one area, five per area at most, and review it like code.
  6. Retire a lesson when its code is gone or ten commits pass without a repeat.
  7. Remove a finished copy of the project only when its branch is merged into main with nothing uncommitted. List the rest with the one command that removes each.

For code, that system already exists, and it’s git. For everything else a company knows, it’s still being built.

How it works

Each unit starts fresh, ends on a commit and is judged from git

  1. Brief from mainThe rules and lessons for the files, read from the main branch
  2. Work in a fresh sessionOnly the commit carries over
  3. Done is read from gitCommit, branch, changed files and anything uncommitted
  4. Review, then mergeThe reviewer gets the rules for the files that really changed, and a block feeds the lessons

Rigby does the carrying and the checking, and git holds the facts. I’ve written about handing work over and cleaning up before.