Back
SiTech
AI code quality: Fabien Sanglard's agent.md rules for LLM-assisted coding
SiTech AI Team3 წთ. საკითხავი

AI code quality: Fabien Sanglard's agent.md rules for LLM-assisted coding

Programmer Fabien Sanglard published the agent.md file he uses when coding with LLMs: terse comments, strict commit messages, a test before every bug fix, and short sessions to avoid context dilution.

Programmer Fabien Sanglard published a post on 21 August 2026 titled "My agent.md to improve LLM-assisted code quality", sharing the agent.md file that coding harnesses load automatically at the start of a session.

From a bad first attempt to a usable workflow

Sanglard recalls his first try in mid-2025: he was working on libadbmdns, an mDNS implementation in Rust, and the generated code would not even compile. He revisited LLMs in January 2026, and this time the model wrote a complex indexed-binary heap class and pinpointed an obscure bug in the polling crate caused by the Windows IOCP implementation.

The code quality, however, was abysmal — spaghetti with no comments and no structure. In March 2026 he moved to agentic IDEs such as Antigravity and VS Code's Claude Code plugin, which let him iterate over the staged code. Quality improved dramatically, close to what he would have produced by hand, but repeating the same suggestions in every new session was tedious.

What goes into the file

agent.md is placed in the root of a project; gemini.md or claude.md can be symlinked to it so the rules apply anywhere. Sanglard's rules include: use as few words as possible in anything meant for human consumption; skip praise and "give me the cold hard truth"; replace magic numbers with descriptive constants or enums; reduce indentation and avoid the arrow anti-pattern with early returns; keep function names under 30 characters; use enums instead of booleans for parameters; add blank lines between logical blocks; write short comments explaining what and why, with ASCII drawings for whole systems; treat visibility changes as a breaking design shift and ask before making anything public; program to levels of abstraction with a dedicated driver layer; do not touch unrelated blocks and minimise changed lines; respect the layered boundary hierarchy instead of punching holes through layers; and always use braces, even on one-line if statements.

Commit messages and tests

The file also carries seven commit-message rules: separate subject from body with a blank line; limit the subject to 50 characters (72 is the hard limit); capitalise the first letter; no trailing period; use the imperative mood, with the test that it must complete the sentence "If applied, this commit will..."; wrap the body at 72 characters; and use the body to explain what and why rather than how. For bug fixes the rule is procedural: write the test first, observe it failing, then write the fix and observe the test passing.

Limits: hallucination and context dilution

Sanglard stresses that this is not a magic bullet. LLMs hallucinate constantly and cannot be trusted, so he still verifies and iterates — though he now focuses on architecture and design rather than code style. A second problem is context or attention dilution, described in the Lost in the Middle paper: as the context grows, a model pays less attention to instructions in the middle and more to what sits at the beginning and the end.

He found two ways to limit the effect: keep the context short by starting a new session per feature, and explicitly ask the harness to reload agent.md when quality drops — the phrase "Reload agent.md" is enough. To add a rule he does not open an editor; he asks the agent to update agent.md itself.

SSiTech

SiTech — AI-powered web development

We build fast, modern websites and bring AI into real business workflows. Have a project or a question? We'd love to help.