Skip to content

fix: Add Identity section to CLAUDE.md template#952

Open
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/add-identity-to-claude-md-template
Open

fix: Add Identity section to CLAUDE.md template#952
MarvinDontPanic wants to merge 1 commit intodanielmiessler:mainfrom
MarvinDontPanic:fix/add-identity-to-claude-md-template

Conversation

@MarvinDontPanic
Copy link

Problem

CLAUDE.md.template uses {DAIDENTITY.NAME} for the assistant's name in output format lines, but never includes {PRINCIPAL.NAME} (the user's name). The generated CLAUDE.md tells the LLM the assistant's name but not the user's name.

In setups where the assistant's name appears in system paths, project names, or OS usernames, the LLM mistakes the assistant's name for the user's identity — addressing the user by the wrong name.

Data from affected setup (2 weeks of Slack gateway logs):

  • Before v4.0 (had explicit identity injection in LoadContext hook): 0 name misidentifications across 200+ messages
  • After v4.0 (identity injection removed, relies on CLAUDE.md): 30+ misidentifications, getting worse on high-volume days

Fix

Add an Identity section to CLAUDE.md.template between the format definitions and Critical Rules:

### Identity

- **User:** {PRINCIPAL.NAME}
- **Assistant:** {DAIDENTITY.NAME}

Always address the user as "{PRINCIPAL.NAME}". The assistant's name "{DAIDENTITY.NAME}" may appear in system paths, project names, or other infrastructure — do not confuse infrastructure naming with the user's identity.

BuildCLAUDE.ts already resolves {PRINCIPAL.NAME} from settings.json, so this just needs the template reference. Updated the pre-built CLAUDE.md with default values ("User"/"Assistant") to match.

Files Changed

  • Releases/v4.0.3/.claude/CLAUDE.md.template — Added Identity section with template variables
  • Releases/v4.0.3/.claude/CLAUDE.md — Updated pre-built version with default values

🤖 Generated with Claude Code

CLAUDE.md.template uses {DAIDENTITY.NAME} for the assistant's name in
output format lines, but never includes {PRINCIPAL.NAME} (the user's
name). This means the generated CLAUDE.md tells the LLM the assistant's
name but not the user's name.

In setups where the assistant's name appears in system paths, project
names, or OS usernames, the LLM can mistake the assistant's name for
the user's identity — leading to the AI addressing the user by the
wrong name.

Add an Identity section between Subagent Defaults and Critical Rules
that explicitly states both names. BuildCLAUDE.ts already resolves
{PRINCIPAL.NAME} from settings.json, so this just needs the template
reference.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@MarvinDontPanic MarvinDontPanic force-pushed the fix/add-identity-to-claude-md-template branch from 8646e8a to e793e9f Compare March 13, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant