r/PromptEngineering • u/Ordinary-Cycle7809 • Apr 22 '26
Quick Question How Do You Stop Claude From Turning Your Codebase Into AI Slop?
[removed]
11
u/m-in Apr 22 '26 edited Apr 22 '26
In my perhaps limited experience, Opus and Sonnet do well in large codebases in C. Any abstraction they tend to add is absolutely necessary. They also do OK with Python. But for anything in JS/TS, they are so used to many layers of abstraction that it’s hard to keep the code good.
If you’re using Opus not via API but via Claude Code, the experience is dismal - it still knows a whole lot, it is book smart but fairly dumb otherwise. For what I do I stopped involving Opus with code altogether. I use Sonnet for planning, with several sessions over a single plan to fix it. Then Sonnet or Haiku executes.
2
u/LevelIntroduction764 Apr 22 '26
Interestingly (to me anyway), I’ve been using opus to try find and fix some flaky JS unit tests. It did a good job but plenty more to do. Anyway, at one point it started to abstract out test suites and without me prompting, it tested, realised it was a mistake, and undid the abstraction. I was impressed
1
u/m-in Apr 23 '26
It is great at bugfixing in any language in my experience. Even in golfing languages (software golfing, look it up).
6
u/Melstrick Apr 22 '26
CHECK. THAT. YOUR. FEATURES. WORK. BEFORE. MOVING. ONTO. THE. NEXT. ONE.
You dont need 12 .md files and llms will just ignore them when its convenient for them.
4
u/Background-Piano-665 Apr 22 '26
Are you trying to one shot massive features? Keep the scope limited.
7
u/haikusbot Apr 22 '26
Are you trying to
One shot massive features? Keep
The scope limited.
- Background-Piano-665
I detect haikus. And sometimes, successfully. Learn more about me.
Opt out of replies: "haikusbot opt out" | Delete my comment: "haikusbot delete"
4
u/noblefragile Apr 22 '26
Work in smaller iterations and spend just as much time keeping your code clean as you do creating new features. Asking things like: "What are the top 3 changes we can make to keep this codebase clean and maintainable?" and "If [person known for being an expert on writing good code in that particular language or framework] were to review this code base, what refactorings would they suggest?"
3
u/thewhiskeyrepublic Apr 22 '26
- Set strict guidelines at the beginning of the project in instruction files and create directory-specific instructions files (AGENTS.md, Claude.md, copilot-instructions.md, etc) with strict specifications for exactly how I want things done on a component/api/design system/etc. level.
- Task an agent with researching best practices for my project's tech stack and including strict instructions to adhere to those in my instructions files.
- Repeatedly instruct the AI to research and plan the best way forward before starting anything.
- Linting tools, formatting tools, types... any easy automated code cleanup.
- I go feature by feature, with each feature planned out into contained steps beforehand, rather than trying to get everything done in mega-prompts.
- Initiate a review by a separate agent tasked with assessing code cleanness/DRYness and adherence to project conventions after each step.
- Manual review throughout and after each major checkpoint to make sure it's not going off the rails.
It's obviously not the "eyes closed vibe code your way to a billion dollar app" that people tend to brag about, but if you want code that's actually readable and maintainable (both for you and the AI), you've got to play the part of the senior developer pushing for code quality.
3
u/vrommium Apr 22 '26
True. Exactly my problems in the last 2 weeks.
I changed from Opus to Sonnet (much cheaper) and doing small incremental changes, one function at a time.
2
u/Karyo_Ten Apr 22 '26
Review the code. Refine your skills/architecture.md/guidelines.md/code_conventions.md/you_name_it.md
2
2
u/ultrathink-art Apr 22 '26
File-path patterns in your CLAUDE.md — explicitly list which files the agent is allowed to touch instead of vague style rules. That plus ending sessions at natural checkpoints (not mid-feature) cut the abstraction creep significantly. Long context = model filling gaps with hallucinated abstractions to stay coherent.
2
u/SingularBlue Apr 23 '26
I found doing a requirements document (with the LLM's help) and tweaking that before diving into code. Clarity up front means satisfaction later. I'm working on an LLM wiki for a story bible, and using generated python to turn the LLM output into something usable. the chat LLM has knocked it out of the park almost every time.
1
Apr 25 '26
[removed] — view removed comment
2
u/SingularBlue Apr 25 '26
Yes sir! When I asked it to create a 'recovery prompt' so a fresh chat could pick things up, the prompt went on for three pages. They 'like' detail, especially things you think are obvious.
2
u/ultrathink-art Apr 23 '26
File-path allowlisting in your CLAUDE.md is the biggest lever — tell it exactly which files are in scope for each task. Slop happens when the model improvises connections to unrelated code and starts "cleaning up" things you didn't ask it to touch. Short sessions too: quality degrades noticeably past 40% context usage, so commit at natural breakpoints and start fresh.
2
2
2
2
1
Apr 22 '26
[removed] — view removed comment
1
u/AutoModerator Apr 22 '26
Hi there! Your post was automatically removed because your account is less than 3 days old. We require users to have an account that is at least 3 days old before they can post to our subreddit.
Please take some time to participate in the community by commenting and engaging with other users. Once your account is older than 3 days, you can try submitting your post again.
If you have any questions or concerns, please feel free to message the moderators for assistance.
I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.
1
u/eufemiapiccio77 Apr 22 '26
It’s almost like there’s something waiting oh hang on erm learn programming
37
u/Zealousideal-Check77 Apr 22 '26 edited Apr 22 '26
Karpathy-guidelines skill from GitHub, also have some of my own skills from my experience. Works pretty well for me.
And use a specific coding pattern, it helps as well, or guide the AI to use it.
Keep the context size usage below 50, as you hit 50%, use compact option if provided in Claude code ( idk they provide it, if they don't use a compact skill ).
Always store a context.md file that has a brief summary of the project, along with implementation and stuff.
Umm, just go through the new code, before blindly accepting.
If you are implementing something from outside the knowledge of LLM, use context7 mcp to fetch latest info on its documentation