DEV Community

Jayakrishna I
Jayakrishna I

Posted on

Your AI agents are building on code that changed. Neo catches it before the edit published: false

AI coding agents are fast. They are also confidently wrong about code they read five minutes ago.

An agent reads a function, makes a plan, and edits. If another developer or agent changed a function it depends on in the meantime, the agent has no way to know. It writes new code on top of the broken version. The mistake doesn’t surface until the tests run, or until two branches try to merge, and by then you’re paying twice: once for the bad generation and once for the cleanup.

I built Neo to move that check to the exact moment of the edit.

Repo: https://github.com/jaykrishna316/Neo

What Neo does

Neo is a set of hooks for Claude Code. Before and after each read, edit, shell command and prompt, it:

Records intent. Your prompt is saved as the reason for the edit, so the shared record says who is doing what and why.
Takes a lock on the file being edited, so a second developer or agent can’t edit it at the same time.
Blocks stale edits. If the file changed after you last read it, the edit is stopped until you re-read it.
Blocks edits to broken code. If a function’s signature changed and a caller no longer matches it, the edit to that function is stopped and the broken caller is named. Fix the caller, and the block clears.
Logs everything to a shared activity log, so you can see what happened afterwards.
The demo

The demo is a small Python project: a price() function and a total() function that calls it. A previous developer changed price() to require a tax_rate and left the caller broken. Then a single developer, Jim, starts work:

Intent is recorded. Neo logs intent set for jim before anything else happens.
The edit is blocked. Neo sees that checkout.py line 5 calls price() without tax_rate, and it stops the edit before the file changes.
The fix clears the block. Jim updates total() to pass tax_rate through. Neo confirms downstream breakage resolved.
A teammate changes the file. Someone adds discount() to the same file after Jim has read it.
A stale edit is blocked. Jim tries to edit without re-reading. Neo stops it: changed after you last read it.
The edit goes through after a re-read. Neo takes the lock, logs the edit, and releases the lock at the end of the turn.

You can see every step in the Claude session as a Neo: line. The activity log records each lock and edit, and the session transcript records each freshness check. So you can verify the stale block after the fact, not just trust the output.

Add Neo to any repo

You need git, Python 3, and Claude Code. The steps below use the command line, and they work in any git repo.

  1. Get Neo
git clone --depth 1 https://github.com/jaykrishna316/Neo ~/neo-src
Enter fullscreen mode Exit fullscreen mode
  1. Install the hooks into your repo
bash ~/neo-src/scripts/install_neo.sh ~/path/to/your-repo
Enter fullscreen mode Exit fullscreen mode

This copies the hook into .neo/ in your repo, adds its entries to .claude/settings.json (keeping any hooks you already have), and ignores Neo’s state folders in .gitignore. Run it again any time to update.

  1. Review and commit
cd ~/path/to/your-repo
git status
git add .neo .claude/settings.json .gitignore
git commit -m "Install Neo hooks"
Enter fullscreen mode Exit fullscreen mode

Your teammates get the hooks when they pull.

  1. Set a name, then start Claude Code

Neo does nothing until each session has a developer name:

cd ~/path/to/your-repo && NEO_DEVELOPER=alice claude
Enter fullscreen mode Exit fullscreen mode
  1. Check it’s running

Inside Claude Code, type /hooks and look for Neo’s entries. Then send a prompt such as What is 2 + 2?. You should see Neo: intent set for alice.

To see Neo’s state, run ls .neo_state/ in your repo. You should see an intent_alice.txt file.

  1. Try the demo (optional)
.neo/scripts/neo_repo_demo.sh setup
Enter fullscreen mode Exit fullscreen mode

This adds a small neo_demo/ folder with the breaking change left open, so you can run the six steps above yourself. When you’re done:

.neo/scripts/neo_repo_demo.sh cleanup
Enter fullscreen mode Exit fullscreen mode

*What’s proven, and what isn’t
*

Everything above is shown in a single-developer run. The checks are also covered by automated tests, which run on every change.

What I haven’t shown yet: how Neo behaves with several agents editing the same code at the same time, and how much it saves in tokens. Those tests are running now, and I’ll post the numbers when they’re done. Neo coordinates developers who share one machine. Coordination across machines isn’t built yet.

Built on Munder Difflin

The multi-agent setup in this work runs on Munder Difflin, an open-source desktop app that runs an office of coding agents on your own machine. Thanks to its authors for making it free and open to build on. The Neo integration into the app is still in progress, so it isn’t part of their release yet.

If you’re building with several agents, ask yourself one question: how do they know the code they’re working on has changed? That’s the question Neo is built to answer.

P.S: I <3 https://github.com/HarnessMD/munder-difflin

Top comments (0)