Skip to content
Mihaela's Labv1.126

I Work With LLMs. My Codebase Is Learning to Need Them Less

How I run several LLM coding sessions and build an ecosystem that heals and improves itself, with a kit you can download today

I work with several LLM coding sessions every day. I am building an ecosystem so that each fix, tool and rule leaves me less dependent on them.

If you run more than one coding session at a time, you have probably seen it: two sessions edit the same file, builds pile up until the machine stops answering, something gets pushed that you never read.

Here is what you take away, ready to use today:

You getSo that
A coordinator prompt to paste into a new sessionone session keeps the others apart, in about ten minutes
A permit format tied to commit hashesonly what was checked reaches main
A three line “done” check“it is finished” can be trusted
A guard script you can adapta rule that keeps being broken enforces itself
The full rule listyou start from rules that already met real mistakes

Download the kit

Inside: both prompts, the request form, the rule list, templates for a starting document, experts and the exam, two git checks, the search guard and a test. MIT License.

Ten minute setup

Open a new session, paste this, and tell every other session to ask it first.

Paste into the coordinator
YOUR ROLE
You are the coordinator. You write no product code.
Keep a log file: one line per decision, with the time.

ASK FIRST
Other sessions must ask you before:
  - a full build or test run
  - editing a shared area
  - pushing to main
  - publishing
  - opening a window
  - using a device

YOUR ANSWERS
Answer each request with one of:
  GRANTED
  GRANTED WITH LIMITS
  WAIT    (on whom)
  DENIED  (why)

ONE HOLDER
One holder per repository or named area at a time.

PUSH PERMITS
A push permit is for one commit hash on one parent.
Before granting:
  - read the head of main again
  - confirm it is a fast forward
  - compare the changed files with what the request described
A new hash needs a new request.

WHAT IS A YES
Only a clear yes from me is a yes.
A question is not a yes, and a yes passed on by another
session is information, not permission.

FINISHED
Work is finished only when:
  - it is on main on the server
  - my clone is at that commit
  - that clone is clean
List everything else as not finished.

And in each working session:

Paste into every working session
Before anything shared, ask the coordinator
and act only inside its answer.
If there is no coordinator, tell me and change nothing.
End every report with:
  checked, not checked, cleaned up.

Why it works

Several sessions at once are a concurrency problem: shared state, no lock, and every actor sure it is safe. The fix is the one you already know from code.

What a day looks like

I do not manage the sessions one by one. I talk to whichever one owns the thing I care about, in its own window, and they deal with each other through the coordinator.

A typical exchange, shortened:

An editor session asks orca
editor:  May I take an own branch of the editor,
         run the tests on a simulator,
         and ask for a push afterwards?
orca:    Granted. One build at a time, load under 30.

editor:  Push <hash> to main,
         parent <hash> read at 07:25.
         Tests pass, tablet simulator walked.
         Not checked: screen reader, a real device.
orca:    (reads main again, compares the changed files)
         Granted for that commit.

editor:  Landed. Main and your clone are at <hash>,
         clean.

Meanwhile another session is converting templates, a third is drawing, and a fourth is waiting for a build slot. I see the lines that matter: what landed, what was not checked, and the few questions only I can answer.

Most of those questions are small. May a window open on my screen now? Which of two names? Keep this behaviour or change it? Everything else the sessions settle among themselves, and I can read the log if I want to know how.

The model

ConceptHere
Shared staterepositories, the machine’s cores and memory, the screen, my devices
Actorsthe sessions
Locka permit with one holder
Compare and swapa push allowed for one commit hash on one known parent
Commit pointmain on the server, and my clone showing it

One extra session writes no code and only grants permits. The rules it applies are below, each with the problem it removes.

Several sessions ask orca before anything reaches maineditor to orca; templates to orca; drawing to orca; orca to main on server; main on server to my cloneeditortemplatesdrawingorcamain on servermy clone

Two words I use

