The guardrails file: what to fence off and the exact wording
I build Settl, an expense-splitting app, solo with Claude, and every real disaster I have had with agents happened in code I never mentioned in my instructions. Agents are remarkably good at respecting explicit fences and remarkably creative in the gray zones you left unmarked. This guide is the fence list I wish I had written on day one.
Freedom inside, hard walls around the scary stuff
Micromanaging an agent wastes the whole point of having one. The productive setup is the opposite: broad freedom to edit, refactor, and create, surrounded by a short list of hard fences around the places where a mistake is irreversible or expensive. A model will follow a clear, justified "never" with near total reliability. What it cannot do is guess which of your directories can end your week.
Fences live in the instructions file your tool reads at the start of every session: CLAUDE.md for Claude Code, or the equivalent for your setup. Not in your head, not in the chat. In the file.
The copy-paste fences block
Adjust the paths to your repo and paste this in today:
## Fences: never do these in this repo
- NEVER edit or delete existing files in db/migrations/. They have already
run in production, and editing one desyncs every environment. Create a new
migration instead.
- NEVER modify files under src/billing/ or any code that calls the payment
provider. Mistakes here charge real people real money. Propose the change
in plain text and stop.
- NEVER change session or token logic in src/auth/ without asking first. A
subtle bug here locks every user out at once.
- NEVER print, log, or commit the contents of .env or any secret. Keys leak
through logs and transcripts. Refer to variables by name only.
- NEVER edit generated files: src/generated/, *.lock, dist/. They are
overwritten on the next build. Change the source and regenerate.
- NEVER rewrite git history: no force-push, no rebasing shared branches, no
amending pushed commits. History is the one thing we cannot restore from
backup.
Ten minutes, once. It pays for itself the first time an agent stops at the wall instead of walking through it.
The six things most worth fencing
- Migrations. An already-run migration is history, not code. Editing one makes production and your laptop disagree about reality, and the failure surfaces days later in a place that looks unrelated.
- Payments and billing. The only code where a bug costs money and trust in the same instant. Fencing it is the cheapest blast-radius reduction you can buy.
- Auth and sessions. Bugs here are total: everyone locked out, or worse, everyone let in. Changes should be proposed, reviewed, and made deliberately, never as a side effect of "clean this up."
- Secrets and env files. One helpful debug line can put a live key into a log, a transcript, or a commit. Name variables, never values.
- Generated files. Edits are silently destroyed on the next build, producing the most confusing bug class there is: "but I fixed that yesterday."
- Git history rewrites. Almost anything an agent breaks can be reverted. A force-push over a shared branch cannot. Fence the irreversible above everything else.
How to phrase fences so they stick
- Imperative. "NEVER edit files in db/migrations/." Not "please be careful around database stuff." Hedged wording invites hedged compliance.
- Specific paths. Name the directory or the file pattern. A fence the model can check against a concrete file path gets applied. A vibe does not.
- Include the why. "They have already run in production." Models weight justified rules more heavily, and the reason stops the fence from being misapplied to lookalike cases, like a migrations folder in a throwaway prototype.
- Give the alternative. Every NEVER gets an "instead": create a new migration, propose in plain text, ask first. A fence with an exit keeps the work moving. A fence without one just teaches the agent to route around you.
What not to fence
Keep the list under about ten items. A forty-line fence file is a style guide wearing a security costume, and it dilutes the rules that actually matter. Fences are for irreversible or expensive mistakes only. Formatting opinions, naming preferences, and "prefer X over Y" advice belong in a different section of the same file, written as guidance, not walls.
And revisit it when the codebase changes shape. The day you add a payment provider is the day its fence goes in, not the day after the incident.
Run this on your codebase
Paste this into a Claude session in your repo:
Study this repo and draft a "Fences" section for my agent instructions file.
1. Find the dangerous zones: migration folders, payment or billing code,
auth and session logic, secret and env files, generated or vendored
files.
2. For each, write one fence: an imperative NEVER rule naming the exact
path, a one-line reason it is dangerous, and the safe alternative action.
3. Keep it under ten fences. Only include things that are irreversible or
expensive to get wrong.
Show me the block ready to paste. Do not modify any files yet.