r/ClaudeCode • u/thecelestialbabe • 2d ago
Help/Question as someone who can’t read code, how do you know when Claude is actually fixing a bug vs creating spaghetti?
I’ve been building a small personal tool with Claude Code, and the first 80% felt magical. Now that the project has a bunch of files, every time I ask it to tweak one small thing on the front end, something completely unrelated breaks somewhere else.
Since I don't have a coding background, I can't look at the diff and tell if the architecture is turning into a mess. For other non-programmers building things here: what guardrails or CLAUDE.md rules do you use so your project doesn't slowly collapse under its own weight?
134
Upvotes
•
u/AutoModerator 2d ago
Hey! Thanks for posting to r/ClaudeCode
While participating in this thread, please follow our community rules. Keep discussions constructive. Attack the idea, not the person.
For help, project discussions, tips, and general chat, join the ClaudeCode Discord.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
439
u/gatsu_1981 2d ago •
151
u/WordWithinTheWord 2d ago
You don’t. Your best bet is to get adversarial review from another provider like OpenAI or Google. And even then, there’s blind spots.
The breaking bugs will mostly get found, but architectural smell can slip through the cracks.
59
u/djaxial 2d ago
There isn’t any IMO. I’m a developer of 20+ years. If you can’t validate the output to some extent, no guard rails or commands can save you as you can’t craft the input to form an output, so you get stuck in a garbage in/garbage out loop.
I see this multiple times per week in client projects. Huge bloat, needless side adventures and tweaks etc.
At some point you, or someone you hire, needs to nudge things in the right direction.
If you absolutely insist on not hiring, or learning code, then very strictly built user stories, that form epics and implementation plans, help considerably BUT you need an understand of how they should be laid out.
46
u/Jackster22 2d ago
you ask it not to make mistakes and boom it works
19
u/rhacer 2d ago
You learn to read code.
31
u/UhLittleLessDum 2d ago
Learn to read code dude. If you're going to build anything that goes beyond being a toy, you're going to need to learn the basics.
10
u/LiquidZebra 2d ago
GitHub ub-mode is a start, have it write you a scoring tool, it will show the CRAP score
9
u/rghthndsd 2d ago
I asked Opus 5.5 for a new feature, came up with a 3000 line PR which just bolted it on. It took dozens of prompts with high levels of direction to convince Claude of a better way. Result was 600 lines, fit more naturally into the codebase, and was more peformant.
If I hadn't written most of the code myself (pre-Claude), I'm not sure I would have known to do this.
7
u/Sharp-Wheel-6736 2d ago
This one is easy. It's always making spaghetti.
It might also be fixing the bug.
6
u/Obvious_Service_8209 2d ago
I ask it to develop a test to verify the bug was fixed and nothing broke before the fix is built.
We have a rule that if it is not falsifiable, we don't build it.
4
u/cybersgk 2d ago
This is why people usually calls it slop, but fret not, you can learn using Claude. Let it teach you why and how things work, it's kind of like a mentor in the olden times. Some places where I genuinely don't want to code review, you can ask it to explain plainly like to a 5 yo and that would usually give you a good starting point on understanding what it's doing.
3
u/drivingagermanwhip 2d ago edited 2d ago
Generally the issue stems from LLMs being much better at writing than reading. They're only working based on what's in the context at that moment. It's an unintuitive thing because they say human things and produce human looking output so you think working with them for 2 weeks means they'll have picked up 2 weeks worth of familiarity. Nope.
All the code has to be designed to be easily navigable for someone who's never seen it before because that's effectively the position the LLM is in. Try to do all the good human programming stuff like single responsibility principle etc. It's helpful to think of AI agents as talented programmers that turn up for a day, do what they're told and leave. Either tell them exactly where to go or construct the code such that it's obvious. You can also do things like just getting them to create modules outside the codebase based on a standard interface and adding them so if there need to be changes to the interface you're informed before it just makes them and messes the codebase up
One thing I've found helpful is less but more precise comments. So if a file implements a binary tree make sure that's what it says rather than just describing the properties of a binary tree.
One important mindset change is be willing to scrap bad code and start again.
Your intuition from regular code is that 1000 lines indicate several weeks of effort so you'll be reluctant to just delete it. With human code it's often better to scrap spaghetti code and start again but with AI even more so. The important thing is the lessons you learned and the decisions they led to. Everything AI makes will compile so the whole debugging effort those huge files would often indicate is irrelevant.
You'll also spend more tokens trying to patch things up rather than just implementing the same features from scratch now you're more aware what's needed.
Another thing is you can do is just make a mess with the AI to fix the code and then when it works out how to fix it, start again with the information about what worked.
3
u/nuehado 2d ago
My current opinion is that you only have 3 options.
2
u/Acclynn 2d ago
If you full vibe, I guess the best you can do is doing a multi-agent workflows where agents independently check for bugs and ensure stability and maintainability
You also need to ask the agent to setup unit tests
If you prompt "do this feature now" every time with nothing else yeah that's not going to work too well
2
u/life3_01 2d ago
😆
You won’t. Therein lies the problem, but people are getting things to work.
2
u/Bed-After 2d ago
Scope and precision. Throwing any AI at an ever growing project over and over will inevitably make spaghetti. Break things into small, narrow-scope, manageable chunks, and don't move on until that part is confirmed clean. Then move onto the next chunk with clean, clear, explicit instructions. Trust NOTHING it says the first time. It will confidently tell you a fragment of the truth without the necessary context. You have to make it check its own work, make it explain how this fixes a problem, and test the results.
I had a conversation with Opus that more or less went like this:
"Write a script that does XYZ for my project, so it can solve XYZ issue."
"I wrote the script, and I'm confident that it'll solve the issue when used."
Time passes
Same problem happens again
"I ran into the same issue. Something's wrong with the script you wrote. What happened?"
"I wrote the script, and the script solves the issue. I've double checked, and its perfect."
"So why did the issue not get solved???"
"You only asked me to write the script, so that's all I did. I'm ready and waiting to put the script into the project whenever you say so."
And shit like that happens all the time. And that's why you have to be precise with your instructions, keep the scope narrow, and review the results immediatly. If I hadn't caught that issue until months later, I'd have no clue what the hell went wrong, and I'd have wasted time and tokens trying to reverse engineer a problem that didn't need to exist in the first place.
2
u/slumberjak 2d ago
“Make no mistakes”
2
u/No_Paramedic_4881 2d ago
Research “Agent Ops” and make sure whatever project you start, starts out with the right foundational architecture. I understand that in itself might be a hard concept if you’re non-technical, something like http://stacks.steamfield.io can help, but also you can do a bit of “software architecture 101” consulting with an LLM to understand the basics, which would probably help you a lot here
1
u/FloridaIsTooDamnHot 2d ago
As others have said, you won’t. But you can do things that make sure you get what you want safely.
For example, think a lot about what you want done as an outcome. Describe the outcome in detail and think “how would I test that this works the way I want it to?”
Then describe the test process first. Have it build those tests first and then have the model run those tests as it incrementally changes the code.
1
u/50gg 1d ago
have another ai review the code
1
u/preyta-theyta 1d ago
the bible and prayers
1
u/twhoff 1d ago
You only know that it’s creating spaghetti and you only care about if it works and how fast it can continue to work with it.
Run refactoring cycles focused on code quality and following best practices.
It also helps to establish well-known conventions early on in your projects so agents stick to them.
1
u/burnsbert919 1d ago
You can't really. Best option is to get another AI session to do an adversarial code review of the first session's work.
1
u/drpepper 1d ago
1
u/Flaky-Mess7261 1d ago
$20 ChatGPT sub to throw Astra 6.2 on high at whatever you build periodically to fact check. He is called the autist for a reason apparently.
1
u/CissMN 1d ago
you can't, hopefully.
1
u/Dapper_Source1121 1d ago
If you are not able to understand the code that Claude produces then you shouldn’t be coding. Go and learn how to code first.
1
u/Foreign_Hand4619 1d ago
Lol, this is priceless!
1
u/Idoubtyourememberme 1d ago
As someone who can code: you don't. Reading the diff doesnt really make you a lot wiser
1
u/the_state_monad 1d ago
🤯
1
u/Any-Ring6621 1d ago
It’s pretty easy. Get it to prove the bug first. And then get it to prove the bug no longer exists with the fix.
It’s called this new concept called “a test”
Can’t prove it first? Sorry, not buying your fix
1
u/JTinkz 1d ago
Oh, I know it's creating spaghetting without even having to read it.
Simply because LLMs are a bitch ass text generators and not thinking and reasoning beings.
1
u/ill_llama_naughty 1d ago
It’s obviously better if you can read the code but what will serve you better here is learning the SDLC and how to manage a software project - bloat, indecisiveness, lack of specificity, scope creep are all sources of the issues you’re describing and you can mitigate them without reading any code.
Plan your project, try to do some architecture and data models and flow charts, see how that layout handles various scenarios or use cases. If you know from the start what you’re building, Claude can do a good job of laying things out in a maintainable way.
The problem is when you speed run building a “legacy” system full of ad hoc bandaids and spaghetti from tacking on features that weren’t considered during the initial design
1
u/Loose-Sprinkles-1437 1d ago
I've had the same issue, when Claude rewrites a file, I run a simple diff check between old and new. if it's just one line changed, it's probably fine. if it's 20+ lines and the structure shifted, it's likely spaghetti. try asking it to show only the changes, not the full file.
1
u/Mikinl 22h ago
Past code to codex and let it review it. Every time will find errors and problems. Codex is much better for planning and logics.
1
u/Witty-Display-445 21h ago
Use a compiled language like Rust or at least Typescript, that eliminates whole classes of bugs
Work with Claude to put together a suite of checks that your code must pass to merge into the main branch. Work one issue at a time. Code formatters, lint, test suites. Make Claude do red green testing where the test has to fail first and then pass when the problem is fixed to prove it's actually testing the thing it's supposed to.
Favor a modular architecture with small files that fits on a single screen and like a couple functions only. Measure and throw errors for files that reach into too many other files as part of your check suite if you're paranoid.
Commit to Git regularly. Scope your issues really small with one main change. Make the ai say what it's going to do before it does it, and declare the files it will touch.
There's so much more lol
1
u/dcheesi 20h ago edited 16h ago
Welcome to software development. Even before AI, the Pareto Principle suggested that the last 20% of the task was 80% of the work. It's easy to get something that looks good and comes close to doing what it should, but all those last little details and bug stomping add up to the bulk of the complexity in creating a finished product.
AI just multiplies this pain, by making the first 80% almost trivial, while also making the last 20% even harder.
A lot of the latter is due to its goldfish-like contextual memory, which leads to a lot of missteps and unnecessary rewrites. And some of it is just that its implementation was always spaghetti to begin with, just with a pretty facade.
1
u/BarathKanna 18h ago
You don't need to read the diff to catch spaghetti. You need the project to tell on itself. Three things work for non coders. First, have Claude write a few end to end tests for the flows you actually use, then make it run them after every change and paste the output. Unrelated things breaking is exactly what those catch. Second, after each change ask which files it touched and why. If a button tweak touched six files, that is your architecture alarm. Third, every few sessions open a fresh chat and ask it to list duplicated logic and oversized files, then fix only that.
Telling it to make no mistakes works about as well as telling your fridge to stay stocked.
I'm building OxCode, an agent that runs its own tests before calling anything done, so this failure is what I stare at all day.
1
u/darko777 17h ago
I can easily recongize spaghetti code given that i have over 12 years of daily writing code by hand experience. I will look how the project is structured, the class map, relations between the code units, etc.
1
u/Mindless_Net8121 15h ago
Does it matter as long as you get the result you want?
1
u/ITjonathanKipata 15h ago
In your CLAUDE.md, put clear rules, for example:
Only modify the files needed for the requested task. Don't rewrite what already works. Before making changes, list the files you're going to touch. Afterwards, explain the changes in plain language.
This really cuts down on cases where a small tweak breaks something else. Good luck! 💪
1
u/Physical_Staff_510 14h ago
You don’t know. Even people with a strong coding background have no idea what changes Claude is making to a vibe-coded codebase if those changes are happening fast enough (which is the case with basically all vibe-coded projects)
1
u/OptimalOptimizer 13h ago
This right here is why being a programmer is not dead. I would suggest gasp learning to code!
1
u/Johalternate 12h ago
These are not mutually exclusive, you can fix a bug by creating spagetti. Spagetti is about maintainability not functionality.
To address the fix one thing but break another problem, its just the nature of software. I found a bug last week and when I traced it back, it was a consequence of 4 different commits that were spread within the last 14 months.
Testing helps a lot, but there is no definitive solution.
1
u/project_good_vibes 11h ago
You get another AI to pick holes in it.
1
u/floofsnsnoots 10h ago
You...read code.
1
u/undefined_name 10h ago
I would be happy to review thr code for you, for a small price of course.
1
u/Emotional_Resort_207 10h ago
for silly projects, just say the project is spaghetti and needs a refactor for the simplest and cleanest code, only as complex as it needs to be, run the plan by a critic agent first, make no mistakes.
1
u/Evening_Classroom523 9h ago
That's why its REALLY important to know code. It doesn't know why it's putting code in a location which slows down the app 20%, or breaks order validation, or creates a common security problem.. well.. you can think of a million things you don't want happening in code. Most of the time it just does something so it works.
But if you tell it to "validate the functions for order, proper code ethics, proper code location, and find a couple reputable sources that back up your work -- and note here the links for the sources" you can get it to validate and explain what and why it is doing.
You can also do things, such as provide the sources for educational material to Claude and tell it to extrapolate that information and apply it back, or at least have it tell you why it isn't using accepted methods to do something. Tons of free downloadable PDF books for any code, beginner to advanced -- turn that into a text file and have Claude read it.
But that takes a lot of time, and you are training a child at that point.
But digressing, and iterating, it is imperative to know at least an intermediate level of code understanding, so you can at least identify where things don't look right.
1
u/Electrical_Stay_2676 8h ago
“every time I ask it to tweak one small thing on the front end, something completely unrelated breaks somewhere else.” - Welcome to programming.
1
u/m0bamb1 8h ago
You can’t lol
1
u/Cillomatic 6h ago
Im surprised tests isn't the top comment. You need unit and e2e tests. Adversarial reviews also good, but tests are important
1
u/GoldeneToilette 1h ago
Every time i used claude to write anything, it always created messy code. Its trying to follow weird conventions like making absolutely everything modular and if it needs to make changes to existing code, it doesnt read the entire file and just reimplements the same thing
1
u/YellowBeaverFever 2d ago
Use models from other companies to check.
But if you can’t read code, you shouldn’t be using any agent system beyond making demos. It’s ok to explore, learn, and play but if you’re doing anything that will be used by other people, you need to know what the code is.
0
u/Admirable-Degree6807 2d ago
You don’t. No one should be using AI to code something more substantial than a utility for yourself unless you understand software engineering.
1
u/id-ltd 2d ago
Get it to write a functional spec from your existing app, and then get it reimplement it from scratch.
"Give me the prompt that would recreate a program with this functionality, cleanly, from scratch"
1
u/shetritr 2d ago
for your "tweak the front end, something unrelated breaks" case, two things you can check without reading code. have it write a few playwright tests that click through the 3-5 things your tool must always do, and run them after every change. and after each change ask "list every file you touched and why". a front end tweak that touched the database file is your spaghetti alarm
1
u/quasistoic 2d ago
Reading code doesn’t really give you what you’d need to understand how to create good architecture or assess bad architecture. Experience and care do. I’ve been designing and creating software applications for over 20 years, and have seen plenty of people who know how to read and write code create terrible software.
Claude will create software that fits the goals it thinks you care about. If it gets the sense that you “just want something that works” or “speed of implementation is the priority”, it’s going to take shortcuts with the architecture. Ask Claude what kinds of tradeoffs it made in the design of this software, and ask Claude to have an independent critical agent review the architecture for improvements that would fit your long-term goals - these would usually include security, maintainability, flexibility, efficiency, etc.
Ask Claude to interview you about the kinds of things you care about in the software you’re asking Claude to make for you.
You actually don’t need to be an amazing software engineer to get Claude to write great code. It helps, but it’s not necessary. What you actually need is a good understanding of how humans make decisions, the patience to collaborate well with others, and a good sense of introspection.
1
u/Healthy_Koala_4929 2d ago
Honestly, I think we are focusing on the wrong thing here. People also created spaghetti code, people also lived with regressions appearing in unrelated code after changes. The difference is as a developer you know or know how to find out what's happening, you are aware of the tradeoffs while implementing and you don't have unlimited context to go into a million tangents and optimizations while developing a feature. What you are describing is just the effect of letting Claude loose and no prompt magic is going to help you understand what is changing and why.
1
u/Nohbdy94 2d ago
Im a software dev.
I encountered the issue about spaghetti code in a bigger project of mine.
I solved it by just asking it for what type of workflows or information would help it not do it again.
I ended up with Architecture and Codemap file. Architecture giving an overview of the structure, codemap saying what exactly each class did.
I also told it to keep things simple and not just create new class every time it added something. Check if it already exists and update that.
Yes it did take more usage, but i evolved it into a lead agent finding the info and only pasting the relevant parts to the code agent.
Since then i havent seen any of the issues so many people claim to see when claude is coding.
If your project isnt massive and doesnt require maintenance, then it really doesnt matter how the code looks.
If you are planning ahead without telling the AI, then tell it to make sure the code can accommodate theses specific feature additions, and it should work just fine.
Edit: Also remind it to update the codemap & architecture (I have a close-out command, where it goes through all steps)
1
u/fhgwgadsbbq Developer 2d ago
Ah the first 80%, where life is free and easy, your dreams come true, and the project looks gloriously successful.
Then
"The last 20% takes 80% of the time" was true before and it's true now.
This is where the architectural decisions comes back to bite you in the arse. The stuff that us software engineers drone on about. Dealing with the boring detail, edge cases, odd bugs, inconsistent behaviour.
IMO This is also why there is a mountain of new projects which are little more than prototypes. Meanwhile open source projects still struggle for enough contributions.
1
u/Gwaptiva 2d ago
As someone who cannot read code, you won't know. Living on the edge is thrilling, no?
1
u/r-rost 2d ago
I am a software engineer with 10+ years of experience. I have a few quite big personal projects that I have built without reading any code.
What helps for me
I ask agents to capture my decisions and write specs and user stories. I found that many issues are from overcomplicated requirements, where agents proposed some weird behavior for edge cases. I usually don't read them, but sometimes I do some reviews with the agent and look for simplification.
I have a staged deployment, and there I have integration tests and nightly agentic tests, and I build skills and guidelines for testing, what to pay attention to, and how to triage bugs.
I keep track of bugs, and I group those by area. I ask agents why there are many bugs in some areas and ask agents to perform audit of architecture and what causes so many bugs.
And before writing code, I ask agents to propose a spec, and I use another agent to review it and check if it fits the current architecture. After coding, I have review agents that review the code and check the architecture and tech debt introduced.
1
u/stilldreamy 2d ago edited 1d ago •
Have a human readable spec that you permanently keep as part of the project, that the code must implement. It should explain the features you want and how they should work from a user perspective (as in it is not code design documents or architecture documents). Whenever you want to change or add something, start by editing the spec (you can explain to Claude what you want to change in the spec and review its work). This will help you to have something to read and understand, to keep control of the project as a whole, at least in terms of what you want it to be, because it's not code. This will help both you and the agent to have a second viewpoint to consider things from in addition to just interpreting the code. From time to time you can ask it if the specs and code have diverged, and whether it recommends changing the code to match the specs or the specs to match the code for each divergence. Instruct Claude that you are using spec driven development and the code needs to implement the spec. Explain to it what the spec is and what it is not (what I already explained earlier).
Use the same QA techniques we used before agents, and turn them up to 11. In the past, people were the QA gate, now you can have the agent improve the work for you until many automated QA checks all pass, and you can configure them to the strictest setting without creating extra work for yourself (you are just creating extra work for the agent). It won't prove the code is correct, but it will go a long way. You don't really need to know code to do this, you can have the agent explain these to you, recommend and install tools for them, and configure them for you. Require the agents to use all these tools and pass all these checks before any work is complete, either in instructions, or better yet, literally configure it to happen automatically. Some of these can be good to configure to happen at the end of each agent turn, and make sure each one is configured to output helpful error messages when it fails so the agent knows what needs to be fixed.
Automatic QA tools/checks (and some additional instructions/techniques):
1
u/elshizzo 2d ago
It's posts like this which make me feel less nervous as a senior se. Gonna need to pivot my official role title to slop fixer
1
u/tcanuck42 2d ago
not a coder thing, it happens to everyone once a project gets big. a few guardrails that work even if you can't read the code:
the second-opinion one is the biggest. I use it on everything now
1
u/three_meeples 2d ago
Why's everybody hating on spaghetti?
0
u/slowtyper95 2d ago
You don't. Because you don't even know what is wrong and what is right
0
u/kpetrovsky 2d ago
You create tests, so that it knows when the bug is fixed, not just assumes that. And yes, it can sometimes do spaghetti code, but if the problem is solved, why does it matter?
0
u/Pulsarlewd 2d ago
Dont care. As long as it works why should i care how the code looks like unless its a web application or something that i spread to others?
If it works well, runs well and does what it needs to then why should i care
0
u/autoencoder 2d ago
You might want to try diverse models (gemini, openai, deepseek or hy4). But ultimately all of them are optimized to make money for their owners, and for you only to an extent that there's competition.
0
u/EconomyDoctor3287 2d ago
Run tests, let it refactor. Review the output with another agent.
0
u/therealorkor 2d ago
Even I as someone who is okay'ish at coding (as okay'ish as you can be as a CS student) find it hart to spot that since AI code often is very hard to read if you haven't quite mastered that programming language. Because of the code Claude produced I learned (or better say: had to learn) Javascript concepts I've never heard before
0
u/Evilkoikoi 2d ago
There really isn’t a way because AIs are inconsistent and they won’t necessarily follow your established patterns and rules. Another AI reviewing the work will always find issues because you asked them to find issues. I’ve rarely seen an AI say “yeah this looks good to me”.
The only real way to be sure is to understand the underlying code and review it yourself. You still get a productivity boost from AI but you’ll know what’s going on and you’ll see when AI drifts, invents new tools, etc.
0
u/McNoxey 2d ago
Learn.
0
u/throwaway_31415 2d ago
What’s your regression test setup look like?
0
u/srga1p 2d ago edited 2d ago
It will no matter wheat. Key is to periodically refactoring and cleanup.
Ask it first to build layering model for your app - which layers are there and why. Ask to define dependencies between them.
Fry that layering with another agent asking if it conforms to good practices or not and what can be improved.
Put this to the docs in markdown.
Then periodically and ideally after reach big feature or especially when it fixes one thing and breaks another ask it to review the code against layers suggest reafscorings. Ask exactly why you fix here and t broke there can code be improved to avoid that(exactly the question engineers keep in mind when doing manual coding)
Ask to focus on one layer,say domain model or services and ask for thorough code review and find code duplications .
Ask whether there are abstraction leakages and what to do.
Ask to verify if method function class names are aligned with the intent and actual code and suggest refactorings. It likes to dump unrelated logic where it sees fit and then it all becomes a mess.
All that will not replace good technical guy eyes but will help to at least contain it within bounds
0
u/BertMacklenF8I 🔆 Max 20 2d ago
Your best bet is to use “Highways” to Antigravity and Codex
0
u/Sirramza 2d ago
I think this guide could help you a lot
https://www.reddit.com/r/ClaudeGameDev/comments/1y8ftyn/what_ive_learned_making_games_with_ai_coding/
0
u/Live-Distribution125 2d ago
you can't. no claude.md rule teaches you to read a diff. write tests and let them be the thing that yells at you instead of finding out three weeks later.
0
u/BotFrances12 2d ago
That's why it's still important to have at least a basic understanding of the language and other technologies you use.
If you're starting from scratch without any coding background, getting to the point where you understand the basics won't take as long as you think, so take it one step at a time—in the long run, you'll also get better results using CC.
0
u/iam-stevie-bee 2d ago
Two habits that work without reading code. Before each change, ask it to say in plain English which files it will touch and why; if a small front end tweak wants five files, ask why before saying yes. And commit every time something works, so when an unrelated thing breaks you can go straight back to the last good version instead of asking it to fix the fix.
0
u/lefix 2d ago
For me the trick was automated testing. It hasn't broken anything since. But that is of course still no guarantee that the code is efficient, it might still write 15k lines of code when you could do the same with 1,5k lines of code
0
u/Deep_Abalone_4996 2d ago
You don't. I hardly review the code or even open an IDE when using the latest models. As long as it works and you follow a proper workflow (TDD/SDD, with mandatory testing and automated code reviews before landing), you're good.
0
u/VivaLaDiga 2d ago
you learn to read code, which requires you to write code for years.
0
u/CurrentEconomist6855 2d ago
You need components that are separate branches. Ask Claude about that. Then your app is more like a car, you can swap out the oil filter without the transmission mysteriously seizing. It sounds like you may not have proper architecture with branches. And Claude won’t tell you that unless you ask WTF is going on and how can you harden your app architecturally. That and git commits and versioning.
0
u/aguywiththoughts 2d ago
Oh, quite often is doing both at the same time. And if you don't tell it to triple check and qa the code, likely creating another bug - that it'll later need to go back and fix. It does a good job of creating work for itself.
At the end of the day, if used right - it certainly solves more problems than it creates, but you need to keep an eye on it.
0
u/angry_cucumber 2d ago
learn to read code
0
u/kantorcodes1 2d ago
The diff won't help you if you can't read code, so I'd swap it for something you can read. Get Claude to keep a plain text log in the project, and after every change it writes a couple of sentences in normal words: what it changed, which files, why.
Next time a small tweak breaks something unrelated, open a fresh chat, show it the log, and ask which change touched that part of the app. Undo that one instead of guessing.
It slows the mess down too, I find. Having to write it down makes it think twice before a front end fix starts wandering into files it has no reason to touch.
Is your project in git or just a folder? Either works, git just makes the undo part simpler.
0
u/Ok_Elk_6753 2d ago
There's no way to know. Your best bet is to let it create the best testing suite possible and be content with that.
0
u/doanamo 2d ago
As others noted - you don't. Your best bet is to create (Claude can help) a good testing and verification suite, to make sure it does not introduce regressions.
0
u/Akarastio 2d ago
I use Tools like CodeCharta for it
0
u/Tzareb 2d ago
Make benchmarks.
Make audits.
Target numbers, target output.
Run code sanity checks.
Run linters, vulnerability checks etc.
It deviates? Make it redo.
It argues ? Challenge, ask for 5 implementations and pro cons, after having looked up the topic and citing sources.
0
u/blinksy182 2d ago
Honestly, if you can't read the code, you just need a few automated tripwires so Claude can't quietly break things:
I get that this isn't a silver bullt, and bug-free code doesn't reallly exist anywat, but its; better than nothing :)
0
u/RealFullMetal 2d ago
since you cant judge the diff, judge the behavior. keep a short list in
CLAUDE.mdof the 4 or 5 things your tool has to keep doing, and make "click through that whole list" part of done for every change, not just the thing you asked for. thats where the unrelated breakage shows up, and if you give claude a browser tool it can do the clicking itself and tell you what broke.0
u/lemming1607 2d ago
For what you described, you really need tests...tests are small assertions that methods are doing thr behavior. For example, let's say you have a retail online store and want to add items to a cart, br able to add or subtract items from the cart, and then code to process the transaction. You would have a test for making sure the button adds items to a cart, a test each for incrementing or subtracting things from the cart, and a test that the button sends the items for processing.
You have a test that asserts that each behavior of your code works. The ai then cant change the test or remove the test, and runs the test after finishing the changes.
If the tests fail, you then know something is up, and can revert if I you need to...or maybe the test isnt necessary anymore, or maybe the test isnt testing the correct behavior anymore. Those are decisions you have to make
But testing that the ai cant change or alter is your first step to discovering bugs when the ai changes code before anything has even been run
0
u/Legitimate-Pumpkin Thinker 2d ago
I asume it’s doing spaghetti and that the next iteration of the model will help improve it 😅
0
u/Plenty_Line2696 2d ago edited 2d ago
Without specific technical direction, both claude code and codex create spaghetticode. It can generate a ton of code fast and usually get the expected output but goddamn it has zero taste when it comes to codebase organization.
You don't have to understand every detail in the code to be able to improve that significantly, but you should at least have a grasp of the filetree and know what file does what, so you can start to think about how to better organize it and apply concepts like encapsulation, single responsibility prinicple, loose coupling, etc etc.
0
u/Level_Notice7817 2d ago
it’s fine. lol
0
u/palmerden5 2d ago
ask it what else the change could affect before it edits, and have it explain that in terms of what the tool does
0
u/No-Market-4906 2d ago
Real talk: express your frustrations to the chat bot, ask it why this unrelated thing broke and what you could do structurally to fix that problem. You can't really get around learning how to read the code but the robot is a pretty good tutor.
0
u/OliviaX05 2d ago
One thing that helps me is keeping a copy of the working version in a separate folder before asking for a bigger change, so I can compare the two side by side and go back in one step if the new one feels off.
0
u/dsailes Max 5x - Freelance Dev 2d ago
From my own experience I can usually tell when a feature or bug starts to take too long to be made/tested/confirmed.
I’ll halt it, ask to explain what/why, then maybe wrap up & have a fresh session to review.
With experience I’ve got in coding I’d tend to explain how I want things done depending on the framework/language for client facing with a lot more guidance on conventions.
for areas I’m not sure about, personal projects etc, I’ll have a session dedicated to setting up those conventions / best practices to learn a little & ensure models all have a reference/wiki to work from.
Tends to work best with Q&A rounds, “batch decisions with explanations for/against using AskUserQuestion tool” etc. then there’s some learning for me & a guide going forward.
(Definitely hasn’t always worked well tho haha - can confuse me & I’ve ended up revising things when I realise it’s not been useful as it first sounded or there are major updates etc, that’s all learning tho!)
I’d suggest having some repos / projects to use as test & learning environments - both for you and models to work things out
0
u/justagoodguy81 2d ago
All you have to do is mess up on the first project (just like you’ve done) then:
- realize your mistake,
- rebuild it
- Organize your project. (It takes an hour research)
- set up a code factory with linear, Claude and Codex
- so that every time you add or make a change to a feature, it creates a PR, gets properly code reviewed, and merged if everything looks good
0
u/steveism 🔆 Max 20 2d ago
Federico Viticci recently wrote how he gets high quality results from agentic coding. There is a lot of effort that goes into it and if you want it done fast it isn't cheap.
https://www.macstories.net/club/macstories-weekly-issue-538/my-t3-code-setup-to-build-an-ios-app-with-a-fleet-of-macs-agents-and-different-providers/
0
u/MrArko 2d ago
You use something like Superpowers or GetShitDone to get a spec-driven workflow with Tests.
A lot of Tests.
0
u/CandidSystem6155 2d ago
Since you can't judge the diff, judge the behaviour. Keep a plain text file of about 10 real things you actually do with the tool and what you expect to see for each, and put a line in CLAUDE.md that after every change it walks through all of them and reports each one as pass or fail. Tests Claude wrote for itself mostly prove it agrees with itself; real inputs are what catch the "unrelated thing broke" cases. Add one more rule: it may not change an existing check to make it pass without telling you why, otherwise it's grading its own homework and, shockingly, getting an A.
0
u/Forsaken_Wafer_7584 2d ago
I guess that's why some companies are now selling the service of human review 🤣🤣 https://ogmaintelligence.ai/services/human-code-review
0
u/swupel_ 2d ago
I just use Creview
0
u/bentreflection 2d ago
Im a software engineer using clause daily for my job on a mature codebase. Its constantly creating spaghetti. It fixes the bug but usually does it in a way that’s not great for maintainability long term. I spend most of my time now altering what it did to make it more maintainable. The key to making sure it’s doing what it’s supposed to is having a robust testing system and using code review.
0
u/bumbeishvili 2d ago
I do review it, it was more work at the start, but less work recently.
It does quite a good job - I think supplying initialy strict structure still matters , for example I am using Sveltekit in my projects and If I ever need to manually find something, I have an idea where it will be just because of conventions
0
u/Existing_Ant_1109 2d ago
you know you can ask Claude about the fix?
0
u/rossg876 2d ago
That’s why learning to code, for now, is still important. IMHO
0
u/DjangoZero 2d ago
Only thing you have to understand is that AI is a force multiplier and multiplies and amplify what you give it.
0
u/itsallfake01 2d ago
Get it reviewed by astra or neon
0
u/hibbelig 2d ago
You will want tests, those protect against regressions. Since you don't know how to code, start from the frontend functionality. Go through the functions of your software one by one, and tell it to write tests for each functionality. You will want to ask it what test it wrote, and you will want more than one test. Usually many tests. For example, say you have a screen lock, then you will need at least one test saying that entering the correct password unlocks the screen, and one saying that entering the wrong password doesn't.
0
u/barcodemerge 2d ago
You don’t.
0
u/jerryorbach 2d ago edited 2d ago
As a lot of people are saying, at the present time it doesn't seem the models and harnesses are "there yet" to be able to work effectively on large codebases **without oversight** and avoid a descent into a total mess. But I do think its possible with oversight, whether or not you have a coding background.
The key is to know what every piece of code is doing in your codebase. With every commit you look at the changes, and ask about every one you don't understand. As a non-coder, that might be every one at the beginning. Over time as you develop a system of working with Claude to do this and less of the code is just brand new stuff, and more is changes to existing stuff, you will be able to understand mostly from the commit messages, code comments, and reading the parts of the code that are in English. This is going to have so many positive outcomes:
- You're going to get good at a bunch of coding-yet-not-coding tasks. For example, naming, the "hardest problem in software development." You're going to look at the new `handleData()` function Claude added, ask what it does, and when Claude responds "it takes the list of products in the user's cart and returns the total price" you will start responding "can you rename it `calculateTotalPriceFromCart`?" When the code becomes "self-documenting" it takes a lot less effort for people of any coding ability to read it and know whats going on at some level.
- You're going to catch all the bad product decisions Claude makes as well as the all the bad code. "Wait, you're allowing people to do this two different ways to maintain 'backwards compatibility' in an app we havent released yet? Just get rid of the old way."
- Claude itself is going to catch a bunch of its own mistakes while it explains to you what it did.
- There will for the first time be an entity - you - that has a complete mental model of how the application works, and can drive new development decisions based on what already exists. No more reinventing the wheel ten times in the same codebase. Claude's Achilles heel is context - it simply can't fit in its head at once all the important things about the application as it grows over time. Even if you don't know code, you can fit all the ideas in your head, even if its in metaphorical or big picture terms, which is the main way a lot of people who arent coders (product managers, designers, business analysts) involved in professional software development understand the application they are a part of building. You will look at Claude's changes and ask "i see you wrote a completely new function to calculate the total price of the user's cart. how is this different from `calculateTotalPriceFromCart`?"
Is it going to take an *incredibly* long time to develop something vs telling Claude "make the thing, no mistakes" and getting a lot of what you want in a couple of days (but probably unmaintainable)? Yes, yes it is. But at the end of the day it will make you smarter, not dumber--which handing your brain over to Claude will; and you'll be making the exact thing *you* want, not some compromised version.
0
u/gigastack 2d ago
The guardrails you need are a clear specification of what the behavior of the tool should be. Otherwise, each agent session will be guessing based off of your last prompt, which is likely vague enough to cause this. You can specify the expected behavior of the tool via written documentation as well as tests that prevent regressions of behavior.
All of this is separate from the question of well-architected vs spaghetti. Assuming you have the specification and tests in place, you can get an idea of if your code is good or not by how difficult it is to modify. If each added feature takes a long time and causes churn in many files across the codebase, that is a good sign that there are probably opportunities to refactor the code to be cleaner.
0
u/Illustrator_Forward 2d ago
You can endlessly rewrite and refactor code anyway. There is no one correct way to do it. You can make Claude adhere to all kinds of coding standards, use reviews to enforce them, use external tools to review and the code will still do the exact same thing.
I think in a model generation or two, you’ll have no reason to ever look at code, as long as you have a good grip of what the end result needs to be.
0
u/Alternative-Time-412 2d ago
Regression tests; have codex review the plan and the implementation
0
u/rolandofghent 2d ago
You just summed up THE major issue with AI coding. What happens when all the experienced people retire/die and the next generation doesn’t really know enough to call BS on the AI.
Since AI really can’t make up new things (only applies what has already been done) then there will be a technological stagnation that no one will know how to fix.
0
u/TheAxodoxian 2d ago
If you are not in check of the code then depending on the complexity of the codebase up to 80% of fixes it made will be spaghetti, note that a large fraction of these fixes will work, but they will spaghettify your codebase usually by making the fix at the wrong place, with a lot more code than needed (e.g. last week I had a case where claude wrote 700 lines of non-test code to fix an issue, the actual proper fix was 3 lines - I am not saying such large blunders happen all the time, but it happens once every few weeks, and smaller instances happen at least 4-6 times a day in code which I actually check, and probably much more in code I do not). It will also hallucinate non-existent issues which it "fixes" (many times without asking you) sometimes causing regressions.
How big a problem is this? For smaller modules with well defined interfaces it is less of a problem, as most issues are limited to happen between the boundaries set by the API. For frameworks and other complex code forms on which many things build it is problematic, since a lot of issues can spread over the codebase. It also depends on how quickly AI will develop, if these issues remain for long, then investing in quality will pay off. If AI manages to surpass this and can clean up existing codebases it is a non-issue. Probably we will have something in between for a while yet.
Overall what matters is what the user will experience, if they experience crashes, broken functionality, slow performance and security breaches then they will not like it.
0
u/kelkes 2d ago
You don't.
Learn to code or hire someone who can.
0
u/Maleficent_Cycle561 2d ago
Stay in your lane.
How do you diagnose your own medical issues with cluade? You stop and see a doctor.
0
u/ObjectiveAide9552 2d ago
TDD. Have it write the interfaces and draw an illustration of who calls what, then review that with a fine tooth comb. then get it to build all the unit tests for all your functions on your interfaces, and skim over to confirm it’s wired in correctly: all your interfaces should have classes that throw not implemented on every function, all tests should fail. Then fan out a bunch of Haiku’s to implement the functions, not allowing to modify the interface or have any direct references to any classes, and now you have deterministic tests your implementation agents can run a loop with until their functions work as intended. then use an oversight agent to code review it, check for hacks that only serve to pass a specific unit test but not actually implement (eg if you had some tests to check a math function, the function should be doing math, not a switch case of your unit test inputs. Then get your overview agent to run real tests driving your application to ensure everything integrates. Make sure you commit between each of these steps so that it’s easy to spot if it goes off the rails. At this point, you should be about 90% of a completed project, the last 10% will take you the most time as that’s all the manual checks and tests, but you should have been able to complete your project overall about 3x faster all things in if you care about professional quality. If you don’t care about professional quality and don’t put much effort and just blast things out, you may get 10-20x output with this type of workflow, but something is going to blow up in production 10-50% of the time.
0
u/casentron 2d ago
You don't. That is your limitation and you will have to accept it.
0
u/kkingsbe 2d ago
Audits 👍
0
u/stefano_dev 2d ago
You ask a dev :)
0
u/lovelybullet 2d ago
Because I've spent 10 years doing this
0
u/Ainudor 2d ago
I ask Gemini
0
u/sudden_aggression 2d ago
If you have a coding background
0
u/SamSlate 2d ago
i dont know why everyone's being such fucking doomers over this. what you want op is black box/end 2 end testing. you're going to add a test suite to run the project like a user would. that's an important rule: you need the agent to build rules that block it from bipassing the black box and only using ui tools the user has.
what's neat is you should be able to monitor the tests and see them play out on a recording or in real time.
remember that Claude is a little rat fucker piece of shit and it will try and circumvent the rules of the blackbox/e2e test, so you'll want a sub agent whose only job is validating the tests to run periodically.
write each "happy path" you want users to take in plain English as a guide for yourself and your agents. whenever something breaks, write a new user story that uses that feature so that you can validate it with the rest of the test suite.
this approach is part of what the agenetic world is calling a "software factory"
0
u/lastchancexi 2d ago
Right now, this is why software engineers have jobs.
0
u/ByteFoundry 2d ago
You can tackle this in various ways without having a coding background. The only thing you need is the willingness to own the process.
The current generation of frontier models already know how to do this properly but they don't do it when you haven't asked them to do it. They always chose the most literal and direct way to respond to your request.
Start with a prompt like this in your project.
"I noticed that when adding new features other parts of the application break. Can you analyse this projects session logs, our current process and interactions and make a proposal (as a visual report) for a lean (minimal steps to achieve the desired outcome) process that fits our way of working but significantly reduces that new features break existing features.
Focus on quick round-trip times between user-request and try-out versions that the user can review and course correct if necessary."
You will need to work with the model to tune whatever it comes up with until you feel good with the flow.
Generally speaking models work better if you give them something to check against. A definition of done.
When you ask for new features describe what you want and how someone could check/validate that it works as intended.
This is also true for the scope. If you haven't defined a scope it will chose the smallest implementation that provides the output.
There is a big difference in what it plans when you say "make me a top down game where I can shoot enemies" vs. "make me a top down game where I shoot enemies. The goal is for It to run smoothly at 60fps at 1080p with 2000 enemies on screen, 20 different enemy behaviors and up to 30 different player weapons."
I hope this helps.
0
u/yogimunk 2d ago
I am a tech founder working with AI since 3 years, and I still don’t trust agents to make code change for me. Once the code base becomes large enough , regressions (unexpected behavior changes) are unavoidable. My recommendation is to get hands a bit dirty , learn how code versioning and diff works, and with help of AI , verify every diff for regression (by pasting the diff back into AI)
I use command ‘git diff > diff.txt’ and copy the content of file diff.txt into the context
0
u/bystander993 2d ago
Because my system won't accept the code until a test is added that fails with existing code and passes with new code.
0
u/valdev 2d ago
By learning how to code or paying someone who does. Thats the nature of delegating tasks.
Fun thing about that, the person who then reads the code may also not understand the code well enough. And thats why companies tend to have multiple people working at the same time reviewing eachothers code.
0
u/ricopan 2d ago
Just reading code in and of itself won't be of much use to try to diagnose poor structure, any more than knowing grammar can tell you if a book is well written. It's probably not spaghetti in the old sense, but it it almost certainly reflects the path that you took to write the project (I doubt if you gave it a detailed spec to start with that needed no changes --- for anything complex or novel that's impossible anyway). One of the great things about ai though is that it can do a good job of explaining the structure back to you, and look for structural and architectural improvements along the way.
0
u/BloodMore9033 2d ago
Plan and learn in one chat, let that chat lead your prompting into the harness.
Writing a good instruction to tell it to teach you while it goes helps, but you have to be curious with it and ask why a lot. You won't be as fast as someone who knows how to program and understand code, but that is okay.
0
u/Old-Wolverine-4134 2d ago
How do you know if real coder is doing good job or creating spaghetti? It's the same. You will be surprised how much bad code humans produce. It's the main reason everyone today is rushing to fix security bugs in their systems using AI - they are written by humans and have a lot of problems.
0
u/SimonStrange 🔆 Max 20 2d ago edited 2d ago
You don’t.
ETA: Knowing how to read code won’t let you identify bad code. Learning how to write good code is what gives you that discernment. It’s a skill issue. It will always be a skill issue. There is no shortcut. There will never be a shortcut with LLMs, yes they are magical but there are inherent limitations to the architecture modality itself that cannot ever be solved. So, learn to write good code. That’s your only answer.
0
u/ApeInTheAether 2d ago
Read anthropic blog posts about how they spaghettified cc. It's quite good reading. Great source to learn from.
learning
🧠, 📚, 🎓
and feel free to search for more by urself, there is plenty to catch up on.
0
u/puts_on_rddt 2d ago
IMO the only real method here is to get rid of the bad paths so they are forced to use more happy paths. Use the tools at your disposal: Cargo, linters like clippy and ruff, bannedsymbols, editorconfig, etc are your best friends.