Rules Files and a Prompt Library: Make the Repo Remember
If you type the same thing in two chats, it belongs in the repo. What earns a line in a rules file, a filled-in AGENTS.md, and a shared prompt library whose review prompt stops hiding real bugs.
Key takeaways
- If you type the same thing in two different chats, move it up to the rules layer.
- A rules file is read on every request, so a line earns its place only when the model cannot learn it from the code.
- Most healthy rules files are 30 to 100 lines; at 500 lines it is a wiki pretending to be a rules file.
- Asking an AI reviewer for only important issues makes it drop real bugs; review in two passes, find then refute.
- Keep shared prompts in the repo, reviewed like code, and prune them after model upgrades.
Contents
FAQ
I use several AI tools. Do I need a file for each?
Put shared conventions in AGENTS.md and keep only tool-specific extras in each tool's own file. Claude Code can point at AGENTS.md with one line in CLAUDE.md.
Why two review passes instead of one?
The session that produced a finding is a poor judge of it. A fresh session told to refute each finding cuts false positives sharply, while the first pass still lists every candidate.
Sources
Only you and the owner see your answer and rating. Send private feedback
Enjoyed it? Support fx-blog with a coffee.
Related posts
Your LLM Proxy Retries the Wrong Errors
What an LLM proxy has to decide on every failure: limits are per organization, which statuses to retry, why nothing is retried after the first streamed byte, and the headroom headers the API already sends.
Your LLM Demo Works. What Every Call Needs in Production
One timestamp in the system prompt and every call misses the cache. Pricing each call, making failures loud, logging per feature, and treating outside text as untrusted.
RAG That Works: Why Retrieval Matters More Than the Prompt
Most bad RAG answers are retrieval problems. How RAG works end to end, the three parts of the grounded prompt, how to measure retrieval alone, and when long context is enough.
Comments
Oldest firstNo comments yet. Start the conversation.
Part 1 ended with a prompt that works and a cost that stays: in every new chat you type "TypeScript, page objects in tests/pages/LoginPage.ts, pnpm not npm" again, plus the same review prompt. Those lines belong in the repo, where the model reads them on every request.
The model isn't forgetting "pnpm, not npm". Nothing persists between calls, so it never had anywhere to keep it.
AI Practices for Engineers, in 6 parts:
Three layers, and one rule for moving between them
Every AI coding tool builds what the model sees from the same three layers: rules loaded every session, context attached per task, and the prompt you type now.
CLAUDE.md.cursor/rules/*.mdc, plusAGENTS.md.github/copilot-instructions.md, plusAGENTS.mdAGENTS.mdGEMINI.mdIf your team uses more than one tool, put the shared conventions in
AGENTS.md, the open cross-tool format.CLAUDE.mdcan point at it with one line:See @AGENTS.md. These tools change weekly; when this table and your tool disagree, trust your tool's docs.What earns a line in a rules file
A rules file is read on every request, so every line taxes every task. A line earns its place when the model can't learn it from the code.
Here is the guide's
AGENTS.mdtemplate, trimmed and filled in for the auth service that will get the login rate limit:Every line is something the model would otherwise get wrong.
The review prompt that hides real bugs
Prompts you reuse belong in the repo too, because a bad one costs more than a retyped line. "Only report important issues" sounds sensible in a review prompt. Current models follow it literally: they judge each finding against your bar and silently drop the real bug they rated minor. You never see what was filtered.
The guide's fix is two passes, in two sessions:
The session that produced a finding is a poor judge of it. Run this on the rate-limit diff and the first pass lists every candidate; the second keeps only what survives.
Keep the library alive
A test-case prompt from the same library asks the model to mark guesses as
[ASSUMPTION: ...]instead of inventing them. On the rate limit, a case that depends on "per IP only, or per account too?" comes back marked. A guess you can see is a question you can answer.{{PLACEHOLDER}}; an empty one gives generic output.Try it
The conventions load in every session, and the review prompts sit one file away. You're ready to hand over the change itself: rate limiting on
POST /api/login. An agent will read the rules, edit files and run commands for an hour. How do you let it work without watching every step, and what do you do when it goes in circles? Part 3, Run Coding Agents Without Babysitting, writes the brief.Read this with your AI