Every correction I give my coding agent becomes a file, then a hook

by•

When my programming agent makes an error and I point out the wrong part, the corrections don't just stay in the chat but are stored as files, so the next session doesn't trip over the same thing again. I spent quite a while figuring that out actually.

In this way, I have 100 incident notes which the agent has written, and it also keeps memory notes in the project, with one fact for each file. A one-line index of those notes is loaded each time a session starts. Should the same mistake occur another time, it won't merely be a memory but a hook. That hook runs on every tool call and every reply, whether the agent remembers it or not. At the moment I have 63 hooks.

A few of them came about from pretty common things. It began to reply in English after long sessions in a different language. The note for that one says the more English documents it had just read, the more likely it was to drift into English. Now if a reply is in English, a hook makes the agent rewrite it.

Another time it told me something was fixed without testing it. From this I made a rule: it has to write down how it checked. And dash use was restricted.

Has your agent ever brought back something that had already been corrected? How do you make sure that it doesn't?

15 views

Add a comment

Replies

Best

Mid-task the agent lost earlier context and rebuilt a helper that already existed two files away under a different name. That left two versions of the same logic drifting apart. Now every prompt forces it to search existing utilities first instead of letting it spin up a new file.

Same first half, different second half. My corrections also become files, one fact per file with a why and a how to apply line, and a one line index of them loads at the start of every session. I have no hooks, so the question of whether it comes back is a fair one, and yes, two did. The agent kept shortening translations to fit a button, in 43 languages at once, and it kept writing gendered endings in parentheses in Russian copy, the "(a)" form, after I had said no. What stopped both was not repeating the rule but moving it. The translation rule now sits in the localization section of the project file, the one the agent reads before it touches those files, with the reason: a shortened line looks like the app was translated by a machine. The gender rule got a mechanism to point at, the quiz answer that carries the user's gender and the select syntax that uses it, so there is a right way to write and not only a wrong one. A rule that lives next to the act and comes with a replacement has held for me; a rule in a general list, read at the start and forgotten by the time the file is open, is the one that drifts. And yes, dashes are restricted here too.

turning each correction into a hook is a smart way to stop repeats. do the hooks ever start clashing once you have a lot of them?