Tips on dissecting vibe code
from reabsorbthelight@lemmy.world to programming@programming.dev on 24 Feb 16:45
https://lemmy.world/post/43529561

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?

#programming

threaded - newest

Rhaxapopouetl@ttrpg.network on 24 Feb 16:49 next collapse

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

Solumbran@lemmy.world on 24 Feb 16:52 next collapse
  1. Ask what was the purpose of the code
  2. Delete all the slop crap
  3. Make the code from scratch
VibeSurgeon@piefed.social on 24 Feb 16:57 next collapse

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

reabsorbthelight@lemmy.world on 24 Feb 19:06 collapse

Primary maintainer …

VibeSurgeon@piefed.social on 24 Feb 20:33 collapse

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.

doeknius_gloek@discuss.tchncs.de on 24 Feb 16:58 next collapse

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 on 24 Feb 17:00 next collapse

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.

reabsorbthelight@lemmy.world on 24 Feb 17:16 collapse

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 on 24 Feb 18:08 collapse

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

owenfromcanada@lemmy.ca on 24 Feb 17:48 next collapse

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.

ultimate_worrier@lemmy.dbzer0.com on 24 Feb 17:55 next collapse

I did this recently. Here’s how I made it sane:

  • clone it to a branch
  • concatenate every line of code and paste it into an LLM with a prompt asking for a summary of the issues with the code
  • make a TODO list so you can work from that (a .md file of the LLM’s output)
  • use that list to aggressively delete the dead code while compiling it with each change
  • committing each change that keeps it working while also paring it down.
  • keep starting a new LLM session with each change and the same “make a detailed analysis of the issues with this code” prompt with it along with the newly concatenated code (this helps a lot to keep hallucinations down)
  • at some point, more cosmetic deletions/changes won’t be necessary and you can start carefull refactoring the code that is actually connected to something while also compiling then committing at every working change.
  • then you can start using the LLM as an assistant but actually USING YOUR BRAIN to decide how to fix the architecture and flow of the code. Of course you can ask for advice but ALWAYS keep in mind that the LLM will give you stupid advice and tell you you’re a genius and blow smoke up your ass if you’re too shy to ask a real person (like I am).
  • If it’s a language like Haskell or Rust or Purescript, you’re in for an easy time. If it’s something ubiquitous but dynamic and unsafe like JavaScript or Python, GOOD LUCK!!!

I think the biggest problem with vibe-coding is when someone doesn’t take the time to understand the WHY of the changes the code is making. This is why I can’t abide agentic access to my code. Every change must go through me. I won’t even let the AI give me files , preferring to get everything in front of me.

reabsorbthelight@lemmy.world on 24 Feb 19:06 next collapse

Yeah. I want to do something like this. I was hoping to run a proper dead code analysis first.

But this is a good idea. For how to reduce the code volume. I need to reduce the abstraction layers because there are a bunch of unneeded ones

ultimate_worrier@lemmy.dbzer0.com on 24 Feb 21:48 collapse

LLM’s really helped me with this. I am now working with only code that is wired up and can ask for insight into my ideas while being highly skeptical and lucid about any advice.

I’ve found prompts that make sure to use words like “idiomatic” can prevent LLM’s from going off the reservation to some extent. It’ll try and reinvent the wheel or pull in hallucinated libraries if you’re not careful but it’ll probably also be aware of the idiomatic way to do things in each language.

Have fun and take a walk if you’re getting burnt out.

I’ll sometimes send my concatenated code in, ask for advice, then paste that advice into my phone to have it read aloud to me as I walk around. It can go into insane detail. So as long as you stay skeptical of it, it can be a really good tool for what you’re trying to do.

grueling_spool@sh.itjust.works on 24 Feb 21:32 collapse

I guess despite how intimidating it seems, un-fucking vibe code can be approached just like every other complex programming problem: by breaking it down into smaller problems and solving them incrementally.

ultimate_worrier@lemmy.dbzer0.com on 24 Feb 21:53 collapse

Definitely. Also once it starts to take actual logical shape, showing it to real people is also great if you have that luxury (which I don’t). :)

kibiz0r@midwest.social on 24 Feb 20:20 next collapse

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

My first thought is test suite.

Feyd@programming.dev on 24 Feb 20:55 next collapse

Cry in the bathroom

reabsorbthelight@lemmy.world on 24 Feb 20:56 collapse

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

87Six@lemmy.zip on 24 Feb 21:06 next collapse

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.

e8d79@discuss.tchncs.de on 24 Feb 21:34 collapse

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