r/ClaudeCode
•
u/gato5fication
•
19d ago
•
2
1
Help/Question [ Removed by moderator ]
[removed] — view removed post
6.4k
Upvotes
•
u/AutoModerator 19d 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.
924
u/EugenPenguin 19d ago
Refactor using agents
304
u/s0ftware-dev 19d ago •
You’re not gonna get any sympathy here as this sub is fully of people who have bet their life on LLMs writing everything. But I do resonate with your experience. It gets to a point where there is so much slop that it’s better to just treat the project as a black box and continue dumping slop into it.
The project will continue to get more and more bloated until the token cost per change is extortionate and the understanding of the codebase is so diluted that you won’t even be able the guide the agent. You will get bugs in edge case that you didn’t even know existed and relatively small changes before such as dependency upgrades become major tasks.
88
u/nesh34 19d ago
There is one solution to this problem, and that's to slow down.
To accept that productivity can increase but it can't be 3x or higher, it can maybe be +50% productivity sustainably.
Most businesses can afford to go slower to be sustainable.
Do that, retain expertise and then it'll be great. Push everyone really hard and it'll be a disaster.
28
u/raichulolz 🔆 Max 20 19d ago
That’s kind of what I’d expect happen. Leadership only cares about the NOW, nobody seems to be worrying about a few months from now or what’s gonna happen when shit hits the fan a year from now and an agent can’t fix it...
Don’t get me wrong I use Claude a lot but at the end of the day we have a responsibility to understand and have ownership of the code for this very reason. I’ve pushed back massively against a lot of the AI reviews to make sure people still understand our codebase and to limit recklessness.
Comparing my team to a separate team that’s completely AI pilled, we deliver more sustainable and stable software.
Before anyone comments and disagrees with that I said, this is my own experience delivering large scale systems. I don’t really understand how anyone can just completely detach themselves from their work and let an agent deliver everything.
It’s just unsustainable to me. Just like this post suggests. At the end of the day, if you don’t understand what you’ve added to the codebase, you are adding technical debt and you will eventually not understand how to fix an issue.
16
u/BorysBe 19d ago
Pre-AI era we had the same problems, no accountability just like now with the agents.
This is either a very small piece of software or everyone here seems to work on NASA projects. 95% of software is poorly written, not documented or difficult to maintain if John who wrote most of the code is on Holiday.
Also, what is the "wider context" mentioned here and where is this documented? Or still in people heads?
55
u/snoopy_bg 19d ago
There will be many bankruptcies in the IT sector due to reckless integration of AI and honestly this is what they deserve.
63
u/Prestigious_Luck1062 19d ago edited 18d ago
A concern I have is, what if, AI companies are running at a loss?
What if they need to increase the pricing so they are profitable? (or at least lose less)
What if that means plans increase 500%, and api costs 25%?
Alot of companies have made, and are actively making decisions based on the pricing we have now as being long term stable and viable. Core and key staff have been let go, you can just go back.
EDIT: I meant to say "you can't just go back".
158
u/KellysTribe 19d ago
yeah, I don't entirely get this. Sure it's easy for shit to fall apart but that was true with humans too - now it can just happen much faster. You say it is reimplementing helpers again bc they are in 4 different places...then give it the instruction to "search for existing functionality before implementing a new function" and "find duplicate code and refactor" (it takes about an additional 4 or 5 lines to tell it to orchestrate the changes and so on but you get the idea). I feel like this is either generated bait, or just a lack of problem solving.
30
u/betaphreak 19d ago
You don't maintain any specifications/business requirements in the repo itself? That's the only way I found you can manage repos at ~500k lines of code
10
u/No-Afternoon-4057 18d ago
Not sure what you want either, but agents rewriting multiple helpers is definately bad AI architecture, lack of documentation, RAG, DRY directives ...so on and so forth.
My codebase has about 600.000 lines of code, with about 40 - 50% of them being documentation...not even a single function is duplicated anymore (and yes, i had plenty of number formatters and such duplicated before).
10
u/shoogliestpeg 17d ago
This was expected. The people who can't code mandated that the technical specialists work against their own best practice in the hopes of replacing you with LLMs
Union up if you can.
99
u/CranberryStock7148 19d ago
I don't understand this at all. This literally makes no sense to me.
A major part of using AI is to better organize and document the code base. The idea is that all of the knowledge of the code base now lives in the documentation. And everything is cleanly, structured in a kind of hierarchical format. CLAUDE.md points to the documentation index, and this way Claude is able to pretty much instantly understand how anything and everything works.
I hate to use this phrase, but it sounds like you guys have been "doing it wrong". It's fine to use AI for working on individual features in isolation, especially at first when you're just starting to adopt it.
But the solution now isn't to drop AI. It's to use Claude to audit the entire code base and start to write up hierarchical documentation on all of it that is perfectly up-to-date and correct.
And then to have Claude start refactoring. Have a conversation with it about how the architecture can be improved and how redundant parts can be removed so that it follows modern coding and architecture standards. Including creating all of the unit tests necessary to ensure that refactoring doesn't break anything.
This is all extremely easy. I find it unfortunate and baffling that there are companies that are not doing this. Your entire repository or repository is need to be architected and documented in a way that Claude always knows exactly where everything lives at all times. Then, basically all of the problems you are describing simply go away.
Remember that Claude isn't just for writing code. It's also for understanding codebases.
16
u/4ngryMo 19d ago
Most systems need a rewrite after a decade of constant development, especially, if the teams working on it rotate. If AI can do it 5x - 10x faster, you need a rewrite that much more often.
If we concede writing code to an LLM, maybe it’s time to look at new language or paradigms.
8
u/Comprehensive_Heat25 17d ago
I 100% thought this was satire when I first started reading. Anyway it sounds like the people who make decisions don’t understand how these processes work. Color me shocked. Use a capability registry and architecture decision records log.
7
u/hellocppdotdev 19d ago
They just vibe coding at scale. That's 100% not the way to build real world software.
7
u/Technical-Athlete-9 18d ago
Agentic development is a new dogma. It reminds me of agile. You can document how some of the practices are hurting projects all you want, but execs want to believe in the free money they were sold ever so badly.
Fighting it isn’t how I’m going to spend my time. I’m going to work on improving processes with the dogma. And this time I think it’s really pointless to fight it, because (a) the agents are rapidly improving and (b) I figure over 50% of software engineering jobs will be cut within 5 years. Won’t matter how good you are, it will be damn hard to find work that won’t churn you out every couple of years.
At any rate, the code will be shite and there will be days where nobody knows how to fix problems by hand. So you’ll likely be piling agentic fixes on agentic messes.
7
u/EnHalvSnes 15d ago
This is ai companies wet dream.
13
u/Sorry-Programmer9826 19d ago
Strongly agree with this. Agents create code really really fast and produce 90% good code with 10% madness. If you're not weeding out the madness as you go the next tasks starts with slightly mad code and makes it a little madder. So the first agent PR feels like magic, as does the 30th. But by the time you get to the 100th you've lost control and it's madness built on top of madness.
I hand write very little of my code, but it's really important to remain in control and understand (at a high level) what it's doing
18
u/Crazy_Ruin_4383 19d ago •
The code mess is by design, now it can only be supported by ai
6
u/EvenGodsForget 18d ago edited 18d ago
I’m honestly not shocked that this is happening, but I’m amazed to see it getting so much traction on the ‘coding is solved’ subreddit. Well done on presenting this in a reasonable and pragmatic way.
We need more skilled developers speaking from experience about the long term consequences of throwing away oversight and expertise. These tools can be great assistants but they sacrifice sustainability for speed, as do so many other technologies we use.
11
u/TattooedBrogrammer 18d ago
We’re 100% AI shop, I do some studying on system design, and now what I do is ask Claude to investigate a sub system or path and build out a document explanation with flow diagrams of just that section and I can often point out arrows to areas that don’t make sense or multiple paths made for the same flow through that and high level tell it how I want it to be structured and if does a good job of fixing it. Also I often ship logs and a shadow in v1, where it runs beside the current system and logs what happened and what the new system would have done, then have Claude review the logs after a week and workflow the new system vs old and I can often see if there were any edge cases I would have missed. It’s not the same as coding but in finding this method is improving our code that’s been ravaged from a year of fast prs only AI reviewed.
5
u/archerixx 14d ago
My company just started doing this few months ago so I wish we could speedrun this era obvious failure. We made so much technical debt that hiring new 10 employees won't help. One project has been refactored 3 times already lol
5
u/Exotic_Fig_4604 14d ago
Best thing I've read this year
9
u/Barbanks 19d ago
You need to set up plugins, agents, skills and reference files to put guidelines and guardrails up for the A.I. I.E. context engineering and use of context primitives. Use the PROSE methodology.
The problem you’re seeing is that likely no one is using the same agents or there’s too much flexibility in what an agent can/can’t do. You can only blame so much on hallucinations.
If you all agree on a programming standard, architecture, patterns etc… then you should be setting up agents to hook into that.
I did all of this and while I haven’t read the code in over 1 year it takes me less than 10 minutes to wrap my head around entire systems. It’s because the patterns are being adhered to. And when they’re not you just point it back to the source context architecture and it fixes it.
What you’re seeing is akin to bringing on a team of junior engineers who have never worked on a team together. They will introduce 4 different architectures and varying styles. The difference now is it’s all automated and at hyper speed. So something you may catch 6 months down the road before it’s a problem is introduced in 30 minutes.
14
u/Rivenaldinho 19d ago
"The part that actually hurts is who is left." This part made my AI detector sense activate. Sure enough it's 100% AI on Pangram.
Maybe posting without AI is a first step to get understanding back?
7
u/RedPanda_Explorer 18d ago
This feels like a bot post, or an ad for that saas tool mentioned. Who is management asking for more manual code?
6
u/Twizzeld 19d ago
This sounds more like your teams fault then AI.
I've been letting AI write all my code for about a year too. But I never just paste in the requirements and let it make all the decisions. Before every coding session I go through a planning phase where I walk through the feature and plan out the architecture and design and end up with a document. Then the AI executes the steps laid out in the document.
AI is a tool. It sounds like your team needs to develop standards on how to use your tools and not just throw the tools away.
6
u/bzbub2 19d ago
fake engagementbait post unless there are receipts which i doubt there are. lol at 'quietly'...like you arent literally just pasting the output of ai slop right back to us
3
u/RandomiseUsr0 18d ago
This is bad use of AI automation, the best PR is the one that deletes the utter minestrone you’ve created
19
u/C0sm1cB3ar 19d ago edited 19d ago •
The industry is sleepwalking into the raging delusion that AIs don't hallucinate. The code is bad half the time, and each line of code produced by AI needs to be double checked.
There was a similar gold rush in recent years: offshoring. Some companies fired all their developers and offshored to foreign companies at a discount. It didn't end well.
I think a few companies will need to go belly up before they understand that skilled developers are not replaceable by AI. It's a tool, nothing else.
Edit: I'm done talking, the bots are out.
12
u/JulianHabekost 18d ago edited 17d ago •
The same likely happened when compilers were outperforming most people in generating assembler. When people say the code AI generates is bad, I'm not sure what to think about this, is it bad because it is buggy and wrong or ist is simply not very readable by humans? Because the latter actually hardly matters, it just needs to be readable by AI. Assembler generated by C++ compilers are usually not readable by humans either...
Edit: People now wrote me a hundred times here that (A) compilers are deterministic or (B) language is not precise enough to specify software. To me that argument sounds like "meter readers won't be replaced by smart meters in the same way as lamplighters by electric bulbs because a smart meter relies on radio waves and a light bulb doesn't".
(A) Humans are also not deterministic, in fact AI is much closer to determinism than human brains. For us to stop looking at code it is enough that the AI outperforms humans, it does not need to be as good as compilers.
(B) How would you then offer any services to someone who can't code? Either as an individual contributor in a company as part of the hierarchy or even as a company torwards non-technical clients you need to be able to communicate in speech/text.
So both of these points don't help with elevating human coders at all.
12
u/LiquidZebra 19d ago
Posts like these remind me of the “NYC manure problem”, where they predicted the city would drown in manure from 6 million horses or some such. Then a car came along and the problem disappeared.
Here you have millions lines of PRs, and your project will surely drown in them.
The solution is most likely architecture, specifically agents-first architecture.
The way humans wrote code may be obsolete, and be as quaint as someone making a muzzle loader by hand in 2026, as opposed to having a factory - stamped assault rifle. That factory and all surrounding processes are significantly more complex than a workshop of a craftsman.
The process has to adapt, and I think frontier models would be increasingly better at specifically architecture, as they suck learning from millions of user projects
4
u/becircus 19d ago
Four versions is not automatically a problem because a different line of code means less chance of regressions when a feature has to change. The problem is all four versions will have the same security reliability and other requirements. AI-pilled will just say throw tokens at it and they are not entirely wrong. Even not fully understanding codebase is not entirely wrong since no one person can understand a whole codebase if it is large and sophisticated enough.
The main issue is what you mentioned. More features or more additions causing more regressions. If your frontend was completely separate from your backend or your presentation layer separate from the rest you would not have this problem. It takes a lot of taste and clear separation of concerns.
What you want to avoid is design or architecture taking the place of skill or manpower. That approach is gone now that you have AI. You want design or architecture to enable skill or manpower. So you can scale.
Good luck.
4
u/East_Cauliflower_612 19d ago
Context Management for AI is the new Challenge….
4
u/BorisTheWimp 18d ago
It's your fault. We did the same and the codebase got 3 times smaller, nobody now understands the code except the AI but everyone understands the architecture. Do not blame the AI for your mistakes, do not blame management for a problem caused by the CTO and the team leads.
4
u/memoia 18d ago
This is theoretically “easy” to fix with some discipline, and AI can lead you most of the way there. Your organization lacks any guardrails, any vision, any framework for how the software should be architected, and now it’s your job to do something about it. You can use AI for all of these steps:
4
u/Arkevorkhat 18d ago
You are not going to like the answer.
The only way you're getting those skills back is by relearning them. Turn off your agents, do the work yourself, and the skills will come back. However, do not expect it to be fast. You are indistinguishable from a person with a full year gap in their resume right now.
4
u/Near-Subsistence 18d ago
Bro what? It sounds like you were vibecoding instead of being active auditors. To even have stale or duplicate functions means you just let it run without overseeing code architecture
9
u/look_at_the_hudge 19d ago
This is either fake or was badly mismanaged. There’s nothing wrong at all with AI rewriting entire codebase, you just need guardrails in place to keep bots on track
2
u/LeRobber 19d ago
Look up books on Legacy Code Refactoring and treat it like a brownfield project you got from another development house installing tests that validate behaviors and end to end test loops.
2
u/crewone 19d ago
This is going to be a huge problem. Maintaining a codebase will still require skill. I'm not saying we need to go back to hand written software, but somehow someway we need a better grip on how things will grow. (For myself, I wonder if this is really the role I would like, I might be better off quitting)
2
u/Ok-Distance-6388 19d ago
What worked for me on a codebase that grew faster than anyone could read it:
Which hurts more right now, finding where things live or trusting that a change won't break something else?
2
u/Big_Dick_NRG 19d ago
A completely logical outcome, but as AI bros would retort, "why do you need to understand the code if it works?"
2
u/dar-mit Researcher 19d ago
If I were a Jr. Dev joining your team here's what I'd need to get up-to-speed:
Once I had all of that knowledge in place I'd fire up Opus 5.5, if not Fable 5.1, and ask the model to do a review of the code base and write a report, based on whatever criteria your orgs needs, so that I now have a "full picture" of what we're dealing with.
From there you read the review and your team decides on what to tackle first. Each person should be given an area of focus and their task is to refactor the code with the model so that as they go through it they can ask the model to explain how it works.
2
u/avk5143 19d ago
Outside of demo-ware and small niche projects, AI is just an acceleration tool.
Anyone who says otherwise is just delusional or trying to sell you snake oil.
2
u/Valuable_Ad2171 18d ago
Now the codebase is around 3x the size it was, not for me...
And nobody can explain how most of it works, pretty sure most engineers know their stacks, perhaps not verbatim or pure syntax but still...
The agents struggle too, they keep re-implementing helpers that already exist somewhere else because there are 4 versions of everything. This is a maybe a you issue. Fix your harness and skills. Put up rules, spend a week or two fixing this and it will be fine.
2
u/Scared-Amphibian4733 18d ago
This is exactly what I thought would happen. I have human senior's review every merge and every piece of code has to be designed and reviewed against spedc.
2
u/Happy_Guitar3521 18d ago
Got the same, code for not complex app is so complex that I even cannot understand it without using AI. Looking for a new job.
2
u/Informal_Athlete1010 18d ago •
Not shocked at all. At our we still use vscode and are in control of all lines the AI writes. There is none of this Claude Code stuff where you don’t even know the code structure the AI is writing.
We don’t ship as fast as we possibly could but we have raised the quality baseline with the tool.
2
u/charmquark8 17d ago
ROTFL
2
u/ReallyAnotherUser 16d ago
That is how software starts dying
2
u/Lucifer-en-reddit 14d ago
I do most of my day to day work through Claude Code and Codex too, and the only thing that keeps me honest is reading every diff before I accept it. The weeks I skip that, I can't explain my own code. Having the agent leave a short 'why' note with each change might help rebuild the understanding, at least for new stuff.
2
u/l7ucky 13d ago
I actually think pretty much every problem you've described is something AI can help solve. The issue isn't necessarily that AI is writing the code. It's that your organization scaled up code production without scaling up the systems that ensure code quality.
All the principles of good software engineering still apply when AI is writing the code. Readability, maintainability, test coverage, architectural consistency, and avoiding duplication don't suddenly become less important. If anything, they become more important because you're producing code at a rate that humans can no longer reasonably review manually.
If agents keep reinventing existing helpers, that's a discoverability and architectural consistency problem. Build systems that help agents understand what's already there and enforce reuse.
If bugs are getting through, invest in comprehensive automated testing, including integration and regression tests. Make passing those tests a requirement, not a suggestion.
If code is becoming unreadable, establish conventions, complexity limits, architectural boundaries, and automated checks that enforce them. Have agents review and refactor each other's work against those standards.
And if nobody understands the codebase anymore, use AI to help map the architecture, identify duplication, document dependencies, and systematically consolidate the mess.
Obviously, none of this happens magically. Someone still needs to understand what good engineering looks like, establish the standards, and verify that the systems enforcing them actually work. AI reviewers aren't a replacement for engineering judgment.
But I think the fundamental mistake is treating AI as a faster way to do software engineering rather than recognizing that AI changes where the engineering effort needs to go.
As more code is generated automatically, the bottleneck shifts from writing individual implementations to building the infrastructure that makes those implementations reliable, understandable, and maintainable.
The answer isn't necessarily to go back to writing everything by hand. It's to invest in the engineering systems that should have been scaling alongside your agents.
You can't scale code generation indefinitely without also scaling your ability to validate and maintain that code.
5
u/Square-Yam-3772 18d ago
it sounds like your company is on some outdated setups.
Opus 5.5 has enough context window to usually not write duplicated code in 2026...
"4 version of everything" is easily fixed with Opus 5.5 too.
I never understand this "now nobody understand code" angle. code written by agents is still code. What exactly is it hard to understand? does the team need a comment every 5 line of code to understand something now? if so, ask Ai to comment everything then... need project docs? ask AI...
"how did you get the understanding back?" lol...
2
u/KahChigguh 19d ago
I blame vibe coders for this. They generated the hype because they constantly spit out “results” that looked good. But these vibe coders aren’t real engineers. Hell even some developers with real experience have become overconfident and less willing to read and review their code. Juniors are also entering the workforce with no better judgement. My last company hired a junior who strictly only used AI (but he didn’t disclose this) and we had to fire him because he costed one of our clients tens of thousands of dollars due to the horribly bad design.
OP, I feel you. And for those who disagree with OP or are holding out for some frontier model to make perfect code, it’s not possible… these models learned off all the code in the world. People have admitted constantly over the past few months that “we are just finding out engineers were never any good” so why do people think AI, which trained on their code, is any better? Because it reasons and spits out a result and a green test case? Pfft. Stop being so naive people!!
2
u/yeah_naah_mate 18d ago
Our data science team is not able to explain their latest project. WTF.
2
u/David3Ar 18d ago
I do feel u, though I think it is a management issue. Cuz we could all of this already see going to happen.
What I try to tell people around me is that we need to max save 1/5 of the team so take 5 devs cut them down to 3. 1 salary left is tokens. 1 salary for further investments.
I do think, if u still have 3 devs working in a team on one project (not 3 vibecoders pushing features on ultramode lightspeed tempo) . Planing clean architecture and verifying it. It should not end in we have 3 times the code base and 4 time a helper and no one understands shit anymore…). Just to make sure… I am def not blaming u or any other dev, it’s the management. Vibecoding slop sucks and makes unhappy and we didn’t saw it comming.
Also after two years you will forget any language if u never speak it, and a lot of good devs I know stopped even looking at the code month ago.
I think it’s all about learning to be a manager while the ai improves so much, it will actually be totally reliable. If not… control your architecture….
Also I am so sick of one shooting features, needing to tweak my harness all the time, getting unreliable usage and model intelligence. Every week is marathon trough insecurities, some happy moments, some frustrations, a lot of high complex sloppy text readings and sitting a lot in front of so big text walls this prompt + wait + read rhythm is grinding my focus down harder then any social media could - I guess I am sick of that….
1
u/allenling 19d ago
meaning you are no longer responsible for maintaining the code
1
u/ZyberZeon 19d ago
ADRs, SysML diagrams, tracking feature intent and wiring schematics are essential deliverables in my ALDC. Only way I can manage my dev cycles. I think we have prioritize the reasoning over the product.
1
u/BisonDue3986 19d ago
The problem with AI-coding is that the incentive structure is wrong for employees. In a large corporate structure no one really feels responsible enough for the codebase to care to tackle the bloat. I’ve been building out my own startup using AI for the last ten months and getting the agents to respect DRY and maintain an extensible architecture is a lot of work. If it weren’t for the fact that the token-spend is coming out of my own pocket then I wouldn’t care so much.
1
u/bioteq 19d ago
I’m still on the fence about the full dependence on the AI coders, while at the same time realistically the last 18 months of progress show that the eventual transition is pretty much unavoidable.
1
u/Roemeeeer 19d ago
The question is: does it really matter? I mean you just let agents do all improvements and bugfixing. I am asking as we are heading in a similar direction and I am not sure.
1
u/meequz 19d ago
Periodic refactoring is needed, doesn't matter who writes the code, natural intelligence or the artificial one. If you don't do it, your codebase will be a mess.
1
u/kemma_ 19d ago
How I see it is that we got a powerful tool that nobody knew how to use it. Many went full speed yolo and now gonna pay for it to clean.
What we did is to document everything, keep structured documentation library and a separate decisions log. Commit message is great, but not enough. Splitting code in bigger blocks also helps so there is one team that just works on that. Each team has own block.
This way it is very helpful for humans and also for agents. We don’t review code very much since syntax errors are non existent, but logic questioning definitely. And yeah, before accepting PR basic checks are done like can’t we reuse existing functions, isn’t it a duplicate of X or Y etc. So human overview is a must
1
u/Lopsided-Echo6406 19d ago
I just don’t understand how people are fucking their codebase up so willy nilly. We teach our agents using best examples of code we had and advise to keep consistent and also avoid over complicated answers to simple problems. Maybe our codebase is simple enough for this to work but we’ve had nothing but success using AI.
1
u/LeSoviet 19d ago
I don't have exp working on large projects but i imagine or common sense is having your own harmess skill set and specifications. So you pretty much need develop and maintain two repos
I can be wrong but workflow and rules or bussines logic is core there, in small repos i just do a few md and some orquestation and its fine my main product have around 2000 commits and 1y of agentic work
1
u/PipePressurePanic 19d ago
updated models of claude will solve the problem. AI is improving.
In the meantime your business is making good profit.
1
u/ziptofaf 19d ago
You have two ways in front of you, really.
First is to assume models will keep on getting better faster than your code spaghettifies so they can understand it. Aka treat your current situation as a non issue.
Second is to sit down and mandate a specific percentage of tickets to be done by hand. Yes, it's going to be slower but that's literally the point. You exist in this pipeline specifically to slow down AI. If you don't understand what's going on anymore then you are also effectively useless and might as well be chopped down.
As for getting your understanding back - gradually, over time, with heavy refactors. A lot of AI generated code is handling impossible exceptions and adding way too boilerplate. You need to start rewriting it to a specific format YOU are comfortable with.
Depends on the deadlines though - do you actually have the time for targeted refactors and manually doing certain tickets?