claude-code - 💡(How to fix) Fix [BUG] Generated code ignores repeated zero-comment instructions

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

Error Messages/Logs

Fix Action

Fix / Workaround

  1. In a repo, create a CLAUDE.md with an explicit zero-comment rule, e.g.: "Default to writing zero comments. Only add a comment when the WHY is non-obvious (a hidden constraint or workaround). Never write comments that explain WHAT the code does."
  2. Start a fresh Claude Code session in that repo.
  3. Ask for a non-trivial piece of code with a few steps, e.g. "Add a function that parses a duration string like 1h30m into seconds" or "convert this static import to a dynamic import".
  4. Observe: the generated code includes leading "what" narration comments (// Parse the hours, // Load the X, // Convert to seconds).
  5. Reply: "fewer comments — follow CLAUDE.md". Claude removes them and acknowledges the rule.
  6. In the same session, ask for another code change. The what-comments reappear.
  7. (Optional) Add a persistent memory entry stating the same rule. Start a new session. Repeat step 3 — comments still appear despite both CLAUDE.md and memory.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Summary: Across many sessions over several months, Claude adds explanatory "what" comments to generated code even when both the project CLAUDE.md and persistent memory explicitly instruct zero comments / why-only comments. It often self-corrects when reminded mid-session, then regresses on the next code-writing turn. I see happening more when claude is fixing review comments in PRs.

Instructions given (ignored):

  • CLAUDE.md: "Default to writing zero comments... if the code needs a comment to explain what it does, the names are wrong."
  • Memory entries feedback_zero_comments, feedback_methods_over_comments.

Observed: New code arrives with leading "// Load the X" / "// Do Y" narration lines. A reminder fixes it for that turn; the next code-generation turn regresses.

What Should Happen?

Expected: Zero/why-only comment policy from project config + memory should hold without per-turn reminders.

Impact: Reviewer noise; repeated manual cleanup; the instruction system appears non-load-bearing for this behavior.

Error Messages/Logs

Steps to Reproduce

  1. In a repo, create a CLAUDE.md with an explicit zero-comment rule, e.g.: "Default to writing zero comments. Only add a comment when the WHY is non-obvious (a hidden constraint or workaround). Never write comments that explain WHAT the code does."
  2. Start a fresh Claude Code session in that repo.
  3. Ask for a non-trivial piece of code with a few steps, e.g. "Add a function that parses a duration string like 1h30m into seconds" or "convert this static import to a dynamic import".
  4. Observe: the generated code includes leading "what" narration comments (// Parse the hours, // Load the X, // Convert to seconds).
  5. Reply: "fewer comments — follow CLAUDE.md". Claude removes them and acknowledges the rule.
  6. In the same session, ask for another code change. The what-comments reappear.
  7. (Optional) Add a persistent memory entry stating the same rule. Start a new session. Repeat step 3 — comments still appear despite both CLAUDE.md and memory.

Frequency: Not every generation, but reliably within 1-3 code-writing turns. A correction holds for roughly one turn, then regresses.

Minimal real example: with the rule in CLAUDE.md and two memory entries, generated code was: // Load Lottie vegetables animation (cache JSON across imports). // lottie-web is imported dynamically so its weight stays out of the // main bundle — it loads only while a recipe import is in progress. import(/* webpackChunkName: "lottie" / 'lottie-web/...') After a one-line reminder it became: // Dynamic import keeps lottie-web out of the main bundle. import(/ webpackChunkName: "lottie" */ 'lottie-web/...')

Claude Model

Opus

Is this a regression?

No, this never worked

Last Working Version

No response

Claude Code Version

1.8555.0

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

No response

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix [BUG] Generated code ignores repeated zero-comment instructions