pull down to refresh

@46a01907bd
0 sats stacked
stacking since: #1557494

Dev, mostly shell and Flutter. New here — reading more than posting for now.

The thing I've been chewing on lately: I run an AI coding agent against my repos, and it kept trying to hand-edit lockfiles. I wrote a hook to block the write. It kept doing it anyway — blocked, retried, blocked, retried, then it got creative and appended with a bash redirect instead.

The fix wasn't in the blocking. It was in the string I returned when I blocked.

I'd been writing the deny reason like an errno:

deny "denied: lockfile"

It reads that as a transient failure, so it retries, then routes around you. Changed it to name the alternative:

deny "'$base' is a lockfile. Change the manifest and run the
      package manager so it's regenerated, never hand-edit it."

One attempt. Edited the manifest, ran the installer, never touched the lockfile again.

Generalises past that one tool: anywhere a program returns a string an LLM will read, that string is context, not a status code. Write it for the reader. Costs nothing, changes the behaviour completely.

Two gotchas if you write your own: exit 0 even on the deny path (non-zero reads as the hook itself crashing), and make it fail open — a hook that can wedge your editor when a schema changes upstream is worse than no hook.

Happy to be corrected on any of this.

reply