this post was submitted on 24 Feb 2026
29 points (96.8% liked)

Programming

25759 readers
818 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities !webdev@programming.dev



founded 2 years ago
MODERATORS
 

I was handed a pile of vibe code. And you might be surprised to learn that it has a ton of bugs.

And tips on how to dissect it and break it up into something manageable?

all 25 comments
sorted by: hot top controversial new old
[–] tiredofsametab@fedia.io 1 points 48 minutes ago

If possible, you could try to get the requirements and design to those and write something new.

If that's not possible, I would start flow-charting. I always do it by hand in whatever tool you have handy. Some languages have tools that can do this for you (Go and Java and I think PHP to name a few) if it's that big of a mess. From there, find your inputs and outputs and go back to the "rewrite it" part.

[–] froufox@lemmy.blahaj.zone 3 points 8 hours ago (1 children)

Depends on the size of the pile. If it's huge, then you have to use LLM too, with some decent tooling like Claude Code. Let it analyse the code first, and put a summary for you. Then design the proper solution yourself, and either fix it manually, or if it's too tedious, guide LLM to apply the changes for you. Ofc iteratively and don't let it apply changesets without your approval. I had a similar task recently, did it like that

[–] onlinepersona@programming.dev 2 points 3 hours ago

Fighting fire with fire. I like it.

[–] e8d79@discuss.tchncs.de 8 points 12 hours ago

Document the features and requirements, then rewrite it with proper architecture and without LLMs.

[–] Solumbran@lemmy.world 36 points 17 hours ago (1 children)
  1. Ask what was the purpose of the code
  2. Delete all the slop crap
  3. Make the code from scratch
[–] TrippinMallard@lemmy.ml 2 points 2 hours ago

can confirm. this is the way

[–] Feyd@programming.dev 8 points 13 hours ago (1 children)
[–] reabsorbthelight@lemmy.world 9 points 12 hours ago

I just cry at my desk and tell them it's because AI is so beautiful

[–] doeknius_gloek@discuss.tchncs.de 19 points 16 hours ago* (last edited 16 hours ago)

Vibe code it a bit further, then pass it back. If they can hand you slop without second thought, why shouldn't you?

[–] yaroto98@lemmy.world 18 points 16 hours ago (2 children)

For work, or for hobby?

Hobby: have AI document what it's supposed to do, then work through it like the ship of theseus one function at a time replacing it with not bad code.

Work: use it, document the bugs, ninja in and clear them out one at a time until it works. Keep blinders on and ignore anything not directly related to each bug. Same strategy as legacy code.

[–] draco_aeneus@mander.xyz 1 points 51 minutes ago

The problem with this approach is twofold.

  1. The AI doesn't know what anything is either. It can annotate faster than you, but if it is all wrong, that doesn't help.
  2. The primary reason the code is bad, and something the AI is particularly weak at without a human doing much of the thinking for it is architecture. Working your way through ship-of-theseus-style isn't going to address the fundamental reason the code is difficult to work with. The architecture.
[–] reabsorbthelight@lemmy.world 11 points 16 hours ago (1 children)

For work. The code goes like 8 levels of abstraction. I'm trying to figure out how to unravel it.

Even a code flow/branching diagram would help I think

[–] zener_diode@feddit.org 6 points 15 hours ago

Depending on the language, there might exist an automated tool for generating those kinds of diagrams from code.

[–] kibiz0r@midwest.social 3 points 13 hours ago

Nature of the code? Library, CLI tool, cloud service, API, UI?

My first thought is test suite.

[–] VibeSurgeon@piefed.social 5 points 16 hours ago (1 children)

Handed to review, handed to maintain, handed to extend?

[–] reabsorbthelight@lemmy.world 1 points 14 hours ago (1 children)
[–] VibeSurgeon@piefed.social 5 points 13 hours ago

The same as taking over any legacy project applies, really.

Start out with some expectation management - the current state of the solution prevents progress from going fast, and your stakeholders need to understand that.

Then get some tests going, such that you can try to defend whatever value the system has, if any.

Finally, start refactoring as much as you can get the space to do. Repeat until the system reaches your desired state.

[–] Rhaxapopouetl@ttrpg.network 4 points 17 hours ago* (last edited 17 hours ago)

Of course! Vibe coding is a popular activity nowadays and *** thinking ***

[–] owenfromcanada@lemmy.ca 3 points 16 hours ago

Start by separating the files by namespace and class. Then, by method. Delete the first method, then the next, and so on. Then rewrite the code by hand as God intended.

[–] 87Six@lemmy.zip 0 points 12 hours ago* (last edited 12 hours ago)

Unironically get Opus to get you a base of a flow document based on the code so you can figure it out.

Then of course, you dig in yourself, understanding what Opus said, then fiflling in the gaps.

Edit: I don't think you need to pay for Cursor to prompt Opus once for this. Just make sure to use Opus, Auto picks the dumbest model available on free tier.