By Gaurab Chhetri on January 1, 2026

It’s no surprise that, like many developers these days, I use AI to the fullest. After spending a fair amount of time working with it, I’ve noticed some interesting quirks about how it writes code.
If you’ve worked with AI-generated code, you probably know the basics: AI models are trained on massive amounts of publicly available code from platforms like GitHub, GitLab, and Kaggle. They learn the patterns and styles present in this corpus and then try to reproduce them for us.
The problem? The web is full of all kinds of examples: good, bad, and downright terrible. Even with the safety checks and fine-tuning applied by AI developers, models can still output messy, inefficient, or redundant code. Garbage In, Garbage Out (GIGO)1 is alive and well. If the AI “eats” a lot of messy code, it will inevitably spit out some slop.
One-shotting a project/ feature with AI can be unpredictable. Sometimes it generates hundreds of unnecessary files. Other times, it dumps an entire project into a single file. Neither is ideal for maintainable code. You might get a full framework scaffolded in minutes, but cleaning it up is a project in itself.
Let me show you a basic workflow with AI for a fairly simple website with a few pages: Prompt (1−2mins) → AI Code Generation (10−15mins) → Cleanup (10−15mins if it worked, else 1 hr? 3 hrs? 1 day? 2 days? new prompt?).
If it works, fine. If it doesn't, frustruation.
Here are some strategies I keep in mind when asking AI to generate code:
AGENTS.md file. Why, you may ask. Nowadays, almost all AI code editors recognize AGENTS.md file. You can define the specs of your project there, and the model will reference that file if something is unclear. If still unclear after that, it will generate a slop.I am writing these, but I myself am not following these everytime and for every project. Nowadays the models are being very smart, and moving very fast. They can sometimes unexpectedly generate some good code, but the tips above can help you get out of mess.