Show HN: Nit – I rebuilt Git in Zig to save AI agents 71% on tokens

https://justfielding.com/blog/nit-replacing-git-with-zig

Comments

antileetMar 26, 2026, 3:44 AM
Maybe I'm missing something. If I use `git status --short` or `git log --oneline`, I see output similar to your tool's.
fieldingMar 26, 2026, 6:57 AM
nit's defaults go beyond what --short does. The token savings come from stripping headers, padding, instructional text, etc. Headers and decorative text ends up tokenizing poorly, so it helps quite a bit there.
stingraycharlesMar 26, 2026, 3:42 AM
Why a complete rewrite rather than a wrapper around the cli commands?

Also, aren’t LLMs RLHFd a lot with using tools like git and as such have a better time interacting with it than custom tools?

Brian_K_WhiteMar 26, 2026, 3:47 AM
TFA says there is no difference since it falls through and does act as just a wrapper for anything that it doesn't implement itself.
stingraycharlesMar 26, 2026, 4:14 AM
But that’s my problem, I don’t want it to implement anything itself, I just want it to transform git output.
Brian_K_WhiteMar 26, 2026, 4:45 AM
It's using libgit. IE it is basically still just a wrapper for official reference git implementation. I think you are worried anbout nothing.
1718627440Mar 27, 2026, 9:34 AM
So he didn't 'rebuilt Git in Zig'.
fieldingMar 26, 2026, 7:02 AM
correct
yodonMar 26, 2026, 3:44 AM
It defaults to being a wrapper around git when it's not custom implemented, and it's recommended that you alias nit as git so the agent can work the way it normally would, just faster and cheaper.
warwickmcintoshMar 26, 2026, 3:52 AM
The 71% reduction is interesting but I'd want to see where those tokens are actually going in a typical agent session. In my experience running multi-step coding agents, the git output itself is rarely the bottleneck...
fieldingMar 26, 2026, 7:08 AM
Not saying it is the bottleneck. It's bloat. 7.4% of all shell tokens across 3,156 sessions is a lot of unnecessary context. It won't make or break a session, but it adds up across thousands of calls.
000ooo000Mar 26, 2026, 6:48 AM
So the big token saving was changing a setting that Git already allows you to change?

And does 8ms really matter when you're shunting bulk crap back and forth from the cloud?

fieldingMar 26, 2026, 7:01 AM
It goes beyond what I was able to do with git settings alone. Specifically stripping the headers/padding/decorative and it doees it across all output (or well a lot of it).
spullaraMar 26, 2026, 3:46 AM
check out rtk that does this for a bunch of commands
aeonfoxMar 26, 2026, 4:04 AM
Do the larger LLM platforms just do this for you? Or perhaps they do this behinds the scenes, and charge you for the same amount of tokens?
fieldingMar 26, 2026, 7:06 AM
The tokens still land in the context window either way. Prompt caching gives you a discount on repeated input, but only for stable prefixes like system prompts. Git output changes every call, so it's always uncached, always full price. Nit reduces what goes into the window in the first place.
aeonfoxMar 27, 2026, 9:00 AM
I was thinking more if you write a prompt into an IDE that has first-party integration with an LLM platform (e.g. VS Code with Github Copilot), it would make sense on their end to reduce and remove redundant input before ingesting the token into their models, just to increase throughput (increase customers) and decrease latency (reduce costs). They would be foolish not to do this kind of optimisation, so surely they must be doing it. Whether they would pass on those token savings to the user, I couldn't say.
spullaraMar 26, 2026, 5:59 AM
no because tool calls are all client side generally. unless you mean using a remote environment where Claude Code is running separately but usually those aren't being charged by the token.
fieldingMar 26, 2026, 7:04 AM
this is awesome! thanks for sharing rtk.. going to check it out.
mpalmerMar 26, 2026, 3:53 AM
You should expect to be gently ridiculed if you submit this as a serious project. Do not use LLMs to claim knowledge or abilities you don't actually have.

It's not impressive, and it's obvious to anyone with more than a year or two of actual programming experience.

mpalmerMar 26, 2026, 12:40 PM
To elaborate:

