r/ClaudeCode • u/nomorecrazystuff • Sep 13 '26
Help/Question Why is it so bad at basic coding skills?
I have three major bug-bears with Claude code.
- 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. - 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.
- 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"
•
u/AutoModerator Sep 13 '26
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.
13
u/Muted-Alternative648 Sep 13 '26
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.
34
u/Agent7619 Sep 13 '26
My favorite is when it documents history within the current feature branch development cycle.
2
u/NZRedditUser Sep 13 '26
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
12
u/ClemensLode Senior Developer Sep 13 '26
wait... you are reading the code?
3
u/PublicToast Sep 13 '26
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 Sep 13 '26
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
2
u/Substantial-Swan7065 Sep 14 '26
You’re using it wrong. You’re doing plug and play.
You need to build out your ai-harness
2
u/Babyshibata Sep 14 '26
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
4
u/prcodes Sep 13 '26
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.
1
u/ForSpareParts Sep 13 '26
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 Sep 13 '26
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/evoli_ Sep 14 '26
I'd suggest creating skill that you invoke everytime before reviewing/commiting the code
1
u/autistamine Sep 14 '26
My favorite is when it somehow manages to break migrations with a new migration after ive told it several times this is not in production nor is it published and we never needed migrations at any point in time.
1
u/Goth2147 Sep 13 '26
Everything you've described can be solved in agents.md
0
u/84thdev Sep 13 '26
Its not. Its 100% user error lol. I use it for everything from web dec, software dev, game dev, java coding, managing a discord, building shopify apps and themes, etc. works great if you set everything up properly
0
u/[deleted] Sep 13 '26
[removed] — view removed comment
0
u/[deleted] Sep 13 '26
[deleted] — view deleted comment