AI News Daily한국어
← AI tool tips
Claude CodeGoing around, but actuallyAdded Oct 23

Checking CLAUDE.md and context usage in long Claude Code sessions (a name canary doesn't detect hallucinations)

A post on X is making the rounds again: add one line to CLAUDE.md telling Claude to start every reply with your name, and treat the moment your name disappears as the sign Claude has started hallucinating. It's called a canary, and the same trick circulated in August.

A missing name only means Claude didn't follow one instruction. Here is what the official docs say.

  • CLAUDE.md is context, not enforced configuration. It's delivered as a user message after the system prompt, with no guarantee of strict compliance, so the name can drop out even in a short session.
  • After /compact, the project-root CLAUDE.md is re-read from disk and re-injected. The file stays loaded however long the session runs.
  • Claude can still invent facts while dutifully writing your name. Check answers against tests and sources.

The docs do say that as context fills, Claude may start forgetting earlier instructions or making more mistakes. So look at the loaded files and the usage directly.

  1. Run /context to check that your instruction files loaded. If CLAUDE.md or CLAUDE.local.md is missing from the Memory files list, Claude can't see it.
/context
  1. Show context usage in your status line. Put this in ~/.claude/settings.json (requires jq).
// ~/.claude/settings.json
{
  "statusLine": {
    "type": "command",
    "command": "jq -r '\"[\\(.model.display_name)] \\(.context_window.used_percentage // 0)% context\"'"
  }
}
  1. Run /clear when you switch to unrelated work. If you've corrected Claude more than twice on the same issue, the docs recommend running /clear and starting fresh with a more specific prompt that includes what you learned.

For rules that must always hold, like running tests before every commit, use a hook. Hooks run at fixed points regardless of what Claude decides.

Get notified when a new tip lands

Tip alerts only go out in the app. Install it and turn notifications on.

Get the app

All tips →