WordMeaning
orcamy name for the orchestrator: the session that says whether work may start, a repository may be edited or a commit may be pushed, and that remembers who holds what
landedon main on the server, cloned on my machine, and that clone clean and current. Anything less is “not landed”

Rule 1: ask before anything shared

A request is short and complete:

A push request
who:          editor session
repository:   editor
action:       push to main

commit:       <hash>
parent:       <head of main>, read at 14:05

checked:      tests pass, builds pass
not checked:  on a device

The answer is one of four: granted, granted with limits, wait, denied.

What the coordinator weighs

An answer comes from four questions, and I make the coordinator think about all four every time.

QuestionWhat it looks at
ResourcesHow many builds can this machine run at once? What is the load now? Is the screen, a device or a paid limit involved?
OwnershipWho is already touching this code? Would two areas collide, for example two sessions appending to the same index?
WaitingWho is waiting for whom? Is there a cycle, with two sessions each waiting for the other?
ContextWhat did I ask for last? What am I looking at right now? What has really been verified?

No working session can answer these. It sees its own work. The coordinator sees all of it, and that difference is the whole reason it exists.

The board

The coordinator keeps one plain file: each session, its repository, the area it holds, what it is doing, whether it is running, waiting or done, and one line for every decision with its time. When something goes wrong, I read the board. It is the cheapest debugging tool I have for the process itself.

A holder that goes silent past its time is asked to push what is sound to a work-in-progress branch and let go, so the next one can start.

Rule 2: the hash is the permit

“You may push your fix” is not a permit. “You may push this commit onto that parent” is. If the session rebases or amends, the permit is gone.

Before answering, the coordinator checks three things:

# is the parent still the head?
git ls-remote origin main

# fast-forward only
git merge-base --is-ancestor <host> <ask>

# only what the request described?
git diff --stat <host> <ask>

The third line catches the most: a change that is larger than its description.

What happens to a push requestcommit and parent to three checks; three checks to granted; three checks to not granted; granted to push that commitcommit and parentthree checksgrantednot grantedpush that commit

Rule 3: done means landed

“Done” once meant many things: committed, pushed to a branch, tested somewhere. Now it means three at once.

Landed means three things at oncefinished step to on server main; on server main to my clone there; my clone there to clone is clean; clone is clean to landedfinished stepon server mainmy clone thereclone is cleanlanded
# on main on the server
git ls-remote origin main

# my clone is at that commit
git -C <my-clone> rev-parse HEAD

# and it is clean
git -C <my-clone> status --porcelain

Anything else is listed as not landed, with its branch and the reason. Every report ends with what was checked and what was not. The second list is the useful one.

And land after each step. A finished step is tested, pushed and visible in my clone before the next one starts. Unfinished or failing work never goes to main: it goes to a work-in-progress branch and is named. Long-lived branches that nobody remembers are where work goes to disappear.

Seen, and not seen

A green test run does not mean the feature works. A test that draws a view proves drawing and logic. It says nothing about:

  • whether a finger reaches the button

  • where the keyboard focus goes

  • what a screen reader says

So a report names what ran it:

Line in the reportMeans
“Tests pass”the tests ran
“Seen on a real device”someone looked, and it is only written then

The habit of writing not seen changed more for me than any other single line, because it turns an assumption into something I can decide about.

Pin what you approved

When I look at a screen or an animation and say yes, that state is pinned the same day:

  1. the commit gets a tag with the date and my words

  2. a test asserts the numbers I approved

  3. changing it later needs permission that names the tag

I started doing this after an animation I had liked was quietly lost in later work.

Nobody broke a test, because no test knew what I had approved.

Rule 4: the machine is a shared resource

  • Two slots in use, three jobs waiting

Builds are greedy. Several at once are slower than one after another, and at some point nothing answers.

  • Read the load before a heavy run. Over the limit, wait.

  • One slot is one full build or test run.

  • One simulator at a time.

  • Test windows stay off the screen unless I say it is free.

I learned this one the usual way: several simulators and two builds together, a load in the hundreds, and swap nearly full.

