r/vibecoding • • 21h ago

Help/Question Techniques to improve your codebase?

I've now vibe-coded several apps that I'm generally happy with. But I still get the occasional glitches and errors. Once in a while I learn that something I thought I'd implemented is not actually working. If I were to show the repo to a software engineer, I bet they'd be horrified.

Also, I usually use Deepseek and GLM...not sure if that results in substandard code compared to using Claude.

So (besides hiring someone competent or just asking your agent to check), what are some methods to make your codebase more robust and verify that features are implemented in an optimal way?

18 Upvotes

40 comments sorted by

9

u/vpanyushenko 21h ago

- keep issues small
- run implementation and review agent loops with models across different vendors
- run refactor audits every n PRs (try 50 and adjust) to make sure code is It the style you want and old code has been cleaned up
- run security audits every n PRs
- run lots of tets
- for UI work have agents take screenshots before and after and review them

1

u/SanitateCfresi 12h ago

for the refactor audit at 50 PRs, do you feed the whole repo into the context window or go module by module

1

u/vpanyushenko 12h ago

I think the important part as these model get smarter you should do less and less handholding and instead just explain rules. For example, it should audit tests that don't make sense, tests that are missing, look at code structure that doesn't fit your patterns, look for performance issues, and TODOs or FIXME comments in the code.

As the models get better they are better able to use the tools and do detailed work without you specifying exactly what they should do. The smarter the model the less specific you want to be and the grander you want to make your goal.

1

u/vigilant_allocation 11h ago

whole repo never fits for me. i break it into modules and still miss half teh bugs

8

u/Agile-Positive-9050 20h ago

Review what the AI is doing on every commit, try to understand the code and the architecture. If you are new to Software Development try learning coding and understanding software architecture yourself. That way you can make informed decisions in your reviews and steer the AI in the right direction with more specific prompts.

2

u/Rotating-Retard-3001 18h ago

Listen to this man.

4

u/Competitive-Elk763 21h ago

Looking at it

4

u/shakeBody 21h ago

I was gonna say the opposite.

4

u/mikepun-locol 21h ago

Do you have a regression test of your application, and do you keep it up to date?

Eg. I have a full regression test suite of my application that I use on staging first, then against production after a deployment and on regular basis, like a heartbeat to verify everything is good and that something didn't happen. Eliminate situations where a new feature or a fix breaks something else by accident.

There are also also ways to analyze a repo for bloat and issues.

2

u/No-Protection-7019 20h ago

Apprendre à coder avant tout. J'ai utilisé l'IA pour porter du code que j'avais écrit, ça a été assez rapide et sans bug (voir découvert des bugs existant). Je l'ai utilisé pour faire une application à partir de 0, ça a pris plus de temps à debug qu'à écrire le code. L'IA c'est comme la télévision, à petite dose ça peut t'apporter quelque chose, ça haute dose ça fait de toi un imbécile incapable de réflexion.

Je suis un codeur amateur pas professionnel.

2

u/HyperSpazdik 20h ago

This is nothing that I have enacted but it's my general unproven outlook on vibe coding:

Reviewing code defeats the purpose of getting ai to write the code in that in can take just as long if not longer to review code as it takes to write it, particularly in a codebase you aren't familiar with.

This is somewhat mitigated by doing pair programming with the agent, where you plan each change and build features bit by bit, reading each change, but again for big efficiency gains you can't be reading every line.

Therefore your role initially is to set up workflows for the agent that you can eventually trust without having to look at the code. And by workflows I mean just follow the sdlc and have a designated agent for each step. To refine what is/isn't working initially unfortunately you will have to be reviewing the code and trim/augment the workflows based on the mistakes you find.

There are several problems with this approach:

  1. there is only so much code you can read, so your workflows will only be proven in small applications and you will just have to trust it scales
  2. llms at certain intelligence levels are probably already doing something similar to this, and whatever workflow you build will probably be inferior to what a researcher at anthropic is already developing. I suspect that models such as fable and astra are just llms sitting in stricter harnesses that enforce sdlc like worfklows.

