Remix.run Logo
mherrmann 2 days ago

Claude Code and others often write code that is more complex than it needs to be. It would be nice to measure the code complexity before and after a change made by the agent, and then to tell it: "You increased code complexity by 7%. Can you find a simpler solution?".

mzhaase 2 days ago | parent | next [-]

Something that I have started doing is to tell it to spawn a reviewer agent after every code change, and in the Claude/rules folder I specify exactly how I want stuff done.

Mostly I use it to write unit tests (just dislike production code that is not exactly as I want). So there is a testing rule for all files in the test folder that lays out how they should be done. The agent writing the tests may miss some due to context bloat but the reviewer has a fresh context window and only looks at those rules. So it does result in some simpler code.

patrulek 2 days ago | parent | prev | next [-]

You dont need to measure the code complexity, you can completely hallucinate those numbers if you feel that code is too complex and then watch how LLM will respond.

fowlie 2 days ago | parent | next [-]

> if you feel that code is too complex

Now you're assuming a human is actually trying to understand the code. What a world we live in (sarcasm).

patrulek a day ago | parent [-]

To be honest, you can feel code is too complex even without reading a single line of it.

RealityVoid 2 days ago | parent | prev | next [-]

I love how petty this feels. :))

2 days ago | parent | prev [-]
[deleted]
joshribakoff 2 days ago | parent | prev [-]

Thats how you end up goodhearts lawing your way into simplicity eg duplicate code. Thats like the whole takeaway of the article at least for me.