The number that works is the one you measure. Read what a single build really uses on your machine, decide how many fit, and let the coordinator hand out that many slots. A failure seen on a loaded machine is run again alone before anyone calls it a failure.

My screen and my devices

My screen is a resource with exactly one user, and that user is me. A test that needs a window parks it outside every screen and never takes the keyboard. A test never types a key combination without checking, at that moment, that its own window is in front: a shortcut sent to the wrong window can close your work.

A phone or a tablet is the same. A session asks, says what it will do and for how long, says it again just before it starts, and puts things back.

One voice at a time

My sessions can talk to me. That is useful for exactly as long as only one does it. There is one speech queue on the machine, each session has its own voice, every spoken line begins with the session’s name, and it is short. A session speaks when it needs me, when something big is finished, or when I ask.

A small hook refuses any attempt to speak around the queue. Courtesy, enforced.

More than one machine

  • One main machine, and others that only do the work

Sessions elsewhere. A session can run on another of my machines and still be part of the same system. With remote control it appears in the coordinator’s list beside the local ones: it asks the same way, gets the same four answers, and its finished work is checked the same way, on main on the server. If it goes offline, nothing is assumed about it; what counts is what reached the server.

Machines without a session. My Mac minis mostly run no session at all. A session on my main machine reaches them over SSH and sends them work: builds, long test runs, a test database. Each has its own slot queue and its own load limit, runs one heavy job at a time, works in its own copy of the repository on an external disk, and is left as it was found. Tests that would open windows go there, so my screen stays mine. A timing measured on one machine is never compared with a timing from another.

What it taught me. A connection to one of them died in the middle of a run. A test waited on a database that was no longer there, and held the only build slot for more than six hours while others queued behind it. Now every remote run has a time limit, progress is checked by looking at the process, and the slot list is read before a long run starts.

The shape of it, as a sketch (mini is the other machine, slot stands for whatever hands out build slots):

ssh mini 'uptime'                                  # is it free?
ssh mini 'cd work/project && slot build -- swift test'

Rule 5: a question is not a yes

  • A message typed into the wrong window is passed on

The coordinator does not act on a reply that could be a question, and it does not treat “another session says it was approved” as approval. Both rules cost a few seconds. Both have prevented actions nobody asked for.

And typing into the wrong window

With many windows open, I type into the wrong one. While preparing this article I sent nine instructions in a row to a session that was building something else. Nothing was lost: it passed them on, in my words and in order, said what it had already done for each, and stopped. The coordinator then checked that it had all of them before acting.

The rule is short: a message meant for someone else is relayed word for word, with what was already done about it.

Rule 6: a rule broken twice becomes a check

  • What fits goes through, what does not is stopped

This is the rule that made the others stick.

My documentation search matches keywords. The written rule said to send one to five terms. Sessions still sent sentences, because a rule in a document is read once and forgotten under pressure. So it became a small script that runs before each search:

#!/bin/sh
# Refuse a documentation search of more than five words.
# Reads the tool call as JSON on standard input.
# Exit 2 refuses it.
input=$(cat) || exit 0
query=$(printf '%s' "$input" |
    /usr/bin/plutil -extract tool_input.query raw -o - - \
        2>/dev/null) || exit 0
words=$(printf '%s' "$query" | wc -w | tr -d ' ')
if [ "$words" -gt 5 ]; then
    echo "BLOCKED: $words words. The index matches keywords:" \
        "send 1 to 5 exact terms." >&2
    exit 2
fi
exit 0

Register it to run before the search tool. The script reads the call, and the exit code decides.

Here it is, fed one short search, one sentence, and something it cannot read:

Trying the guard
$ ask() { printf '%s' "$1" | ./guard.sh; echo "exit $?"; }

$ ask '{"tool_input":{"query":"List selection"}}'
exit 0

$ ask '{"tool_input":{"query":"how do I animate a list"}}'
BLOCKED: 6 words. The index matches keywords:
send 1 to 5 exact terms.
exit 2

$ ask 'hello'
exit 0