Obviously if you are doing anything critical like handling customer data, writing actual critical software applications you should be reviewing all code. Unfortunately if you can't do this yourself then you will have to delegate to someone who can and hope they aren't just rubber stamping your codebase or just prompting an agent to review it - which you can already do.

Whether or not this is actually an improvement over just letting the agent run wild with a single prompt, I have no idea. and this sort of systems engineering will become less and less relveant as models get smarter and more efficient. However my gut feeling is that this is still worth doing in 2026.

2

u/raiyan_0001 20h ago

I have made an we app too and indeed it make mistake like when we way to implement something it break another one and this loop goes and goes 😭

2

u/segfaults123 20h ago

This isn't meant to be a dig at you at all, just the reality of LLMs right now.

That's the problem with not knowing what you're doing and vibe coding - agents know how to write syntax, but they don't know how to structure systems in a way thats robust, and maintainable, and so you get crazy spaghetti code unless you provide the directives to tell it not how to write code but how to engineer - something non-engineers don't know how to do.

The problem is this: When your code isn't organized well, with clear boundaries of responsibility, the agent has to load so many files into it's context and you get context rot, degrading the performance significantly.

You'll probably be fine on smaller projects but as your projects grow, that issue grows and grows until you can't trust the agent to update something without breaking something else. Unit tests do help, but without proper system structure it's just more stuff it has to load in its context.

Here are some examples:

  1. Not having a domain layer causes the LLM to place business rules in every corner of your application, including duplicating business rules, contradicting business rules, and changing business rules can miss updating them all because it's not in one centralized location.
  2. I guess #1 can be applied to basically every piece of logic, from infrastructure to application layer responsibilities.
  3. It doesn't by default do well with class responsibilities, and it frequently bloats classes with dozens of partial responsibilities, so when it needs to make a change, it's loading a bunch of junk it doesn't need to load into it's context. If things aren't separated properly, it may need to load a significant portion of your code base into it's context just to make small changes. Context rot, degradation and bad decisions.
  4. I told my LLM rules to sanitize user input, and it went on for a while about it's all done in the UI and everything is fine. If you don't have experience you probably would have stopped there, but I had to fight it and tell it that UI sanitization doesn't protect the api from malicious users.

To put it bluntly, vibe coding can be dangerous - both to you legally and to your users - if you don't know what you're doing.

If it's just your personal projects and it's not online no big deal, but if it's not, be careful. Seriously.

2

u/Accurate-Jump-9679 19h ago

I'm aware of all this, but the ability of AI to engineer systems is dramatically improving as well, so if it's a still a shortcoming now, I don't think it will be for much longer. I'm not doing anything that involves financial transactions, safety or sensitive information.

1

u/in-a-landscape 17h ago

Do you understand the code enough to guide the AI away from anti-patterns? because this does help a lot. I wouldn't rely on this getting better automatically just because models are getting better. But optimizing your workflow and making it better is something that will stick.

2

u/mbtonev 19h ago

The model matters less than the guardrails.

  1. Add tests for your core flows (even 5–10 end-to-end tests with Playwright) and make the agent run them before it calls a task done. That catches the "I thought it worked" features.
  2. Add a linter and type checker (TypeScript strict, ruff, etc.) to a pre-commit hook.
  3. Every few features, do a cleanup pass: ask the agent to list dead code, duplicated logic and missing error handling, then fix them one at a time.
  4. Keep a short FEATURES.md with each feature and how to verify it, and check it after big changes.

I built VibeCoder Planner to bake this in: each task comes with its own prompt and checks, and project memory keeps the structure consistent. Your first project is free: vibecoderplanner.com

2

u/Legal_Answer_6956 18h ago

I'd focus on testing rather than just switching models. Keep changes small, run regression tests, and use a separate agent to verify important user flows like signup, payments, and password resets. Also, ask the AI to keep business logic, UI, and database code properly separated. Building features is easy; making sure they keep working is the real challenge.

1

u/snap-dev 21h ago

that nagging feeling that something you asked for isn't actually wired up is super common with vibe coded stuff. the cheapest fix i've seen is writing 5 or 6 plain english checks per app (sign up, pay, reset password, that kind of thing) and having a fresh agent session click through them and report what really happened, separate from the one that built it. do you worry more about the ui breaking, or about data and logins quietly going wrong?

