This.
> Present-day models tend to produce code that is too defensive, too complex, too local in its reasoning. They avoid strong invariants. They add fallbacks instead of making bad states impossible. They duplicate code, invent bad abstractions, and paper over unclear design with more machinery. Worse though: I so far see very little progress of this improving.
Context-smithing can help to a degree and cyclomatic-like complexity rules tend to make matters worse. So, you either roll up your sleeves or close your eyes and hope for the best. I've had limited success with the latter.
I was really surprised by this part!
I've run into the issue a lot; I know it happens. I handled it manually for a while by just having a fresh instance inspect the code - "review this for DRY violations" and "how would you re-write this into a global architecture instead of a bunch of local code".
Eventually the list ended up long enough that I've got an agent that handles it. You've just got to treat "write code that works" and "write elegant code" as two separate tasks - either a fresh instance or an Agent will work