Answers
Claude Code strips HTML comments from CLAUDE.md, so a rule inside one never loads
Published
Claude Code removes block-level HTML comments (<!-- ... -->) from every CLAUDE.md before the text reaches Claude, so a rule written inside one is never in context. Anthropic documents it as a feature: comments are notes for the people maintaining the file, and they cost no tokens. It turns into a bug when someone comments out a rule to "park" it, or wraps real instructions in a comment block to keep a rendered README tidy.
For Claude Code. Vendor facts are from the pages linked below, read on November 18, 2026.
How to find and fix it
- Search the file for
<!--. Anything between it and-->outside a code block is invisible to Claude. - Move every instruction you want followed out of the comment, as plain text or a list item.
- Keep comments only for notes to people: why a rule exists, who to ask, when to delete it.
- A comment inside a fenced code block is kept, so an example of HTML in a code block still reaches Claude.
- Run
/contextin a session and read the CLAUDE.md entry under Memory files to see what actually loaded.
<!-- Claude never sees this line -->
- Run pnpm test before every commit. <- Claude sees this oneThe numbers
| Measure | Value | Source |
|---|---|---|
| Public CLAUDE.md files that contain HTML comments | 5.5% (weighted, of 1,932 sampled) | Harbor study, 18 Oct 2026 |
| Public CLAUDE.md files on GitHub, forks excluded | 839,680 | Harbor study, 18 Oct 2026 |
| Comments inside code blocks | Kept; only block-level comments are stripped | Claude Code memory docs |
Study figures are weighted estimates from 1,935 CLAUDE.md and 1,970 AGENTS.md files sampled from public GitHub repositories on 18 October 2026, with GitHub's own counts for the totals. Every figure is in the study's CSV, and the method is in the study.
What the docs say
- Claude Code: How Claude remembers your project: Block-level HTML comments in CLAUDE.md files are stripped before the content is injected into Claude’s context. Comments inside code blocks are preserved, and a CLAUDE.md opened with the Read tool still shows them.
Where Harbor fits
Harbor connects Claude Code, Codex, Cursor and GitHub Copilot (the CLI and VS Code agent mode; the cloud agent is not supported yet) through hooks and an MCP server. At setup it offers the repo’s committed CLAUDE.md to Review, and keeps each rule as its own entry with the sentence it came from, so there is no comment block for a rule to hide in. Each rule shows how often it was served and how often an answer cited it. A citation is evidence a rule was used, not proof it was obeyed.
Read next
- Why Claude ignores CLAUDE.md, every cause
- The study of 3,905 CLAUDE.md and AGENTS.md files
- Check your CLAUDE.md for free
- "Read AGENTS.md" in CLAUDE.md does not load it: put @AGENTS.md on its own line
- Antigravity CLI skips AGENTS.md in subfolders and drops rule files without a valid trigger
- Windsurf is now Devin Desktop: .devin/rules wins, and only one global_rules.md loads
- CLAUDE.md and AGENTS.md drift apart in 7% of repos that copy one into the other: import instead
- Every answer, by agent and problem
Questions
Does Claude Code read HTML comments in CLAUDE.md?
No. Block-level HTML comments are stripped before the content is injected into Claude’s context. Comments inside fenced code blocks are kept, and if Claude opens the file with the Read tool it sees the comments as plain text.
Can I use HTML comments to disable a rule in CLAUDE.md temporarily?
Yes, that works, and it is the safe use: the rule stops loading. Just know that a comment is not a draft Claude sees, and delete the parked rule if it is still there next month.
How common are HTML comments in CLAUDE.md files?
In our 18 October 2026 sample of public GitHub repositories, 5.5 percent of CLAUDE.md files (weighted) contained HTML comments. The study did not check whether each comment held a rule or a note.
Do other agents strip HTML comments from AGENTS.md?
Anthropic documents the stripping for Claude Code’s CLAUDE.md files. We have not found the same statement in the Codex, Cursor or Copilot docs, so test it in each agent before you rely on a comment being hidden or seen.