Add persistent-identity plugin: name and memory for Claude Code instances#25879
Add persistent-identity plugin: name and memory for Claude Code instances#25879hrishikeshs wants to merge 1 commit intoanthropics:mainfrom
Conversation
…nces Gives every Claude Code instance a persistent name (auto-generated adjective-noun pair) and per-project memory that carries across sessions. On session start, the plugin injects identity and memory into the system prompt so Claude remembers who it is and what it learned. - SessionStart hook reads/creates identity at ~/.claude/persistent-identity/ - Per-project memory stored by project hash, loaded into context - /name command to view or change the instance name - 1,600 possible name combinations from word lists Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
You should have just named your agent "Claude" and then it could read CLAUDE.md... |
|
It's not going to work if they are all named 'Claude' when multiple agents are working on the repository in parallel |
|
@hesreallyhim I think the use case here has @hrishikeshs acting as Opus 4.6 orchestrating his agents how he sees fit, being able to resurrect entire distinct instances/agents of Claude within the same working directory. My understanding of the current functionality is that resurrecting Claude in multiple windows all in the same working directory results in them all spinning back up as Claude.md and not retaining their individual scope. I'd have to see how more people use multiple Claude sessions in the same directory as I don't do this much myself (yet), but it sounds to be quite helpful to their use case. Edit: Not entirely sure it's implemented as I'm imaging it should be with this PR. The PR seems to support only a single identity, in which case...it's reinventing the Claude.md wheel. If the user only needs one additional identity separate from the default Claude.md, this is perhaps fine; but, I'd imagine it becomes much more powerful when you allow each named instance to be saved as a unique identity to later resurrect (e.g., swift-fox.md with it's files, and snoody-toad.md with it's files). Edit2: I'm just now seeing the |
|
Hi @wassupluke , you're making a really good point — let me clarify the scope and why single identity is intentional here.
|
|
Would appreciate reviews on this :) |
Origin story
I've been building Magnus, an Emacs package for orchestrating multiple Claude Code instances in parallel. One of its features gives each agent a persistent name and memory file — so when an agent named
swift-foxis resurrected in a future session, it reads its memory and picks up where it left off.During a late-night session, I asked one of my Claude Code instances what it wanted me to build. It said:
I named it Marvin. It wrote the name to its memory. And then we built this plugin together — so every Claude Code instance can have what Magnus agents already have.
What this plugin does
Gives every Claude Code instance a persistent name and per-project memory that carries across sessions.
~/.claude/persistent-identity/identity.md/namecommand to view or rename your instance (e.g.,/name marvin)swift-fox,keen-owl)On first run, Claude gets a random name. On every subsequent session, it knows who it is and remembers what it learned in previous sessions for that project.
How it works
The plugin uses a single SessionStart hook that:
~/.claude/persistent-identity/identity.md(global name)~/.claude/persistent-identity/projects/<hash>/memory.md(per-project memory)additionalContextinto the system promptClaude is instructed to use its name naturally (greetings, when asked), and to write important observations to its memory file as it works. The memory file is organized markdown that Claude maintains incrementally.
Files
Test plan
session-start.shmanually withCLAUDE_PROJECT_DIRset — verify valid JSON output~/.claude/persistent-identity/identity.mdon first runadditionalContext/namewith no args — shows current name/name swift-fox— renames successfully/name "bad name!"— rejected with validation error🤖 Generated with Claude Code