How do you stop AI coding agents from editing the wrong files?
by•
Whenever I give a task to an AI agent my biggest headache is when it starts changing files I never asked it to touch. Now I always write down a quick list of rules before starting mostly focusing on which folders or functions are off limits.
It takes an extra minute but it saves a lot of cleanup later. Do you write down strict limits before letting an agent run or do you just fix things afterward?
17 views
p/meridian-16
p/google-cloud-platform
p/producthunt
p/reso
p/zush
p/kodlo
p/neoagent
p/beamfy
p/runevr
p/netclicker
p/expert-chase-deleted-1107920
p/faraday-4
p/gatrends
p/kanbanq
p/truedraft-cad
p/findergit
p/thebold
p/orbit-app-blocker
p/cleared-quit-nicotine
p/murror
Replies
Written limits help, but I stopped relying on the agent reading them. Hooks run before every command and they always fire, so things like recursive deletes and force pushes get blocked no matter what the prompt says. Right now that's 97 hooks and 25 deny rules. The written rule I keep is to fix a local problem locally and leave shared code alone.
@hisashispace 97 now lol, it was 91 last week
@leoheo Yeah, it only goes up. Every time the agent repeats a mistake, it earns a new one ☺️
I counted where my agent's edits actually land. 572 file edits since 3 Nov, and 115 of them were outside the folder the session started in.
Most of those were fine. 50 were its own memory notes and 25 were scratch files. The 35 that went into a different repo are the ones I'd want a rule for. Are your off limits lists about folders inside the repo, or about leaving it?