Nit: Git Rebuilt in Zig Saves AI Coding Agents 71% on Tokens
Nit: A Git Replacement Optimized for Machines, Not Humans
Developer Fielding has built Nit, a native Git replacement written in Zig that reduces token usage by 71% for AI coding agents like Claude Code and Codex, while also running 1.4-1.6x faster than Git.
The Problem
AI agents call Git constantly: status, diff, log, show. Analysis of 3,156 real coding sessions showed Git accounted for roughly 459,000 tokens of output — 7.4% of all shell commands. For Codex, over 10% of bash calls are Git.
Git's output was designed for humans: verbose headers, instructional text, column padding, decorative formatting. Machines do not need the tissue paper.
The Numbers
| Command | Git Tokens | Nit Tokens | Savings |
|---|---|---|---|
| status | ~125 | ~36 | 71% |
| log -20 | ~2,273 | ~301 | 87% |
| diff | ~1,016 | ~657 | 35% |
| show --stat | ~260 | ~118 | 55% |
Across real session data, Nit would save 150-250K tokens per coding session.
Performance
| Command | Git | Nit | Speedup |
|---|---|---|---|
| status | 13.7ms | 8.4ms | 1.64x |
| diff | 14.3ms | 9.9ms | 1.44x |
| show | 10.2ms | 7.3ms | 1.39x |
How It Works
Nit talks directly to the Git object database via libgit2 — no subprocess overhead, no text parsing. Zig's C interop is zero-cost, calling libgit2 functions directly. For unimplemented commands, it falls through to Git via execvpe(), making alias git=nit safe.
The U1 Experiment
The developer reduced diff context from Git's default 3 lines to 1 line. Testing with Claude showed no comprehension difference at U1 versus U3. Analysis of 561 real Claude Code sessions showed only 3.9% of agents read the source file after diffing, suggesting the diff itself is the primary context source.
Two Modes
- Compact (default): Machine-optimized, just the data
- Human (-H flag): Colored and grouped for human reading
Engineering
78 conformance tests covering Git edge cases: detached HEAD, merge commits, renamed files, binary diffs, submodules. The passthrough design allowed shipping early with the highest-impact commands first.
Installable via: brew install fielding/tap/nit