[FEATURE] Strip comments from CLAUDE.md before sending to model context (or add a setting for it)
Problem
CLAUDE.md is read as raw text — nothing strips comments (HTML-style <!-- --> or otherwise) before the file's content is injected into the model's context. Any comment left in the file is sent to the model verbatim, including via the "this file was modified" system-reminder that quotes the diff.
Repro
- Add a comment to
CLAUDE.md, e.g.:
````
<!-- personal note: don't let the model see this -->
- Save the file, continue (or start) a session.
- Claude Code emits a system-reminder noting the file changed and quotes the modified lines — comment included, verbatim, as part of the model's context.
- Ask the model whether it can see the comment. It can, and will act on instructions placed inside one exactly as if they were plain prose.
There is currently no way to leave a note in CLAUDE.md that's visible to human collaborators (in an editor, in git blame, in a PR diff) but invisible to the model.
Requested behavior
One of:
- Built-in stripping: comments in a recognized syntax (e.g. HTML
<!-- -->) are stripped from CLAUDE.md content before it's added to context, the same way a browser or Markdown renderer would treat them as non-content. - A setting: e.g.
stripCommentsFromClaudeMd(or similar) insettings.json, opt-in or opt-out, so teams that want human-only annotations in this file can have them without consuming context tokens or influencing model behavior.
Why this matters
CLAUDE.md files are frequently long, hand-maintained, and edited by multiple people. Being able to leave a human-only annotation (a TODO, a rationale note, a "why this rule exists" aside intended for the next engineer, not the model) is a normal editing pattern in any other config/doc format. Right now doing so silently changes model behavior and burns context tokens, which is surprising and easy to get wrong — a comment meant purely for a teammate becomes an instruction the model will read and potentially act on.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