1

u/Own_Badger6076 21h ago

Consistent organizational formatting, with adaptations per project as needed. Regularly reevaluate the codebase to clean it up and reverifying everything is working.

Sorry, if you want to make shit that works and save yourself work down the line you're gonna need to learn and keep learning how to improve the systems you're building.

1

u/Necronomis 20h ago

Strict workflow structure you do not deviate from. Documentation. Scope you don't let creep. Adversarial review. Tests. And learn enough code to at least identify if a function is doing something or not

1

u/Saver411 20h ago

Lock down your environment variables and split business logic away from UI components. If prompts edit a single massive file, you'll watch things break. Keeping routes, db queries, and components separated stops agents from rewriting unrelated code

1

u/ApartChicken6208 20h ago

I've found that adding a simple 'verify' step after each major change, just a quick manual check of the most critical path, catches 80% of the 'wait, this isn't working' moments before they go to review.

1

u/kamronkennedy 20h ago

Setup functional test suites for whatever your stack is, make sure they use throwaway containers to run in or have a dedicated test install. Make sure its something repeatable without the robot so A. You can DIY and B. Minimizes token spend for testing phases

1

u/JitendraBuilds 19h ago

Three things that immediately stop "silent broken features" without hiring anyone:

  • Make the AI write a Playwright/Vitest test for every feature so future edits can't silently break what already worked.
  • Use a second model as a ruthless code reviewer: Paste your git diff into a fresh chat (even a free one) with "Find broken edge cases, unwired UI buttons, and hardcoded secrets in this diff."
  • Run tsc --noEmit + a linter so half-finished refactors fail loudly instead of hiding until runtime.

1

u/ChrisBuildsSaaS 19h ago

A few things that catch what "ask the agent to check" misses.

  1. Two-account test: sign up as user A and user B, create data as A, then try to read and edit it as B from the browser. Agents rarely test across users.
  2. Anything money or permission related (plan, role, is_admin) should only be settable server-side, never from a column the user can update.
  3. Look at your Supabase tables and policies once by hand: RLS on, and no policy that reads "true" or trusts user-editable metadata.
  4. Search the frontend bundle for service_role or secret keys.

Those four cover most of what a software engineer would flag first.

1

u/Only_Bug_2011 18h ago

Your "I thought it was implemented but it isn't" problem is the one I recognise most. One thing that addresses exactly that: keep a plain checklist outside the code — one line per feature, with *how it was checked*, not just that the agent said it's done.

After each session, the agent updates it: the feature, the exact steps to test it, and what it actually saw when it ran through them. If it can't demonstrate it, it doesn't count as done. A lot of those random glitches turn out to be features that were written but never wired up, and this catches exactly those.

On DeepSeek/GLM vs Claude: the model matters less than this verification loop, in my experience. A stronger model writes nicer code, but it will still confidently tell you something works when it doesn't.

1

u/Prod_m 18h ago

at some point I ask an llm to create two .md files:

  1. dependencies map
  2. decision log (like adr)

on every commit I ask to update this docs in accordance with the changes made. token usage becomes higher but the risk of breaking something or rewriting logic that was approved earlier is lower.

also refactoring becomes a bit easier in terms of testing, because there are less mistakes or bugs in the end.

maybe there’s more efficient way to do it, but I don’t know of it yet.

1

u/VridhiMehta 18h ago

anthropic has an official code-review plugin that runs several review agents on a pr and filters out the false positives, catches stuff that looks wired up but isn't. https://www.claudeai.directory/plugins/code-review , I help run that site

1

u/Simple-Bedroom5606 17h ago

The thing that caught most of my "I thought this worked" cases was writing a short acceptance check for every feature before building it. Just a sentence like "logged out user hitting /settings gets redirected", then a test or a tiny script that proves it. Ask the agent to write those first and run them after every change, and keep them in the repo so they pile up into a regression suite. Second thing is CI, even a free GitHub Action that runs build, lint and tests on every push, so a broken feature shows up the day it breaks instead of weeks later. On models, I don't think DeepSeek or GLM is the main problem. Having a different model review the diff than the one that wrote it catches more than switching to a pricier one. And every so often ask it to list the features it can't find a test for. That list is usually the scary part.

