DEV Community

Cover image for AI Can Write Code Fast. Keeping It Clean Is the Hard Part
Aakash
Aakash

Posted on

AI Can Write Code Fast. Keeping It Clean Is the Hard Part

I'll keep this one shorter than usual.

Remember the good old days when we wrote the entire codebase by hand? Being the writer, we knew the pains of maintaining it so we'd keep it as clean and minimal as possible and avoid spaghetti logic and repetition.

With the advent of Coding Agents, coding has never been easier but also, never been messier. Huge functions, giant files, repeated logic, contradictory assumptions, logic strewn around like spaghetti without a proper structure etc. are just a few of the problems I have noticed. Now, just a review takes so much of cognitive overload from just trying to follow the structure, forget wrapping your head around the huge monoliths.
In so many of my projects I see this pattern repeat - I set up a scaffolding and put in the backbone - all clean and DRY. Then the agent takes over. By the time it is done, the drift from my clean code to the mess makes me want to gorge my eyes out!

I tried prompting it to JUST KEEP IT CLEAN, DRY AND REUSE INSTEAD OF RE-INVENT but with repeated context compressions, it soon gets lost. Well, I got fed up and thought of writing a set of SKILLS but came across the clean code skills pack which enforce Robert C. Martin's Clean Code principles. The set of skills were good but it missed the major pain I faced - keeping the code appropriate and avoiding monoliths. So I forked it and added the skill in. I have submitted a PR to the upstream but meanwhile, you can use my fork - CLEAN DRY CODE SKILLS. It's mainly for python but the principles can be applied to other languages too.

I hope the community finds it useful. Please add in other skills there you think is missing - I will be maintaining this fork so we can get it merged there. Do drop a star if you like it!

PS - I'm curious to find what other drifts and annoying patterns you have noticed when an agent works on your codebase.

Top comments (0)