Fabien Sanglard’s notes on getting production-grade code out of LLM coding agents — from his first attempt in mid-2025 (code that wouldn’t compile) through agentic IDEs in March 2026 to his agent.md workflow. The arc: the models got good enough, but the code quality was the blocker; the fix turned out to be a prompt-engineering file, not a better model.
The timeline
- Mid-2025, first attempt (Rust mDNS, libadbmdns): unimpressed — the code didn’t even compile.
- Jan 2026 revisit: real capability (wrote a complex indexed-binary heap; pinpointed an obscure Windows IOCP bug in the
pollingcrate) — but the quality was “spaghetti code with no comments and no structure.” Speed gains were lost to cleanup. - March 2026: agentic IDEs (Antigravity, VS Code’s Claude Code plugin). Iterating with “an infinitely patient junior CS major” got quality close to hand-written — but he kept repeating the same style suggestions every session.
The agent.md trick
Coding harnesses load agent.md from the project root and inject it into the prompt — the perfect place to fine-tune style preferences once, instead of repeating them. His version is public at fabiensanglard.net/agent.md/agent.md; symlink gemini.md/claude.md to it for cross-tool coverage. The rules he collected by noticing what he kept repeating:
- Terse human-facing text (comments, commits, replies): fewest words possible. No superlatives, no praise — “give me the cold hard truth.”
- No magic numbers/strings: extract to constants/enums (spec-derived values always).
- Reduce indentation: early return/continue, no arrow anti-pattern.
- Function names under 30 characters. Enums, not booleans, for parameters.
- Let the reader breathe: blank lines between logical blocks.
- Small comments explaining what and why, with examples; ASCII drawings for whole systems.
- Member visibility changes are a breaking design shift — keep everything private, and require explicit approval before widening.
- Program to levels of abstraction: raw I/O in driver layers, clean high-level APIs above.
- Don’t touch code unrelated to the feature; minimize changed lines.
- Strict layered boundaries — never punch holes through layers (UI never calls the database directly).
- Always
{}, even for one-lineifs. - Commit messages: the 7 rules (≤50-char imperative subject, blank line, capitalize, no period, 72-char body wrap, body explains what/why not how).
- Bug fixes: write the failing test first, then the fix, then watch it pass.
Not a magic bullet
LLMs still hallucinate and can’t be trusted — he still verifies and iterates constantly. The win is that he now reviews architecture and design instead of code style.
Context dilution (Lost in the Middle)
Long contexts make models pay less attention to the middle of the prompt (arxiv 2307.03172). Two mitigations he uses:
- Keep context short: start a new session per feature.
- When quality drops, explicitly tell the harness “Reload agent.md” to re-inject the rules.
Auto-update
Don’t hand-edit agent.md to add rules — just ask the agent to update it. The file is a living artifact, refined by the same agents it constrains.