r/ClaudeCode • u/thecelestialbabe • 7h 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?
67
Upvotes
•
u/AutoModerator 7h 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.
174
u/gatsu_1981 6h ago
113
u/WordWithinTheWord 7h 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.
41
u/djaxial 7h 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.
10
u/LiquidZebra 7h ago
GitHub ub-mode is a start, have it write you a scoring tool, it will show the CRAP score
9
u/rghthndsd 5h 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.
15
u/UhLittleLessDum 4h 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.
43
u/Jackster22 7h ago
you ask it not to make mistakes and boom it works
17
u/rhacer 7h ago
You learn to read code.
5
u/cybersgk 6h 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.
6
u/Obvious_Service_8209 7h 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.
6
u/Sharp-Wheel-6736 6h ago
This one is easy. It's always making spaghetti.
It might also be fixing the bug.
3
u/Acclynn 7h 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
3
u/life3_01 7h ago
😆
You won’t. Therein lies the problem, but people are getting things to work.
3
u/drivingagermanwhip 6h ago edited 6h 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/Bed-After 3h 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.
3
u/slumberjak 2h ago
“Make no mistakes”
3
u/nuehado 2h ago
My current opinion is that you only have 3 options.
2
u/id-ltd 7h 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"
2
u/shetritr 7h 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
2
u/Healthy_Koala_4929 6h 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.
2
u/Nohbdy94 3h 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)
3
u/No_Paramedic_4881 7h 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
2
u/YellowBeaverFever 7h 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.
1
u/autoencoder 7h 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.
1
u/EconomyDoctor3287 7h ago
Run tests, let it refactor. Review the output with another agent.
1
u/therealorkor 7h 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
1
u/Evilkoikoi 7h 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.
1
u/McNoxey 7h ago
Learn.
1
u/throwaway_31415 7h ago
What’s your regression test setup look like?
1
u/srga1p 7h ago edited 7h 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
1
u/BertMacklenF8I 🔆 Max 20 7h ago
Your best bet is to use “Highways” to Antigravity and Codex
1
u/Sirramza 7h 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/
1
u/Live-Distribution125 7h 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.
1
u/quasistoic 7h 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/BotFrances12 7h 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.
1
u/iam-stevie-bee 7h 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.
1
u/lefix 7h 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
1
u/Deep_Abalone_4996 7h 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.
1
u/VivaLaDiga 7h ago
you learn to read code, which requires you to write code for years.
1
u/CurrentEconomist6855 7h 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.
1
u/aguywiththoughts 7h 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.
1
u/angry_cucumber 6h ago
learn to read code
1
u/FloridaIsTooDamnHot 6h 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/kantorcodes1 6h 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.
1
u/newfoundpassion 6h ago
If you don't know the architecture principles your code should be following, you're going to struggle with slop. You have to define these things in documentation, have strong models analyze and refactor, do adversarial reviews with different brands, build tests, learn from mistakes, and follow a process that covers every base.
Incredibly high quality output is possible, but it takes more work than you think.
1
u/No-Willingness2120 6h ago
Sorry to tell you, but if your unable to read code or understand backend archetecture you will not be able to pick up on slop.
You might make some software but to make something that holds with a proper scalable archetecture , you will need to understand code
Or you will be spending 3x as much tokens and time as someone else to create something similar
1
u/Ok_Elk_6753 6h 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.
1
u/doanamo 6h 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.
1
u/Akarastio 6h ago
I use Tools like CodeCharta for it
1
u/Tzareb 6h 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.
1
u/blinksy182 6h 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 :)
1
u/RealFullMetal 6h 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.1
u/lemming1607 6h 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
1
u/Legitimate-Pumpkin Thinker 6h ago
I asume it’s doing spaghetti and that the next iteration of the model will help improve it 😅
1
u/Plenty_Line2696 6h ago edited 6h 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.
1
u/Level_Notice7817 6h ago
it’s fine. lol
1
u/palmerden5 6h ago
ask it what else the change could affect before it edits, and have it explain that in terms of what the tool does
1
u/No-Market-4906 6h 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.
1
u/OliviaX05 6h 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.
1
u/dsailes Max 5x - Freelance Dev 6h 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
1
u/justagoodguy81 6h 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
1
u/steveism 🔆 Max 20 6h 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/
1
u/MrArko 5h ago
You use something like Superpowers or GetShitDone to get a spec-driven workflow with Tests.
A lot of Tests.
1
u/CandidSystem6155 5h 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.
1
u/Forsaken_Wafer_7584 5h ago
I guess that's why some companies are now selling the service of human review 🤣🤣 https://ogmaintelligence.ai/services/human-code-review
1
u/Funkytadualexhaust 5h ago
Dont ask it to find bugs, it will everytime, then create extra code for them. Rinse and repeat.
1
u/swupel_ 5h ago
I just use Creview
1
u/c0reM 5h ago
You write an incredibly clear plan of the end state and read every word of it until it’s perfect.
Then you let it implement.
Then adversarially review and test it.
That’s where the spaghetti will happen because it will start writing patches on top of patches to fix each thing that was missed in real world testing.
Then you do a comprehensive audit to look for over-engineering and spaghetti code and refactor.
Basically exactly the same way as if you were writing the code by hand. Just someone else is doing the coding.
How is this faster you ask?
Because you can run 10 threads at a time :)
1
u/bentreflection 5h 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.
1
u/bumbeishvili 5h 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
1
u/Existing_Ant_1109 5h ago
you know you can ask Claude about the fix?
1
u/rossg876 5h ago
That’s why learning to code, for now, is still important. IMHO
1
u/DjangoZero 5h ago
Only thing you have to understand is that AI is a force multiplier and multiplies and amplify what you give it.
1
u/itsallfake01 5h ago
Get it reviewed by astra or neon
1
u/hibbelig 4h 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.
1
u/barcodemerge 4h ago
You don’t.
1
u/jerryorbach 4h ago edited 4h 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.
1
u/gigastack 4h 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.
1
u/Illustrator_Forward 4h 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.
1
u/Alternative-Time-412 4h ago
Regression tests; have codex review the plan and the implementation
1
u/rolandofghent 4h 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.
1
u/TheAxodoxian 4h 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.
1
u/kelkes 4h ago
You don't.
Learn to code or hire someone who can.
1
u/Maleficent_Cycle561 4h ago
Stay in your lane.
How do you diagnose your own medical issues with cluade? You stop and see a doctor.
1
u/ObjectiveAide9552 3h 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.
1
u/casentron 3h ago
You don't. That is your limitation and you will have to accept it.
1
u/kkingsbe 3h ago
Audits 👍
1
u/stefano_dev 3h ago
You ask a dev :)
1
u/lovelybullet 3h ago
Because I've spent 10 years doing this
1
u/Ainudor 3h ago
I ask Gemini
1
u/sudden_aggression 3h ago
If you have a coding background
1
u/SamSlate 3h 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"
1
u/lastchancexi 3h ago
Right now, this is why software engineers have jobs.
1
u/ByteFoundry 3h 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.
1
u/yogimunk 3h 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
1
u/bystander993 3h ago
Because my system won't accept the code until a test is added that fails with existing code and passes with new code.
1
u/valdev 3h 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.
1
u/ricopan 3h 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.
1
u/BloodMore9033 3h 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.
1
u/Old-Wolverine-4134 3h 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.
1
u/SimonStrange 🔆 Max 20 3h ago edited 2h 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.
1
u/ApeInTheAether 3h 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.
1
u/puts_on_rddt 3h 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.
1
u/Woit- 3h ago
Short answer: if you can't read the code - be sure that it's a sphagetti
1
u/fhgwgadsbbq Developer 2h 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/MannToots 2h ago
Most of the time it gives it away during the conversation phase. This is why building the plan is so vital.
1
u/Fra5er 2h ago
Learn to code?…
1
u/mrpoopistan 2h ago
1
u/MaintenanceSafe5444 2h ago
Tell Claude to build verification checks every time you make a new feature or change something. My latest app has over a thousand verifications that get ran every time something changes. This way you catch any bugs you created immediately
1
u/TealTabby 2h ago
I have a web tech background and I’m building an iOS app so I am pretty much in a similar situation. I am using a skill set - Superpowers which I found very good for planning and testing after the fact. I am not sure about the code quality - I will do an architectural review with a different LLM later and see 😬
1
u/New-Nov032026 2h ago
You learn how to fucking code.
1
u/cautistic-john 2h ago
Save a working checkpoint, then write down the exact clicks that reproduce the bug and one nearby flow that already works. Replay both after the change with the same data. If fixing the button breaks save-and-reopen, you can roll back and give Claude the exact failure to reproduce.
1
u/Some-Detail9134 2h ago
Ask: are you making spaghetti?
1
u/Gwaptiva 1h ago
As someone who cannot read code, you won't know. Living on the edge is thrilling, no?
1
u/Gwaptiva 1h ago
As someone who cannot read code, you won't know. Living on the edge is thrilling, no?
1
u/FrontHandNerd Developer 1h ago
Use it to help you learn coding. Help show you mistakes in yours or someone else’s code and have it explain why it’s wrong. You literally have a personal tutor. Have it teach you!
1
u/tndrthrowy 1h ago
Tell it to refactor the code using a “SOLID” architecture. Read up on what that means. It’s the best known approach currently to organizing code (not going to argue this, friends - it’s simply true and I say this with 40 years of experience on hundreds of codebases).
If it is able to tease apart your spaghetti into clean components, you should run into fewer problems adding new features.
1
u/Few-Celebration-2362 1h ago
If a change in one place breaks an unrelated feature, you've got spaghetti
1
u/PeachScary413 1h ago
Ah that's actually quite easy, so the first thing you usually do is simply learn how to read and understand the code. Then you can do this really cool thing which is kinda like spending tokens except it's actually free.. and that's when you type new code into the computer using the keyboard 🤯 it's kind of a lifehack and I use it all the time now.
1
u/zayelion 1h ago
You can read it. Laymen people can read good code.
1
u/r-rost 46m 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/VoodooKing 22m ago edited 17m ago
I asked Claude to create a log file of bug fixes it does and append new bug fixes to it.
For each bug fix, I'll use another AI to build the prompt. I use the new prompt and get it to refer to the log and tell it not to undo a bugfix while fixing the new bug.
I tell it to notify me if it needs to modify a previous bug fix to fix the current bug. So far it has been working for me.
1
u/KamikazeSexPilot 8m ago
You assume it’s creating spaghetti. More often than not, it is. Especially if you can’t read and guide it.
1
u/Admirable-Degree6807 6h 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/slowtyper95 7h ago
You don't. Because you don't even know what is wrong and what is right
1
u/kpetrovsky 7h 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?
1
u/Pulsarlewd 5h 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/mathhtam9999 4h ago
Even if you can read code the changes usually are just too much and you wouldn't be able to make sense of it.
-2
u/cseickel 7h ago
You cannot, I'm sorry. I have been writing software for about 25 years, and I use AI every day as a central part of how I write code, and I can tell you with absolute certainty that there is no amount of tokens or magic prompts you can throw at this to ever produce anything other than AI slop.
AI absolutely destroys search engines and Stack Overflow, it is great and spitting out a proof of concept and boilerplate code. The first version of anything it creates will be probably better than the first version of anything a human creates.
The problem is that software is iterative, it takes hundreds or thousands of revisions to get to 1.0. Every iteration the AI will screw up the code base a little more. AI has no understanding and definitely no judgement. It just does what you ask it to do. If you don't know how to write software, the AI you use doesn't either. It will never say "no, that's a bad idea, I wont do that." Even when I know what is right and wrong and I hand it a very detailed design, it still screws it up 50% of the time. It also can't really work on something that is novel, a concept you created that sets your work apart. It can only repeat standard patterns that it was trained on. The good news is that 90% of coding is just repeating standard patterns with different details, so a lot of people get lucky and can slide by on that one.
The only reasonable way for you to use AI to make software is to use it for proof of concept work and then hire a developer to take that concept and make real production ready software. The AI PoC is an amazing documentation of what you actually want, and honestly that is the hardest part.
-3
u/nw303 Developer 7h ago
How do you know? Hire a software engineer to review the code and architecture.
If this ( fixing one thing breaks another ) is happening, your architecture is most likely already a mess.
Hate to pile on like all the rest but this is why software engineering needs to be done by software engineers.
-1
u/daredeviloper 7h ago
That’s the KEY question IMO I’m struggling now with as a 15 YOE and they’re asking us to use this at work
What if the code is so spaghetti we will reach critical spaghetti level that AI can’t continue in its mess and we now have to
You wouldn’t ask a new dev to troubleshoot a critical issue on a mess of spaghetti on day one right? Give them at least some onboarding. But IMO even if you’re built the product from day one you haven’t looked at the code you now must troubleshoot from day one and that is a huge deal.
IMO the only solutions are 1- trust it won’t happen by: ensuring testing, building in small pieces, committing code so you can rollback quick 2- review code yourself 3- guide AI to troubleshoot
Would be happy to know of any other options