Comment Re: Lack of math skills? (Score 1) 110
[invariant-heavy and proof-heavy guidance to the AI] How do you do that?
My main AGENTS.md has ten lines about the most important coding principles:
- Prefer functional-style code, where variables are immutable "const", there's almost no "if/else" branching branching, and most functions are side-effect free.
- Code should have comments, and functions should have docstrings. The best comments are ones that introduce invariants, or prove that invariants are being upheld, or indicate which invariants the code relies upon.
I am adamant about clean engineering. What I look for:
- Invariants are the best way to document all aspects of code. These include code invariants (stating what assumptions a function makes about shared data, and how it upholds them), and architecture invariants (for instance the main index.js never touches state except through component accessors).
You must document *meaning* of every field, and also enums and disjoint type fields.
- "Meaning" says briefly what the field/enum represents. From a well-written meaning, a smart reader will be able to deduce all the invariants around this field/enum, and deduce how it will be used in the code.
- It is hard work to distill a good meaning! You must put considerable effort into it.
The instruction on "meaning" ended up carrying a lot of weight to the AI. It adopted the habit of putting a comment on every single field and function that starts with the word "// Meaning: " and they're honestly, genuinely good ones! Single-line sentences on fields that carry a lot of good weight.
Separately, I have a LEARNINGS.md file which I have the AI auto-update every time it gets course corrected by me. Over the first two weeks there were a lot of course corrections, but now there are only a few a day. The file ended up carrying my senior engineer wisdom, more or less, the kind of things I normally mentor to junior developers on the team over several years. Here's an extract: https://gist.github.com/ljw100...