1

u/di4medollaz 17h ago

Perfectly put. If I had to explain everything, you just did in four words I would say

Garbage in garbage out lol

The best software engineers are gonna be the ones who just simply know how to converse with AI the best and set up rules and boundaries that are set in stone.

1

u/Triangle-Enjoyer 16h ago

“I want you to approach this task with such an elite level of efficiency that it would be physically impossible for me to NOT get the absolute best possible result mankind has ever witnessed. This output should literally be the most impressive thing I’ve ever seen in my life.”

I found it on X, it legitimately works.

1

u/usestackrank 14h ago

The "thought it was implemented but it isn't" problem is the one tests fix best, and the trick is having the agent write tests from a spec instead of from its own code. Write each feature as two or three plain sentences of expected behavior, then have the agent turn those into end to end tests (Playwright works well for web apps) that click through the real UI. A test written after the fact tends to just confirm whatever the code already does.

Other cheap guardrails: turn on strict mode in the type checker and a linter, and make the agent run both plus the tests before it says it is done. Add error tracking like Sentry so real glitches show up with a stack trace instead of you hearing about them from users. And commit small, so when something breaks you can bisect to the change.

Model choice matters less than having these checks. A weaker model with a good test suite beats a strong one running blind.

1

u/di4medollaz 13h ago

What would you say in the next three years will be the most important skill for someone who develops software with AI will be?

Also, right now in today’s time, what skills does someone need to be a successful vibe coder?

For me, the answer is a no-brainer.

1

u/meesbie 13h ago

Two things that tend to help more than switching models:

  1. Write down what "working" means per feature in plain sentences (user signs up, gets the email, can log in, can pay). Have the agent turn those into end-to-end tests and run them before every merge. Most "wait,

i thought I built this" moments are features nobody ever clicked through end to end.

2. Use a different model as reviewer than the one that wrote the code. A model reviewing its own diff mostly agrees with itself

Bonus: every few weeks ask an agent "list every feature this repo claims to have and point to the code and the test for each." The gaps it finds are usually embarrassing and very useful.

1

u/OliMations 8h ago

It is hard with LLMs; the best way is to largely just learn the basics of software engineering yourself, which helps you direct the AI in the right direction and spot recurring or silly mistakes and misunderstandings before they get embedded forever. But if you are committed to vibecoding, then you sort of have to accept that the overall codebase quality won't be great, as long as you have adequate testing with high coverage, including integration and end-to-end testing, to catch genuine issues and fix them, and make sure you also test as many features as possible when you make changes, and provide yourself the internal tools to do so. You can mostly get by.

Also, if you did want a human to look over your code, fix an issue or add a feature, check out https://ancorra.dev for fast, easy, risk-free development help from humans. (Disclaimer: I am affiliated with Ancorra LTD)

1

u/hyoahn 4h ago

The biggest jump in reliability is to stop asking the model whether its own code works — LLMs rationalize their own assumptions and miss silent runtime bugs. Wrap DeepSeek/GLM in a deterministic verification loop instead:

  1. Typecheck + deterministic AST check after every edit: Require tsc --noEmit (or pyright) and a local bug scanner (e.g., npx xapbug src/ — runs locally across 50 languages with 0 cloud calls and catches unguarded JSON.parse, null-deref, missing await, and listener/timer leaks) to pass with exit code 0 before moving to the next task.
  2. One minimal smoke test per critical path: Even a tiny Vitest/Playwright check catches half-wired buttons and dead handlers immediately.
  3. Tight git checkpoints (git add -A per working step): The second an agent starts looping on fixes, reset to the last green checkpoint instead of letting it rewrite healthy code.

0

u/FarSideOfSaturn23 15h ago

I have this technique, called learning how to do it myself. Also applies to non coding related skills, for example, DIY, couple of years ago I completely installed a new kitchen myself. Fixing up clothes is another one when I inevitably receive a Christmas present that doesn't exact fit, repairing hardware. So many things you can do, if you just take the time to learn.