r/nextjs • u/the_white_flame_dev • 14d ago
how to manager using AI in vibe coding
i was learning MERN/PERN stack and nextjs in development and plan to start freelance and made two project before i feel burnout and stopped programming for a while around 4-5 months and when i came back i found that all are saying it's not practical writing code with hands again
i tried to use ai agent to write code and i review it but the code ai is writing are so messy like i ask for simple function to do some kind of thing and i found it made around 5 helper function many of them are just normalizing or one return line that make some filter or mapping i really found it so hard and time consuming reviewing this messy code i can't really manage
at the same time i don't want to but some constraint or forcing ai to use my own coding style since it could have some bad practice, weak patterns or things like that and waste learning from ai
NOTE: i really appreciate any advice from anyone here about ai or anything else in coding since i consider my self extremely bad.
7
u/FourtySevenLions 14d ago
Linters, linters, linters.
Most of the things you add to an Agents.md file do not actually need to be defined there.
Most of the opinions you’d expect your agent to follow can get codified so the rules are enforced as you or the agent type.
And for the things that are too abstract to lint use an Architecture Decision Record (just an md file saying why you’re doing something) to enforce the rule
3
u/theloneliestprince 14d ago
I only use claude code, so I don't have expierience with other ai platforms. I am a reluctant adopter of ai, but it's pretty clearly here to stay. Something that can really improve code quality is installing specific skills for the languages/stack you intend to use, for example: https://github.com/vercel-labs/agent-skills/tree/main/skills/react-best-practices that will guide the ai to write better code. let me know if you have any questions, it's a rough transition! everything is changing!
2
u/Ok_Woodpecker_9104 14d ago
ai loves adding those one line helpers. you don't need to force your own style to stop it. one line in your agents.md like "no new helper unless it is used in 2 or more places, inline one line functions" covers most of it. most seniors would give you that same rule, so you are not baking in beginner habits.
when you review, ask it after the fact which of these functions could be deleted with the code still working. reading why it deletes them teaches you more than reading the first version.
the linter comment above helps too, eslint catches a lot of the rest before you even open the diff
3
u/s004aws 14d ago
Companies/managers don't give a flip what code looks like anymore. As long as whatever the AI slops out works its "good enough". (They'll learn their lesson in a few years when they have mountains of code nobody understands, nobody has ever reviewed, nobody knows how to debug, and which is structured like an industrial-sized pot of spaghetti.)
1
u/itsKuriyal 14d ago
If you leave everything to AI by simply giving it a basic prompt, it can produce overly complex answers. What I usually do is write the initial code myself—for example, one complete API or a page—and then prompt AI to follow the same patterns, techniques, and coding approach, while providing some specific constraints.
For instance, if I'm building a full-stack e-commerce website, I'll first code the login page and authentication API myself. Once that's done, I'll ask AI to follow the exact same structure, patterns, and approach when building the remaining pages and APIs.
This technique significantly improves AI's accuracy and consistency while keeping the code clean, structured, and aligned with my coding style.
1
u/circuit_howler_77 14d ago
stop treating AI output as a finished product and start using linters to enforce the rules. Write the first page or API by hand to establish your pattern, then prompt the AI to replicate that exact structure so it does not invent unnecessary helper functions on its own
1
u/UequalsName 12d ago
I got results with alt + f4 . Followed briskly by an uninstall.
1
u/OkTemperature8170 12d ago
You need to do very small parts at a time. A jump start is to ask for a skeleton with a basic layout. Then build out small pages and actions. Tell AI to not allow you to jump from one task to another and if you do try have it suggest adding it to the todo until commit. On commit re-list your todos.
If you keep the scope of each prompt smaller the stuff it outputs is much more manageable. If you need to do some sort of task that is a major overhaul set the AI to its highest reasoning first.