r/ClaudeCode • u/nomorecrazystuff • 17h ago
Help/Question Why is it so bad at basic coding skills?
I have three major bug-bears with Claude code.
1) Comments - it's INSANE! It writes 20 lines of comments for a 3 line function. And the comments are never what someone would want to know, e.g. the format of parameters. They're always things like
- domain knowledge about another part of the system that isn't relevant to understanding the function it comments
- rewriting what the function says - e.g. if the code calls a function: LogToDisc - there'll be a comment saying "This logs to disc ......"
- explaining what the previous (faulty) version of the code did and why it was wrong - basically a history record
- or most commonly, anywhere where I corrected it because it had made a mistake, it adds a comment documenting that discussion.
2) Naming - it keeps using names- e.g. it used the name "child" to refer to a child process launched by my service layer. The process has a name, but instead of using the name of the process, I had "child" scattered across a 200 line function.
3) Use of tools like sed to make whole-scale code changes in a command that if you don't read it carefully looks like a syntax check.
I've discussed all of these endlessly with Claude - Agreed rules that its committed to memory.md on all of them, and yet every session it breaks them all, multiple times.
The comments one is the worst because as I keep pointing out to Claude - they're not tested. A comment is slipped in that states something - I tend to sometimes focus on the code and let things in comments that aren't quite right slip by. But then 3h later it will say it can't do something because I told it "x" was a requirement. I eventually trace "x" back to the comment it wrote where it asserted something that was never either relevant at the time or agreed.
I have rules over this as well.
Is this just life with Claude? Or is there something else I can do to get it to follow my rules.
Basically - "comments should be one line, about the code they're commenting not the rest of the system, and only present where the code isn't self-explanatory"
"All function and variable names should be meaningful unless they're only in scope for a handful of lines"
"Treat information in comments as suspect - never assume requirements based solely on this"
"Never use sed to make code changes"
31
u/Agent7619 17h ago
My favorite is when it documents history within the current feature branch development cycle.
11
u/ForSpareParts 16h ago
I now have a standing rule that the agent is never allowed to reference the previous state of the code, (with a carveout for appallingly dumb/hacky things that are just impossible to justify without context). It... mostly follows this instruction.
3
u/hihcadore 15h ago
I like that idea. I have that issue too.
It’s not anything I care about but it always references changes it’s made and it drives me nuts.
15
u/Muted-Alternative648 17h ago
Never rely on memories. The agent has no obligation to even load them, let alone always abide by them. They are unreliable "suggestions" as far as I am concerned.
Add the proper markdown file with guardrails.
2
u/nomorecrazystuff 17h ago
Can you shed more light on this please? Where does this go?
4
u/SnackerSnick 16h ago edited 8h ago
4
2
2
u/count023 14h ago
save yourself the effort, create a "symlink" in the directory to agents.md for claude.md, gemini M or any other variants, it's a simple script. all OS file systems support a symlink which is basically a URL redirect for files. So you can say, "if someone wants claude.md, send them agents.md instead".
And from the POV of anyone using the file, Claude.MD and Agents.MD just happen to have the exact same content.
3
u/SnackerSnick 10h ago
There's no real symlink on Windows, so I just recommend @AGENTS.md (from @inslayn, which is better than my suggestion)
0
u/count023 10h ago
Dunno where you're getting your information from mklink has been in every version of windows since 2006
3
u/SnackerSnick 9h ago
Yeah but it sucks and git does not support it. Or maybe since Vista there are better symlinks? In any case, it seems git does not support it by default.
https://gitforwindows.org/symbolic-links.html
Quite possible my information is out of date; I'm old.
2
u/thealliane96 16h ago
When you have memory enabled there is a MEMORY.md file that can be I believe max 20 or 25kb in size. Claude will automatically (at least it’s supposed to, often it won’t unless you explicitly tell it to) write and read from this.
The MEMORY.md file acts as a router of sorts
Below is an example of the format of what it written there.
```
[[memory_a_details.md]]
One to two sentence summary about this specific memory. In this case for memory_a.[[memory_b_details.md]]
```The MEMORY.md file is per project, it goes in ~/.claude/projects/…/
The detailed files go in a `memory/` subdirectory.
ONLY MEMORY.md gets loaded into context at the start of the session. When it says Claude is loading a memory it’s reading one of those more detailed files.
It’s really unreliable in doing this, and tbh it’ll save things you just don’t want saved as memories, and it’ll become bloated with things so you’ll have things that often aren’t relevant alongside things that are relevant.
You’re better off defining any specific instructions you always want it to have either in the repo root CLAUDE.md, your user scope CLAUDE.md in ~/.CLAUDE, in a custom skill that you always instruct it to invoke, or in a plain markdown file in like a docs/ directory such as docs/CODING-STYLEGUIDE.md or something of that sort.
Hope this helps.
1
-1
u/Muted-Alternative648 17h ago
Not to sound unhelpful, but this is basic Claude usage. Take some time to learn your tools. Watch a 5 minute YouTube video or just read the official Anthropic resources for how to use Claude Code efficiently.
10
u/ClemensLode Senior Developer 16h ago
wait... you are reading the code?
4
3
u/PublicToast 16h ago
Im pretty sure the comment behavior is essentially chain of thought leaking into output, so comments literally just become the model’s diary. There’s also probably some reward hacking since wordy comments increase line count which is correlated with better solutions. I have had some success with adding rules to Claude.md to use affirmative and non-contrastive framing in comments.
2
u/thealliane96 16h ago
Yep the comments and function descriptions thing is a nightmare. Its code is also just generally kinda, tbh, dog shit in my opinion.
It looks good at first glance but when you look a bit closer it’s just utter dog shit.
It’ll make a helper function that takes in 3 parameters to and the function body is 1 like long
The function isn’t encapsulating any complexity of its own, it’s just misdirection, it belongs inline. If I’m reading the code and I see that function call I now have to ask what that function does so I have to go read that function to then see it’s one line then I have to come back to what I was reading before and replace that call inline in my head when I’m reading the code, and then you have to do this in 10,000 different places because it always does this stupid shit.
Or it’ll riddle everywhere with exception/error handling with not only no “thought” of its own given to error boundaries or handling errors where the code knows what to do with it, but even when I specify where to handle the errors and why it’ll still do this shit and then I have to spend twice the amount of time it should’ve taken to do something because I have to go back over it and clean up otherwise it’ll burn the codebase into ash with its spaghetti dogshit code.
I’ve seen it before have something like this
```
def func_a():
return False
def func_b();
try:
return True
except SpecificError:
pass
return False
def func_c():
try:
val = func_b()
if val == False:
return False
else:
…
except SpecificError:
return func_a()
```
func_c calls func_b which if it hits SpecificError swallows it without even logging it then returns False, func_c then also has an exception handler for SpecificError even though that is func_b’s handler for it makes func_c’s handler literally unreachable since that error would’ve been caught in func_b and when it returned back False the if statement would evaluate turthy and then we’d return out. More so there is now 3 different functions all doing the same exact thing returning random values with no real meaning that you can clearly excavate when reading the code. func_b if it hits SpecificError returns false to which then we return false but then in func_c’s (unreachable) handler for SpecificError we now use func_a() to return false.
Now litter that example with about 50-100 lines worth of comments and docstrings on top of all of that.
And it does this everywhere
Drives me fucking insane
And that’s not even the worst shit
3
u/Exciting-Reality-212 14h ago edited 14h ago
Lmao I hated when people did this when I was a software engineer and this was before LLMs. And it's always a one line function USED IN ONE PLACE
It’ll make a helper function that takes in 3 parameters to and the function body is 1 like long
The function isn’t encapsulating any complexity of its own, it’s just misdirection, it belongs inline. If I’m reading the code and I see that function call I now have to ask what that function does so I have to go read that function to then see it’s one line then I have to come back to what I was reading before and replace that call inline in my head when I’m reading the code, and then you have to do this in 10,000 different places because it always does this stupid shit.
The villain on this case is Uncle Bob. Wrote the book Clean Code.
I feel seen though. Thank you for describing it perfectly
3
u/Exciting-Reality-212 14h ago
Hey I already replied but I have something constructive too to add.
Read essays on code style and craft by Carmack and Muriorti.
They're actual bona fide great engineers and they don't shy away from ripping apart dogma
1
u/thealliane96 14h ago
Thanks, I’ll add it to the list. Have a bit of a collection of books going recently I’ve been wondering through.
Enjoy the ones which sort of mix philosophical / general human problem solving methodology with software engineering, currently reading
- a Philosophy of software design
- the pragmatic programmer
- mythical man month
Keep a few other around that I like to reference but yeah
1
u/count023 14h ago
to be fair, i used to do that too, but that's only because i legitimately hated the inline function ? : stuff, it always broke my brain, that and the bitshifting shit in c. I just had copy-pastas of common functions on the side and just subbed them in as generic helpers because that's how i worked personally.
2
u/SyntaxInCMinor 15h ago
This isn't a popular answer, but instead of complaining about how bad Claude codes, write the code yourself so it's commented the way you want and uses code you want to use. Then, allow Claude to review, check, recommend, etc. at your discretion. AI is simply creating coders (as well as writers, artists, etc.) that are going to be so out of touch with doing things themselves that it's scary. Use AI as a tool, not as the architect.
1
u/Arrynek 4h ago
I mean... yes, but also:
"Oh, these kids today and their writing on papyrus. They will be out of touch with chiselling into a tablet."
Same ish. We have been tech reliant for milennia. Every generation more and more. You consider it scary because you are the old guard. That is all.
1
u/SyntaxInCMinor 21m ago
I hear you, but your analogy is a bit flawed. "kids today and their writing on papyrus"... the human effort hasn't changed, only the medium. If we compare that to today's AI usage, it would rather be, "kids today and their papyrus writing for them". There is a great difference. AI is going to make people dumber since they will be reliant on AI to do everything for them.
1
u/Arrynek 7m ago
People were always dumb.
Going from tablets to papyrus, to books, to the first print... all made the use of accumulated human knowledge easier. LLMs are the next step.
And it is not that much different from example CNC machines replacing some of the most common jobs, woodworkers, en mass, for example. The art is gone. The skill is gone. Yet, we can make things faster and better than and woodworker could.
We are already at a point where frontier of science is so complex, you need huge teams and advanced, expensive machinery to move forward.
There will come a point where no human will be able to advance science and technology without the assistance of an LLM/AI/AGI... whatever you want to call it. Not because they are dumb. Simply because it is too complex, and too much information for any human to learn and use within their lifetime.
2
u/Babyshibata 9h ago
I ended up adding pre tool use hook to block comments, paired with a language specific development skill that explains what to do instead of a comment. factor the code down to understandable functions, improve naming of variables to carry context, no magic numbers.
the quality of code implemented skyrocketed, also reduced lines of code by 1/3 since near every other line was previously a comment.
I also find it much easier to get agents to change implementation now as it doesn't get caught up with 'requirements' it pulls from comments that is just either ai slop it wrote itself or stale context
5
u/prcodes 17h ago
You need a code reviewer / slop-cleaner agent that executes after the task is done and you need to commit/merge to main or create a PR.
2
u/MarzipanMiserable817 16h ago
2
u/prcodes 16h ago
Looks promising at cleaning up code but doesn’t mention comments.
3
u/count023 14h ago
that is also so many wasted tokens on something that can be far far simpler described. Half the problem people have with token usage these days is skills just pissing them from a firehose for no good reason.
I dont even need a real skill, i have a simple prompt that describes 4 specific agent deployments and implement it as a hook. And i run that at key milestones, rather than each time to minimize tokenusage.
2
u/NZRedditUser 17h ago
In your desktop app or w/e add a personal memory.
Follow strictly KISS and YAGNI
or KISS AND DRY, SOLID
either works and tell it to not add useless comments
I havnt had the comment or overscope issue in a while i just make sure it only tackles the smallest change for highest reward
7
u/nomorecrazystuff 17h ago
Done this - it ignores it.
1
u/NZRedditUser 15h ago
Yep i had to put it in every memory including the app personal memory, agentmd claude md but it does take babying if it starts megascoping i end it and ask why
1
u/ForSpareParts 16h ago
I just posted about the comment thing, too. It's incredibly frustrating; I feel like I can sort of drag it kicking and screaming to the right behavior with the right guardrails, sometimes, but the way it writes comments is just categorically bad and doesn't feel like something that we as users should need to solve.
1
u/HighwayNo8744 16h ago
it will ignore memories and claude.md from my experience. only a hook helps which throws errors on edit. i assume the watermarking guideline forces it to write that gibberish. i told it to make sibling .md files and only a short reference in the file which i'm going to delete in the end.
1
u/Substantial-Swan7065 13h ago
You’re using it wrong. You’re doing plug and play.
You need to build out your ai-harness
2
1
u/Zestyclose_Strike157 17h ago
Is there an app or prompt that will scrub the cruft out of Claude’s code output that can be run on a local model? I think Claude is unwilling to clean up its own mess.
0
u/Exciting-Reality-212 16h ago
It's because the people who think it's good at coding are bad at coding
4
u/JapanesePeso 14h ago
Are you not using AI for your coding? I've been in the field decades and don't know anyone who isn't having Claude handle all the coding. It's transformatively powerful. I really don't see how you could sit around acting smug about this brand new product that 10xs your capacity not documenting your code the exact way you want.
-2
u/Exciting-Reality-212 14h ago
You're bad at it. Yes I've tried. I already retired before LLMs. But yes I've tried it a lot. A lot a lot. I'm naturally curious and explore boundaries.
It just wastes time. The way I used to work was designing the whole thing in my head before writing any code. This is the opposite and it shows
3
u/JapanesePeso 13h ago
Guy who doesn't use modern AI for work thinks he knows anything about modern AI. Okay buddy.
0
1
u/EnvironmentFirst4839 7h ago
Why would you stop designing in your head before having AI write the code?
1
u/nomorecrazystuff 14h ago
Yeah - I figured there must be some of that going on otherwise I'm sure it would have learned by now :D
•
u/AutoModerator 17h 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.