Magic Tools
Developer ToolsBy CooconAugust 24, 2026109 views4 min read

Put your code style in agent.md: Fabien Sanglard's 15 rules for taming Claude Code

Put your code style in agent.md: Fabien Sanglard's 15 rules for taming Claude Code

On August 23, 2026, Fabien Sanglard — the guy behind the annotated Doom source — dropped his agent.md on Hacker News. Seven hours later it was sitting at 147 points with 75 comments. Forget flashy prompt hacks; what he's really saying is blunt: the biggest problem with LLM-written code isn't that it can't compile. It's that it doesn't look like yours.

His framing: instead of telling your coding agent "no magic numbers" and "add a comment here" in every single session, write it all down once in a file and let the toolchain inject it for you.

From "would not even compile" to "abysmal code quality"

Sanglard's timeline is refreshingly honest. His first LLM attempt, mid-2025, produced Rust code that "would not even compile" — he walked away. By January 2026, the model could write a complex indexed-binary heap class and pinpoint an obscure Windows IOCP bug in the polling crate. But the cost: "spaghetti code with no comments and no structure."

In March 2026 he switched to agentic IDEs (Antigravity, VS Code's Claude Code plugin). Now he could iterate over "staged" code — but the experience became reviewing the work of an "infinitely patient junior CS major":

I found myself reviewing the code of an infinitely patient junior CS major with suggestions like "don't use magic numbers", "add a short comment here to explain yourself", or "use short function names".

Quality got close to hand-written. But he kept repeating himself in every new session. That's the pain agent.md exists for.

agent.md: injecting "you" into every session

The whole trick, in his own words:

When a coding session starts, the coding harness loads a file named agent.md and injects it into the prompt.

Your style preferences get "super fine-tuned" into every session. He published his full agent.md (linked below), and the rules fall into three buckets:

Category Example rules
Code style No fluff comments, avoid magic numbers, function names <30 chars, enums over boolean params
Architecture Strict layer boundaries, private by default, never touch unrelated blocks
Workflow Write the failing test before the fix, 7 commit-message rules

A few rules worth stealing outright:

  • "Avoid superlatives and praise. Stop telling me I am absolutely right. Give me the cold hard truth." — kills the AI sycophancy problem at the root.
  • "Always use {}, even on a one-line 'if' statement." — the classic dangling-else trap, banned.
  • "If the prompt indicates that a bug is being fixed, don't write the fix right away. First write the test. Observe it failing. Then write the fix." — TDD, baked into the system prompt.

Don't expect it to read code for you

Sanglard is careful about what agent.md is not:

While this "trick" has considerably improved the code generated, this is not a magic bullet that lets me avoid reading the code. LLMs constantly hallucinate and cannot be trusted.

The real win: he spends his energy on architecture and design instead of cleaning up style. He also flags a real failure mode — context dilution (from the Lost in the Middle paper). As context grows, models pay less attention to instructions in the middle. His two countermeasures: start a new session per feature to keep context short, and when quality dips, just say:

Reload agent.md is enough when I see code quality dropping.

What you can do today

Don't write your own rules from scratch. Fork his agent.md (link below) as a starting point and drop it in your project root. If you use both Gemini and Claude CLIs, symlink gemini.md / claude.md to the same agent.md — one rule set, active everywhere.

Then run his loop for a week: every time you catch yourself saying "no magic numbers" to your agent, add it to agent.md instead. Let the model improve itself.

FAQ

What is agent.md? A config file that coding harnesses (Claude Code, Gemini CLI, etc.) auto-load and inject into the prompt at session start, encoding your code style and workflow preferences. Spec discussion lives in agents.md issue #135.

Where does agent.md go? Project root. Sanglard: "Placing it in the root of a project should be enough." For multi-tool setups, symlink your tool-specific files to the same source.

Does agent.md conflict with CLAUDE.md? No. agent.md is the general spec; tools have their own files (claude.md / gemini.md). Sanglard symlinks them all to one agent.md so there's a single source of truth.

Sources

✨ Drafted by DeepSeek, edited by Claude.

Related Articles

Dev Breakfast · 2026-10-07

Today's headline: The same $200 Claude plan: what it's worth depends on which model you run. Plus 4 more: Vibe coding isn't as fun as hand-writing code: a viral HN post spells out 'frontloading the fun'; Mistral Large 4 opens preview: 1T params, 49B active, weights not out until month-end; and more.

daily-intelOct 7, 202611 min
71

Dev Breakfast · 2026-10-06

Today's headline: Wikipedia Looked Into OpenAI's Agent: Changed Configs, Probed for Holes, Crawled Millions of Pages. Plus 2 more: Opus 5.5 Found Two Room-Temperature Magnetic Semiconductors, But One Can't Be Synthesized; Beam Open-Sources 501B Weights: 23B Active, But the Weights Aren't Out Yet.

daily-intelOct 6, 20268 min
111

Dev Breakfast · 2026-10-05

Today's headline: macOS 27 kills the Apple Intelligence master switch: one script helps you evict the models. Plus 2 more: A 125B model running on a 12G GPU: up to 94 tokens/s in the official table; pstack ported to 6 coding Agents: Cursor's workflow has been carried over.

daily-intelOct 5, 20266 min
123

LM Studio Slow on a Mac? Tested: the 39-Second Wait Is Prompt Prefill, Not GPU Offload

LM Studio with gemma-4-e4b (Q4_K_M) on a 24GB M4 Mac mini: generation runs about 29.5 tok/s, and turning GPU offload from max to off costs only 11%. What really feels slow is prompt prefill — a 13K-token prompt waited 39.4 seconds for the first token (about 330 tokens/s), and 3.4–3.7x longer on CPU. A second request with the same prefix got its first token in 0.1 s thanks to prefix caching. With --parallel 4 and four simultaneous requests, each dropped to 9.7 tok/s.

local-llmmac-mini+5
pitfallsOct 5, 20267 min
101

Published by Magic Tools