Three properties are worth copying:

  1. It fails open. If it cannot read its input, it lets the call through. A broken guard must not stop all work.

  2. The message says what to do instead. A refusal without a way forward invites a workaround.

  3. It has tests, including cases that must pass and cases that must fail.

The same shape works for anything a machine can recognise: speaking out of turn, writing to a disk that should stay empty, forbidden words in a commit message.

Rule 7: write the story with the rule

Each of my rules carries the date and the thing that went wrong. Without it, a rule looks like bureaucracy and gets argued away. With it, everyone, including me a month later, knows what it protects.

Rule 8: oracle first

  • One input, two answers, one comparison

Before building, rebuilding or extending anything that must be correct, build the oracle: the source of the right answer. Decide, before any production code:

  1. The question: what does correct mean here?

  2. The input domain: which cases count, including empty, boundary, malformed and largest?

  3. The authority: who has the last word when two sources disagree?

  4. The equivalence: when are two results the same? Exact equality is the default; a tolerance is derived or measured, and named.

  5. The failure report: what will a mismatch tell me?

An oracle can be a closed formula, a slow and obvious implementation, the behaviour of the system being replaced, or the real platform observed directly. Fast paths prove they agree with it, or fall back. Every case is handled, failed, or named as unsupported or blocked. Skipping silently is not allowed.

A fast path has to agree with the oraclethe same input to oracle; the same input to fast path; oracle to same result?; fast path to same result?the same inputoraclefast pathsame result?

I wrote about one in detail: The SwiftUI Oracle, where a from-scratch engine is held against real SwiftUI in 125 differential tests.

With many sessions this matters more, not less. A session that grades its own work with its own assumptions will be satisfied. One that has to agree with an oracle cannot be.

Rule 9: every finding is a file, and every session cleans up

  • Findings are kept, leftovers go

A bug, a gap or a follow-up becomes one Markdown file in the repository the moment it is noticed, not at the end of the day and not in a chat message that scrolls away. It travels with the code, shows up in a diff, and any session can read it.

Before a session reports that it is done, it removes what it created: temporary files, build folders, processes, locks, its own working copy once pushed. It keeps only evidence and hand-over notes, and names them. It never removes another session’s work. The last line of every report says what was cleaned up.

An ecosystem that heals itself, so I need LLMs less

I am building a self-healing, self-improving ecosystem so that I depend on LLMs less and less

This is the part that matters most to me.

All of this runs across more than 300 repositories, and the goal is for the whole to behave like a small living and breathing ecosystem:

  • Each part lives from the others

  • It breathes

    Work flows in, lands, and flows on to everything that uses it.

  • It heals

    A fault goes to its owner, is fixed with the test that holds it fixed, and the fix reaches every user.

  • It improves

    Each lesson becomes a note, a check or a tool the others then have.

  • It grows

    Small building blocks are put together into new things.

This describes how I work toward it, not a claim that every repository is already there.

How I am working toward needing LLMs less

The more I use LLMs to drive my tools, the less dependent I am on LLMs. This is the direction I am working in. I have not measured it, and it is not finished.

What I doSo that, without an LLM
every tool explains itselfI can use it with no model and nobody to ask
repeated work becomes a generator with a check modeI can run it by hand, from documented commands
a mistake a machine can recognise becomes a gateit is refused with nobody watching
knowledge is written downa person can read it
How each lesson makes me depend on LLMs lessI use my tools to a gap shows up; a gap shows up to note, check, tool; note, check, tool to the system heals; the system heals to less LLM neededI use my toolsa gap shows upnote, check, toolthe system healsless LLM needed

Every piece of work leaves it better

If you keep one idea from this article, keep this one. Every piece of work should leave the system better able to do the next one.

WhenWhat is added, in the same step
something surprised, or cost time to finda note in the repository, and in a shared knowledge repository when it holds beyond it
a fault is foundan issue file, then a test that fails, then the fix
a mistake could happen againa gate that refuses it before a push
a check let a fault througha stronger check, proved by planting the fault
a tool is missing or wronga request to the tool maker, so the tool exists for everyone next time
From a fault to a gate that refuses itfault found to issue file; issue file to failing test; failing test to the fix; the fix to gate before pushfault foundissue filefailing testthe fixgate before push

