Published On

The Problem With AI Generated Code And How To Deal With It

Murtuzaali Surti
Murtuzaali Surti

• 5 min read

Updated On

AI models and tools are becoming more and more capable day by day, especially at generating code. With tools like Firebase Studio, Lovable, v0, Augment, one can create entire full stack applications by combining one or more of these tools. But, there's something off once you run the code generated by them.

In this post, I will walk you through my experience of creating a full-stack application using some of these AI coding assistants/agents and share some of my observations.

Table of Contents

TLDR;

  • AI generated code can create a lot of tech debt if you are not aware of what the code does.
  • If you are new to coding, only rely on AI agents/assistants for educational purposes.
  • AI models hallucinate quite often — you need a skilled developer to get them back on track.
  • Improve debugging skills to debug some nasty issues created by AI generated code (if any).
  • AI generated code doesn't eradicate the need of a software developer, it only increases the productivity for now.

Developing A Full Stack Application Using AI

Recently, I developed a full stack application using Lovable and Firebase Studio along with Gemini 2.5 Pro. It's a collaborative movie list which you can share with your friends and create collections which are editable by them.

Frontend

I vibe coded the frontend using Lovable and found out that it was great at generating frontend. I told Lovable my preferred tech stack, which is React + Vite + React Query, and it did a great job following that.

Also, Lovable made its own decisions along the way, for example using Radix UI (shadcn) for components and lucide-react for icons which were actually good. Lovable was able to figure out trivial things such as configuring eslint, tailwind and a couple of vite plugins which were required.

Backend

For backend, I tried Google's Firebase Studio and vibe coded the backend using Gemini 2.5 Pro and it did a pretty good job. I suggested it to use Node, Express, and Neon's PostgreSQL instance along with the TMDB API.

For authentication, I suggested gemini to use lucia-auth and arctic to implement an OAuth based authentication strategy and gemini 2.5 pro nailed it. One thing I like about gemini 2.5 pro is that it recognizes its mistakes and fixes them once realized. The auth strategy it implemented was session-based and although it worked fine locally, it wasn't meant to run on serverless functions. I needed something stateless - so I decided to go with JWT (JSON Web Tokens).

I instructed gemini to re-work the auth strategy to use JWT instead of the session based implementation and it did a good job.

I loved the fact that gemini 2.5 pro generated one-off DDL SQL queries for the neon postgresql instance to create initial schema, and they were perfect, more importantly, in-sync with the code it generated (thanks to the larger context window of gemini 2.5 pro).

Running the GenAI Code

It wasn't a success on the first try. Ran into multiple type-errors and API layer issues, so went back to firebase studio and told it to build the project using CLI commands, look at the type errors and fix them. It fixed most of them but not the ones which were a little bit complex and required human intervention.

I observed that gemini went into a loop sometimes, where it tried one thing, didn't work, switched to do something new, and when that also didn't work, it was back at square one.

Deployment

Deploying the code was mostly a manual thing. I used Vercel to deploy both frontend and backend. This and debugging were the only two things I had to do myself.

The Consequences

Vibe coding an entire full stack app from start to finish in an extremely less amount of time looks good on paper, but if I look closely, I can see a significant amount of tech debt in the code — things like unused code, unnecessary abstractions, unrelated and inconsistent code, etc.

If someone who is completely new to coding vibe codes and develops an application, they will have no idea what the AI model is doing. It's kind of a black box for a newbie in code. Worst thing is that they won't be able to debug issues on their own and will have to solely rely on AI to debug, which can take more time than someone who has decent programming knowledge and can navigate through those issues easily.

Another issue is that AI models still hallucinate and can go off track. If you don't know how to bring them back on track, you might spend more time giving prompts than you would have spent coding the application on your own.

The Right Way

Until AI coding agents and tools do something magical and are able to generate clean, to the point and production-ready code, I recommend generating and using AI code responsibly and wisely. If you are new to programming, I suggest using AI tools as helpers only — to help you learn along the way, and not sole reliers that you blindly trust.

Also, I recommend to generate code incrementally — moving on to the next step once you have tested and verified the previous one.

To summarize:

  • AI generated code can create a lot of tech debt if you are not aware of what the code does.
  • If you are new to coding, only rely on AI agents/assistants for educational purposes.
  • AI models hallucinate quite often — you need a skilled developer to get them back on track.
  • Improve debugging skills to debug some nasty issues created by AI generated code (if any).
  • AI generated code doesn't eradicate the need of a software developer, it only increases the productivity for now.

Closing Thoughts

If you think AI can independently generate production-ready code, I don't think we are there yet. And I don't think AI will completely eradicate software jobs, in fact, software engineers will undergo a transformation where they will have to work along with AI. Software engineers will be more like architect-level decision makers. AI won't come for their job, it will be their job.


MCP (Model Context Protocol): The HTTP for AI? — All You Need To Know

Previous