Trailing Whitespace Consistently Added by Claude During Code Generation
Status Fixed / completed
Maintainer reply None cached
Activity 12 comments · opened Mar 6, 2025 · closed May 8, 2025
Bug Description
Claude introduces trailing whitespace frequently in my code files. Such as on new lines before functions I let it add.
Additionally, I asked it to stop doing this going forward, and it said it would, but it still continued to do so.
Environment Info
- Platform: macos
- Terminal: iTerm.app
- Version: 0.2.32
- Feedback ID: 4a9bd58c-6499-4d8f-9884-1061055acbc9
12 Comments
I have this issue in nearly every file Claude Code edits. I've given up on convincing it to stop doing this. Instead I have installed every styler and linter I could possibly need and I use them to clean up afterword in git pre-commit hooks. For a good project I should have those anyways, but it would be nice if this was solved.
For reference, Linux here.
Same here on Windows/WSL working on NextJS development. Adds lots of blank lines. Maybe 10% of the time.
I also see the "String to replace not found in file" pretty often. Might be related.
another example:
Will follow up to add more info.
Update: this step did it.
Looks like it thinks it added one line but actually added many blank lines.
!Image
I have tried multiple variations of prompts forcing him not to generate empty lines with whitespaces, but it keeps happening. However, it calls linter afterwards correctly and ends up fixing these issues, which just wastes tokens on each iteration.
Yes, thank you same issue here working on Kotlin files. Might be related to line ending conversions from WSL to windows, event edited the line endings generated by Android Studio, no luck. Claude desktop app with MCP server is what im still using until this gets fixed. I would love a native powershell Claude tool.
I've said pretty clearly in my
CLAUDE.mdto not do this:...but it doesn't help. I asked Claude itself, and its answer was unsatisfying.
"more emphasis" indeed. 🤷
I noticed this issue was closed but doesn't appear to be resolved. Can you supply the reason it's closed?
Same here - it's extremely annoying. Happening in both Julia source files and TypeScript.
I'm also experiencing this issue. Please can we configure Claude to remove trailing whitespace and empty whitespace newlines from outputs? Both in CLI claude-code and in the web interface?
It's also neglecting to add trailing newlines, no matter how much it's instructed to add them. When you tell it to add it explicitly, it errors because its find/replace doesn't find them and then it ends up doing a different technique. It's pretty awful.
Experiencing this as well. It's really annoying—please fix!
@bcherny I see you closed this issue - Is the work completed/fixed in the latest npm package or is the bug mentioned by @aaronjensen the right place to track this now?
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.