My experience with vibe coding: the problem wasn’t the tool
AI coding can cost a fortune per day, but in my experience the problem was the huge context we throw at the model. How modular architecture cut cost and raised accuracy.
Read this article in Arabic
Lately I have followed the discussion about the “astronomical” cost of using AI tools for programming, especially in what is called vibe coding.
One example caught my attention:
5.7 million tokens for $4.50 on a single request.
Simple math: 10 requests a day = $45. With real usage of 30–50 requests a day, we are talking about $135–$225 a day… thousands of dollars a month.
But after deep personal experience, I found the problem was never the tool. It was us.
The problem was the huge context we throw at the model.
What I discovered
I was treating my projects as a monolith:
I opened the whole project, sent hundreds of files or thousands of lines at once, and expected the model to be “smart” and figure out what was needed.
But according to OpenAI’s official documentation, cost depends directly on the number of input and output tokens, and the bigger the context, the higher the cost, almost linearly.
There’s more.
Recent research from Stanford and MIT on large models’ behavior suggests performance degrades gradually as context grows, a phenomenon called:
Context dilution
The model loses focus on the important part of the problem as unnecessary information piles up.
That explains why the solutions were sometimes “inaccurate” even though I sent it everything!
The fix that changed the equation: modular architecture
I decided to change how I work with AI completely.
I stopped opening the whole project to the model.
Instead, I started applying modular architecture strictly:
1️⃣ Sub-projects and packages
Every unit of the system became its own project:
– a separate UI library
– separate business logic
– an independent API layer
– helper tools as external packages
And I treat them as dependencies, not as parts of one huge project.
2️⃣ Isolated test environments
Every unit has:
– one or two screens to test the UI
– its own unit tests
– its own mock data
In other words, I can run and test it without the whole system.
3️⃣ Targeted use of AI
When I need help with a specific part:
– I open only that unit’s project.
– I send only the related files.
– Nothing more.
What happened in practice?
✅ The good results
– A big drop in tokens, because the context became small and focused.
– Faster responses (which makes sense, since processing time depends on input length).
– More accurate solutions, because the model no longer “drowns” in code unrelated to the task.
– Better maintainability, which is the whole point of modular design in scalable systems.
In my experience, cutting the context by 70–80% cut the cost by about the same amount, because pricing depends directly on token count.
❌ The challenges
But let me be honest… this approach isn’t easy.
– It needs deep architectural planning at the start of the project.
– It needs strict discipline in managing dependencies.
– You must design clear contracts between units (interfaces / APIs).
– It needs a completely different mindset from “open the whole project and fix the problem”.
My conclusion
AI isn’t expensive by nature.
The way we use it is what makes it expensive.
If you treat it as something you throw a whole project at to solve in one go… you will pay for it.
But if you treat it like an engineer working inside a clearly defined unit… you’ll get results that are more accurate, faster and cheaper.