[BUG] Generated code ignores repeated zero-comment instructions

Resolved 💬 2 comments Opened May 21, 2026 by plantoeat Closed May 25, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