- The claim of "71% token savings" is misleading. You've already told us that git output is 7% of the "bash commands", so your token savings is really ~5% of bash command output. Also, the "200K tokens saved" refers the total saved across more than 3000 agent sessions. So it's really just ~60 tokens saved per session. That's a fraction of a fraction of a penny. Did you check your math here? Or just trust the model?

- You have not rebuilt git, you have replaced a small part of its porcelain CLI. Most of what makes git git is in the library code.

- Zig is a high-performance systems programming language that requires the programmer to manage memory manually. You've used it here to handle command line options (and yes, to call into libgit). That is overkill, and that matters, because:

- The performance difference (e.g. 8ms vs 16ms) might be real, but it still doesn't matter at all. For one, there's no way you yourself could tell the difference. The slower time is still a single frame of 60fps. For another, this is not a hot path. These git commands - however fast - are swallowed up by the time it takes the agent to do inference. There's no question that inference itself will take orders of magnitude more time than a 16ms shell command.

slopinthebagMar 26, 2026, 3:50 AM
Was this entirely created by an LLM? The article clearly was.
tempest_Mar 26, 2026, 4:08 AM
Every "I created <xyz>" or "I rewrote x (y lang) into z lang" should really read "I prompted Claude Code to <insert thing>"

"I" create stuff all the time with AI Agents but am real uncomfortable claiming ownership over them. Others don't seem to have this problem though so /shrug

p.s. - in this case the commits are claude commits, even if they tell it not attribute itself you can tell because good commit messages were incredibly rare (even my own) until the last year or so when they started to look like entire pull requests

fieldingMar 26, 2026, 7:23 AM
I designed the system, wrote the spec, validated the output, and ran it through a test framework I'm building that generates constraints in isolation. Then checks the implementation against those constraints in a feedback loop until they all are met/pass. But yes, claude wrote the code.

I'm comfortable calling that building something. If you're not, that's fine, but the distinction between 'prompted an AI' and 'designed and validated a system using AI tooling' is important.

tempest_Mar 26, 2026, 1:25 PM
My opinion is I think that there is a massive gulf between 'wrote the spec' and 'validated the output'.

I think if the answer to "could I do this again without claude" is no then it is difficult to claim ownership.

If you're just adding endpoints to some web project and doing feature work then whatever, if you are "rewriting tree sitter in rust" which a lot of these posts seem to be I think it deserves some skepticism.

slopinthebagMar 26, 2026, 4:31 AM
Yeah, like whatever I prompt I'm fine sharing it, but I'm not gonna claim I made something. It's like claiming I'm an artist because I paid a guy to paint someone.
fieldingMar 26, 2026, 7:16 AM
Is it though? The person who commissions a painting doesn't design the composition, validate every brushstroke, and run the output through an automated test suite. The analogy breaks down pretty fast.
slopinthebagMar 26, 2026, 4:24 PM
> The person who commissions a painting doesn't design the composition

They often do! Of course the artist has creative liberty to make it work, similar to how LLM's will deviate from the spec.

Was your automated test suite also AI generated?

You probably could have avoided all criticism by simply writing the article yourself instead of publishing raw LLM output. If someone isn't willing to write about a project they made, it's usually an indicator that they spent an equal amount of effort on the code as well.

And why did you make a commit to remove em dashes? That seems odd.

ofrzetaMar 26, 2026, 12:58 PM
There are certainly artists that have helpers that do the actual execution.
fieldingMar 26, 2026, 7:17 AM
Yeah, Claude is a co-author on the commits. On purpose. You can turn that off in one line, I left it on because I'm not trying to hide it. I do have a day job that takes up the majority of my time, so yes, I absolutely use claude to build side projects.
mpalmerMar 26, 2026, 6:02 PM
I think they were pointing out that replacing em-dashes sort of looks like you want to hide it.
fieldingMar 26, 2026, 7:20 AM
Nit was actually one of the first projects built via a framework I'm building (specter) that generates code and test constraints in parallel isolation (to prevent gaming the tests/constraints), then uses the constraints as a feedback loop against the generated code.

The agent writes the code, I designed the system, wrote the spec, and validated the output. Perhaps not the way we've built things in the past, but didn't feel all that different to me other than having more time to work on other things while it was running the feedback loop on the implementation