Your agent starts every session fresh, so it repeats the same mistakes: wrong folder, wrong style, a library you already rejected. Correcting it each time is exhausting and it never sticks. This chapter gives you the fix, a rules file the agent reads automatically, every single time.
2.3.1A rules file is your standing instructions
A rules file is a plain text file of standing instructions your agent reads at the start of every session, without being asked. It is how you beat the memory problem from the last chapter: the things that matter are in front of the agent every time, so you never re-type them.
Think of it as onboarding a new hire who arrives with amnesia each morning. The rules file is the one-page brief that makes them productive again in seconds.
2.3.2Put the non-negotiables in writing
Fill it with the decisions you never want to explain twice: your stack, where new code goes, the naming style, which libraries to prefer or avoid, how to commit, "always run the app before telling me it works."
Write them concrete, the way you would tell a person, not as vague vibes.
| Vague | Concrete rule |
|---|---|
| "write clean code" | "keep files under 300 lines, one feature per folder" |
| "be careful with secrets" | "never hardcode keys, keep them out of the code" |
| "test your work" | "run the app and confirm it works before saying done" |
2.3.3Keep it short and living
A giant rules file gets skimmed and ignored, by the agent and by you. Keep it tight, only the rules that actually matter.
And keep it living. Every time you catch yourself correcting the agent on something it should have known, add that as one line. Over a few weeks the file quietly becomes the exact brief your project needs.
2.3.4Where the file lives
The rules file lives inside your project, committed alongside the code, so it travels with the repo and every agent that opens the project reads the same rules. Each tool looks for it under its own name and place, so the simplest move is to let your agent create the right one for the tool you chose.
This prompt has your agent create its own rules file:
Act as a senior engineer configuring my agent. Create the
rules file for the tool I use, in the right filename and
place, and seed it with: my stack, where new code goes, my
naming style, and a few non-negotiables (for example: run
the app and confirm it works before telling me it's done).
Keep it short.
My tool and stack:
Do this now: paste the prompt so your agent creates the rules file, then read it and add one rule you already know you care about. Add to it every time you correct the same thing twice.