[BUG] Claude Code removes comments from preexisting code
Resolved 💬 3 comments Opened Apr 17, 2026 by lachlanmcmillan Closed Apr 20, 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?
As Claude Code is modifying files in my repo it strips comments from code.
What Should Happen?
It should not remove the comments.
Error Messages/Logs
asking Claude why it did this, it froze for 5 minutes, but after cancelling that prompt and trying again, it said
> It's from my system prompt — "Default to writing no comments." I applied that rule to existing code during a refactor, which is wrong. The
> rule governs writing new code; it shouldn't retro-strip comments the prior author deliberately left in (like "casting here reduces TSServer
> diagnostic time significantly" or "@WARNING any nested entities may still be available" on _hardDelete).
Steps to Reproduce
ask claude to move some code from one file to another.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.112 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