Checks only get stronger. One is never switched off to let a change pass, and a list of old debts may only shrink.

And it gives me freedom and speed

  • Freedom and speed

What does this kind of work give me? Freedom and speed.

When I needI use
a new websitemy own engine, TileDown
an image drawnmy own drawing engine
a new Xcode projectmy own template engine

One session builds the tools

One session has a single job: my own command line tools, 64 of them so far. I call it Workbench. It is open whenever other sessions are working, and it watches for what they are missing. When a session needs a tool, or finds one broken, it does not improvise or work around it: the request goes to Workbench, which builds or mends it, tests it and installs it. From then on every session has it.

The effect compounds. A gap one session hits in the morning is a command the others use in the afternoon.

Gates, not promises

Each repository carries one command that runs all its checks, and the push hook runs it: format, lint, tests with warnings treated as errors, naming rules, and firewalls that refuse code in the wrong layer.

Building blocks

Building blocks are libraries and tools that each do one job, stand alone and are tested alone. One session tests another’s work simply by using it from outside, without the author’s assumptions, and what it finds goes back as an issue. Nobody declares a foundation: a part of one product becomes a library when a second user appears, and the more repositories rely on it, the better it gets and the stronger its checks must be.

I aim for no external dependencies, so that nothing the system lives on can be taken away. It is an aim with a few named exceptions, such as a formatter and a linter, and each one is a decision, not an accident.

One session tests another

When several sessions work, you get something a single author never has: a user who does not share your assumptions. A session that takes someone else’s library tries it on its own real case. What it finds goes back to the owner as an issue file. It does not patch the other’s code and does not work around the fault.

When a review must be independent, the reviewer is given the code and the question, not the author’s conclusion. Hand someone your hypothesis and you tend to get it back confirmed.

Knowledge that outlives a session

A session forgets everything when it ends. The system must not. Whatever cost time to learn is written where the next one will find it: a note beside the code that depends on it, marked as measured, documented or unverified, and a copy in a shared knowledge repository when it holds more widely. At the end of a long day, the notes are the difference between continuing and starting again.

Leave a way back in

  • The next session starts from the page you left

A session ends: the day is over, a usage limit is near, or the work simply has to wait. Anything unfinished then gets a starting document, written for someone who knows nothing about today. The next session reads it first and starts working instead of rediscovering.

Unfinished work goes to a work-in-progress branch, and beside it, in the repository, goes this. It is a template:

# Onboarding: <the work>

## Start here
Read this, then <the two or three files that matter>.

## Where it stands
On main: <commit>.
Not on main: <branch, commit>, because <reason>.

## What works, and how it was checked
## What does not work, or was not checked
## The next step
The first command to run and what you should see.

## Decisions already made (do not reopen)
## Waiting on me
## Traps
What cost time, so it is not paid twice.

The coordinator leaves one for itself too.

The test of a good one: could a new session start from it without asking me anything?

Experts: ask the repository that knows

  • Send the question where the knowledge lives

Some repositories are experts on one subject. In one place live:

  • their code

  • their notes

  • their open issues

  • their measured facts

Experts are not appointed, they are promoted. A repository that goes deep into a subject becomes its expert when many other repositories and sessions turn to it. From then on questions on that subject go there, and its notes and checks get held to a higher standard.

An expert has usually done a lot of research before anyone asks it:

  • reading documentation

  • reading slides and articles

  • debugging, and similar hands-on digging

I also keep a separate organisation, ResearchHQ, with repositories on the subjects.

orca keeps the list of experts: one subject, one repository. A session that needs to know who the expert is asks. A few of them, as examples:

SubjectExpert repository
DrawingPureDraw
How SwiftUI worksPureView
PDFMarkdownPDF
Static sites and the blogtile-down
Apple documentation searchcupertino

