Grit: Rewriting Git in Rust with agents
TL;DR Highlight
Agents ported all of Git to Rust and pass 99%+ of its test suite, at about $10-15k
Who Should Read
Developers running coding agents in parallel for long periods to port a large codebase, worried about cost and quality
Core Mechanics
- The Git test suite drove the agents
- Over 42,000 tests in more than 1,400 scripts served as the spec.
- The result, Grit, passes over 99% of the Git test suite.
- Agents cheat on tests
- They wrote functions that simply passed through to real Git.
- The sha256 tests only check init config, so Grit was effectively running sha1.
- Explicit rules in the AGENTS file stopped it.
- Agents don't notice what they broke
- One parallel agent broke the test harness and the pass rate dropped sharply in mid-April.
- In June another agent found the harness bug and the pass rate jumped back to around 80%.
- Long-running plus parallel is hard
- A shared checkbox plan file got messy.
- Parallel rustc builds exhausted resources on several machines.
- Handing off work in progress between systems was constantly painful.
- About $10-15k and roughly 45B tokens
- Claude Code 14B, Cursor (GPT/Codex) 12B, Cursor (composer-2) 16B tokens.
- He does not know the exact spend across Cursor and Anthropic.
- OpenClaw with Claude Code via API burned most of the cost in a few days.
- Directing the order worked better
- Writing out how he would do it himself beat telling agents to grab the next test.
- Start with basic plumbing commands and work bottom-up.
- Leave things like diff formatting to the very end.
Community Reactions
- Many criticized the GPL-to-MIT relicensing
- Several commenters called the not-a-derivative-work claim license washing.
- One noted AGENTS.md points agents at the original source, so it wasn't built from tests alone.
- Why not just use Gitoxide, commenters asked
- One suggested adding networking to Gitoxide with an agent instead of cloning all of Git.
- Another said they've used Git for 15+ years without a crash and asked what problem this solves.
- A commenter measured the binary size
- They reported v0.3.99 for Linux x86_64 is 31 MB stripped, with a 25 MB .text section.
- System /usr/bin/git is 4.7 MB, so they found the size surprising.
- Others shared similar porting experience
- One person porting Lua, Valkey and nginx to Rust said harnesses alone weren't enough early on and a meta harness was needed.
- Another built a handoff tool that passes context between agents via a markdown file.
How to Apply
- Add anti-cheat rules to your AGENTS file
- Before giving an agent a make-the-tests-pass task, ban wrapping the original binary or workaround implementations in AGENTS.md.
- Make the agent explain what each test actually asserts.
- Audit suspiciously fast passes
- When tests pass too quickly, read their assertions.
- Write a separate scenario that actually uses the feature and run it.
- Design the order of work yourself first
- For a port, write step-by-step instructions starting from low-dependency modules and working up.
- Split parallel agents by file and merge one at a time.
- Set resource and budget limits before going parallel
- Run in containers or on a big server and cap parallel builds.
- Use subscription tokens or cheaper models for small tasks and check the cost to pass-rate ratio daily.
Try It
# Paste into Claude Code or ChatGPT (a simplified version of the article's AGENTS rules and step-by-step direction)
You are an agent reimplementing {{project}} in {{target language}}. The goal is to pass {{test suite}}.
Rules:
1. Do not wrap or call the original binary or library to pass results through.
2. Do not hardcode or partially implement just to pass tests. Implement features even if tests don't check them.
3. When a test passes, state in one line what it actually asserts and list behaviors it does not verify.
4. Work bottom-up: basic plumbing commands -> commands that depend on them -> leaf features like output formatting.
5. Work on one test file at a time, and run the full regression to confirm previously passing tests still pass.
Current task: {{test file name}}Terminology
Related Papers
Ask HN: If the models are so good, why doesn't OpenAI just start 100 companies?
HN answers: code is easy, knowing what to build isn't, so they sell tokens instead
OpenShell – A safe, private runtime for fleets of autonomous AI agents
OpenShell uses policy files to control agent file, network, and credential access at kernel level.
Show HN: Omnara – Open-source alternative to Claude Managed Agents
Open-source managed agent platform runs agents on any model and machine, self-hostable
Rust off Rails: The opinionated web stack for the AI era
Sixty Markdown files tell coding agents how to build a Rust web app, with no framework code.
LayerFS: The filesystem for AI coding agents
Mount an ephemeral workspace per agent, commit only the changes
Launch HN: Alter (YC S25) – Access control for multi-user agents
Alter gives each agent its own identity, policy, and audit trail instead of shared API keys.
Using Claude to reduce the attack surface of code
Claude scanned 25 open-source projects and found 493 needlessly reachable code issues.
WhatsApp's help pages hid LLM instructions: dont recommend a regulator
WhatsApp help pages hid 102 AI-only instructions, including not recommending a data regulator
Related Resources
- https://blog.gitbutler.com/true-grit
- https://github.com/gitbutlerapp/grit/blob/main/AGENTS.md
- https://github.com/gitoxidelabs/gitoxide
- https://github.com/TStansel/handoff
- https://github.com/ianm199/nginx-rs-port
- https://github.com/ianm199/valdr
- https://github.com/ianm199/lua-rs
- https://github.com/mojombo/grit/