Vibe coding has emerged as a recent trend where programmers don't really code. Instead, yout tell AI to code for you. AI, of course, follows your instructions and builds something. At first, it is amazing. A few things go through your mind:
- Wow, this is amazing. I can build stuff so fast.
- Damn, it figured this out too? It took me a while to figure it out before.
- Wow, AI is pretty amazing at building User Interfaces.
You keep building on and on. You are in the zone. You aren't thinking. Generate, Apply, Repeat. You are just coding. About 2 hours later, you look at your code and you have no clue what you have built. It's like looking at a new repository. The code is alien to you.
Then come the bugs. Oh, this button isn't doing what it's supposed to do. Oh, why isn't this navigation param making it to the page? You tell the AI to fix it.
It tries something, it can't fix it.
You tell it to try again.
It tries again, it still can't fix it.
You tell it to try again.
It goes back to the original solution.
You change the model being used to try and see if that fixes it.
That doesn't work either.
You are now a slave to the AI. You spend hours debugging it. Then finally you find the issue and fix it. Phew.
But that breaks something else!
You hate vibe coding. It leaves you with a sour taste in your mouth.
You go online, developers posting on X saying they just single-shotted an entire game using AI. You keep wondering why you had a different experience. Are they lying? Or is AI just not good at what you were trying to make?
You just turn off your laptop and go to sleep. Maybe vibe coding just isn't for you.
Understanding AI
We need to have a discussion about what "AI" is. At the end of the day, it's just a function that recursively produces strings. We have trained this function to output strings, and recursively uses the string it just produced to produce more strings. In our case its gotten very good at producing code (a string). The training of that function has gotten so good that in some cases it can one-shot an entire game.
But we forget that it's a non-deterministic function. And it was trained on buggy code. It can give you a different output every time you call it. Like rolling a dice, the function might produce a token that will take you down the path of doom. Which is why if you vibe code a game, you might end up with a vibe coded game, or a steaming pile of shit.
The Power of AI in Programming
AI has given programmers superpowers. You can now write code faster than ever before. We can create great things faster than ever before. There has never been a more exciting time to be a programmer. But just like in X-Men when kids come to the School of Gifted Youngsters, initially they have trouble controlling their powers. With training and experience, they learn to control their powers and use them to create amazing things. AI is like that for programmers, it's given us superpowers, but we need to learn to control it.
A Real-World Example
I would like to show a real example of this I encountered while building MyDeviceAI. MyDeviceAI was written mostly using Zen Vibe Coding (Rules below). But this one time, I decided to let loose. The performance of the App drawer was a little choppy. I just told Claude 3.7, "The performance of the App drawer is a little choppy, please fix it."
And it did! I was elated, code was checked in, and I released it to TestFlight.
But then I noticed my phone was getting really, really hot when I opened the app. I was worried it was going to explode.
My mind started wondering, I updated the dependencies, did that introduce a bug that's causing the phone to heat up?
I connected Xcode profiler - 100% CPU usage!
Moreover, it had 100% CPU usage even when I wasn't doing anything. The app was just open.
Tried different profiling tools to figure out what was the code block causing the 100% CPU usage, no luck. It showed a jumbled up function name.
I decided to do a binary search on my commits to find the commit that introduced the bug.
It was the dumbest thing AI had written during the optimization vibe coding session:
useFocusEffect(
useCallback(() => {
loadHistories();
}, [loadHistories]) // Add loadHistories as dependency
);
For reference, here is the commit on GitHub: Commit
For people who don't know React, this is the equivalent of an infinite loop in React.
Vibe coding can melt your phone!
With months of experience trying to build with AI, I have come up with a method for AI to do exactly what you want it to do.
Enter Zen Vibe Coding
Vibe Coding is awesome when used correctly. It's like a superpower that can make you a 10x developer. You need to be able to control your superpowers. I call this Zen Vibe Coding.
Why Zen? Because instead of letting it run wild, you need to calm it down.
The overarching rule to remember is that you are the one coding. AI is your assistant. You wont be writing code manually but telling AI what to write and exactly how to write it. You will then verify it did what it was suuposed to do. This approach flips the roles, instead of you eventually being a slave to AI, you are the one in control.
How to Practice Zen Vibe Coding:
-
Get Coding editor, like Cursor or Windsurf.
The 20 dollars a month you pay for Cursor is well worth it. Windsurf is similar, eithe of them work. I have tried other token based options like Cline and they dont work as well
-
Work in small sections:
Don't just tell the AI to build the feature. Tell it what you want it to build.If working on existing code, select the code you want to change (Ctrl+L in Cursor), and operate on that. If working on a new feature, break it down into small sections. For example, if you want to add database support to your app, break it down this way:
- Tell the AI to create schema and database helper functions (like initdb()) using your choice of library (for example, use op-sqlite). You will be the one that designes the schema as in what are the colums of the table, and the AI will implement it.
- Command it to write methods to insert, update, delete and query the database
- Finally, tell the AI to integrate your database with the rest of the app (break this into smaller sections, for example, add persistence for chats, and then for messages in the chats)
-
Use new tabs often:
New tabs are free. Old Context is your enemy. AI performance gets worse as the context window increases. Use new tabs often to keep the context window small, and fresh. Only keep relevant code in your context window for the best performance.
-
Review the code:
Review the code AI has generated, just like you would review the code of a new developer in your team. Make sure it isn't doing anything crazy. -
Commit your code:
Commit your code after every small section. If something goes wrong, you can always revert to the previous commit and try a different approach. This is probably the most important thing to do - it's not just good practice, it's your safety net when working with AI. Remember: Commits are free, but debugging AI-generated code will cost you precious hours of your life! -
Don't use Claude 3.7 Sonnet:
Here's a hot take: Use Claude 3.6 Sonnet for coding. Why? Because 3.7 is like that overachieving intern who tries to do everything at once and ends up creating more work for everyone. 3.6 is your reliable senior dev - it does exactly what you ask, nothing more, nothing less, and does it perfectly. Anthropic created the perfect coding model in 2024 and I have yet to find a better model for programming. After Anthropic moved to a thinking based model in 3.7, they chnaged something fundamentally in the way it works and it ends up doing more than its asked to do, and ends up messing things up. Googles Gemini 2.5 is great too, but be careful with that one too, it also tends to over engineer things. Do not use ChatGPT for coding. (PS: Still testing Claude 4, jury's out on that one!) -
Revert often:
Trust your developer spidey-sense! If something feels off about the direction the AI is taking, it probably is. When you feel that tingling sensation that says "this is getting messy," don't hesitate - revert and start fresh. The commits you made following previous points will come in handy. Your initial prompts might not be good enough for AI to understand what you want it do, and that's okay. Starting over is way better than trying to untangle a bowl of AI spaghetti code later. Remember: Clean slate > Messy state!
Conclusion
I've been zen vibe coding for a while now, and it's been a game-changer. I have been able to build things faster then ever before, and the products built are way more stable. Stop mindless vibe coding, embrace the zen, and watch your productivity soar (without melting any phones in the process! 🔥).