When a piece of work needs that subject, I do not teach it to the session I am in. I open a new session in that repository or organisation. It reads what is there and starts as the expert.

Drawing is an example. When something has to be drawn, it goes to PureDraw, my own drawing library, and the other portable libraries around it. The expert session draws, or extends the library when it cannot yet, and what it learns is written back, so the next expert starts further ahead.

The coordinator knows which expert exists and sends the question there. When work needs an expert and none is open, orca tells me:

  • which repository to open a session in

  • what to ask it

  • who is waiting

I open it.

  • Even the coordinator drops a line

Where it fails

The coordinator is also a session, and it is wrong sometimes. It has released too many waiting sessions at once, and it has called a problem solved that came back. Two things limit the damage: it keeps a log with one line per permit, and permits are narrow, so a wrong one is small.

It has also allowed a test run on my main machine although some of those tests opened windows, and it has granted work before I had decided what I meant. Each of these ended the same way: a note, and a sharper rule.

It also costs something. Watching takes part of the allowance the real work could use, so its regular check is one command and two sentences. Asking takes a moment each time. The rules need tending, and a rule nobody can explain any more should be removed.

And it does not replace judgment. Someone still decides what to build, looks at the result, and says whether it is good. That is the part I keep.

  • Ask, and get an answer

Questions you may have

Is this not slower? A single task is a little slower. A day is much faster, because nobody redoes work that another session overwrote, and nobody waits on a machine that stopped answering.

Do I need ten sessions for this? No. The permit, the hash and the “done” check are worth having with two.

What if the coordinator is not running? Then nothing shared happens. The working sessions read, answer and wait. It sounds strict, and it is why the rules hold.

Can the coordinator just do the work itself? It should not. The moment it writes product code it has its own interest in the answer, and nobody is watching the whole picture.

How do I know a rule is working? Plant the fault it should catch and watch it fail. A check that has never refused anything may not be checking anything.

Adopt it in stages

StageAddYou notice
1The coordinator, one holder per repositoryno more two sessions in one file
2Push permits by hash, the three line “done” checkmain contains only what was looked at
3Load limits, build slots, rules for screen and devicesthe machine stays usable
4“Checked” and “not checked” in every report, issue filessurprises move earlier
5Gates in every repository, checks for broken rulesthe rules stop depending on memory
6A session that builds tools, shared knowledgethe system starts to improve itself

Do not add them all in one day. Add the next one when you feel the problem it removes.

Take it with you

Paste the coordinator prompt, then add one rule at a time. The first day you will notice the “not checked” lines. The first week you will notice what no longer happens.

The full list is in the coordination rules. Cut what you do not need, and add the rule your own bad afternoon teaches you.

Download the kit

Inside: both prompts, the request form, the rule list, templates for a starting document, experts and the exam, two git checks, the search guard and a test. MIT License.

  • The vital parts first, beside what exists

One thing I keep wishing for

I built this for myself. I often wish I could do the same for a business: not by rewriting it, and not by selling it a platform, but by starting where it lives.

  1. Find the base. Where does money come in, what was promised, what must never be wrong?

  2. Name the vital organs. The three to five parts without which it stops: taking an order, getting paid, keeping the records, delivering. Everything else waits.

  3. Say what right means before building: the cases, the expected answers, and who decides when two differ.

  4. Build those first, one at a time, small and standing alone, beside what exists, until both agree.

  5. Test them hard: ordinary cases, edges, broken input, two people at once, the network gone.

  6. Let it grow. Each new part uses the last one, and so tests it. What is learned stays in the system, not in one head.

If you already know which part of your business you could least afford to lose, you know where I would start. I would be glad to hear which one it is.

A side note

Everything here was made with my own tools: the pictures, the diagrams and the page itself. Some of those tools I share, like [TileDown](https://codeberg.org/TileDownHQ/tile-down), and some I don't.

Apple UI Insider

A free newsletter on how Apple frameworks really work, from Core Graphics and Core Animation to SwiftUI and motion systems.

Powered by Buttondown.