Comment by _pdp_

Comment by _pdp_ 3 days ago

8 replies

You put a warning where it is most likely to be seen by a human coder.

Besides, no amount of prompting will prevent this situation.

If it is a concern then you put a linter or unit tests to prevent it altogether, or make a wrapper around the tricky function with some warning in its doc strings.

I don't see how this is any different from how you typically approach making your code more resilient to accidental mistakes.

mvkel 3 days ago

Documenting for AI exactly like you would document for a human is ignoring how these tools work

  • anonzzzies 3 days ago

    But they are right, claude routinely ignores stuff from CLAUDE.md, even with warning bells etc. You need a linter preventing things. Like drizzle sql` templates: it just loves them.

  • CuriouslyC 3 days ago

    You can make affordances for agent abilities without deviating from what humans find to be good documentation. Use hyperlinks, organize information, document in layers, use examples, be concise. It's not either/or unless you're being lazy.

  • notachatbot123 2 days ago

    Sounds like we should call them tools, not AI!

    • theshrike79 2 days ago

      Agentic AI is LLMs using tools in a loop to achieve a goal.

      Needs a better term than "AI", I agree, but it's 99% marketing the tech will stay the same.

bastawhiz 3 days ago

> no amount of prompting will prevent this situation.

Again, missing the point. If you don't prompt for it and you document it in a place where the tool won't look first, the tool simply won't do it. "No amount of promoting" couldn't be more wrong, it works for me and all my coworkers.

> If it is a concern then you put a linter or unit tests to prevent it altogether

Sure, and then it'll always do things it's own way, run the tests, and have to correct itself. Needlessly burning tokens. But if you want to pay for it to waste its time and yours, go for it.

> I don't see how this is any different from how you typically approach making your code more resilient to accidental mistakes.

It's not about avoiding mistakes! It's about having it follow the norms of your codebase.

- My codebase at work is slowly transitioning from Mocha to Jest. I can't write a linter to ban new mocha tests, and it would be a pain to keep a list of legacy mocha test suites. The solution is to simply have a bullet point in the CLAUDE.md file that says "don't write new Mocha test suites, only write new test suites in Jest". A more robust solution isn't necessary and doesn't avoid mistakes, it avoids the extra step of telling the LLM to rewrite the tests.

- We have a bunch of terraform modules for convenience when defining new S3 buckets. No amount of documenting the modules will have Claude magically know they exist. You tell it that there are convenience modules and to consider using them.

- Our ORM has findOne that returns one record or null. We have a convenience function getOne that returns a record or throws a NotFoundError to return a 404 error. There's no way to exhaustively detect with a linter that you used findOne and checked the result for null and threw a NotFoundError. And the hassle of maybe catching some instances isn't necessary, because avoiding it is just one line in CLAUDE.md.

It's really not that hard.

  • girvo 3 days ago

    > There's no way to exhaustively detect with a linter that you used findOne and checked the result for null and threw a NotFoundError

    Yes there is? Though this is usually better served with a type checker, it’s still totally feasible with a linter too if that’s your bag

    > because avoiding it is just one line in CLAUDE.md.

    Except no, it isn’t, because these tools still ignore that line sometimes so I still have to check for it myself.

    • bastawhiz 2 days ago

      > Yes there is? Though this is usually better served with a type checker, it’s still totally feasible with a linter too if that’s your bag

      It's not, because you would have to implement a full static analyzer that traces where the result of a `findOne` call is checked for `null` and then check that the condition always leads to a `NotFoundError`. At best you've got a linter that only works some of the time, at worst you've just made your linter terribly slow and buggy.

      > these tools still ignore that line sometimes so I still have to check for it myself.

      this is _literally_ the point of the article