feat: .shared-memory-project file convention for repo-rooted project ID

Replaces "per-machine X-Project-Key header" as the default way to tell
Claude Code which shared-memory project a repo belongs to. Commit a
single-line `.shared-memory-project` text file at the repo root; every
collaborator's Claude Code reads it at session start and attaches all
memories + snippets to the same shared project. No per-machine config
required.

Changes:
- New file convention documented in README (resolution order, format,
  authoring snippet, rationale for plain-text over JSON).
- project.identify tool description now leads with "check
  .shared-memory-project at the repo root", with inference as fallback.
- memory.write description mentions the file as the canonical source for
  project keys.
- Project detail page in the Web UI shows a copy-paste `echo > file`
  command so users see exactly what to add to their repo.
- Added .shared-memory-project to this repo (content: `shared-memory`).

Resolution precedence is: explicit tool arg → .shared-memory-project →
X-Project-Key header → inference. The file beats the header because
repo context is more specific than machine context.

This is a soft convention — Claude has to read the file. Directive tool
descriptions make this very likely; a Claude Code skill would make it
bulletproof, deferred until we see whether the description alone is
enough.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-18 09:17:04 -07:00
co-authored by Claude Opus 4.7
parent 837c43f3d5
commit b6e28b329d
4 changed files with 65 additions and 3 deletions
@@ -201,6 +201,26 @@ export default async function ProjectDetailPage({
}
/>
<Card className="mb-6">
<CardHeader className="flex items-center justify-between">
<span className="text-sm font-medium">Auto-identify this project</span>
<span className="text-xs text-fg-subtle">.shared-memory-project</span>
</CardHeader>
<CardBody className="space-y-2 text-sm">
<p className="text-fg-muted">
Commit a one-line text file at the repo root so every Claude Code
session opened in this repo automatically targets this project
no per-machine config needed.
</p>
<pre className="!whitespace-pre-wrap text-xs">{`echo "${project.key}" > .shared-memory-project`}</pre>
<p className="text-xs text-fg-subtle">
Commit it. The directive tool descriptions tell Claude to read this
file at session start before falling back to inference or the
<code className="mx-1">X-Project-Key</code>header.
</p>
</CardBody>
</Card>
{shareRows.length > 0 || isOwner ? (
<Card className="mb-6">
<CardHeader className="flex items-center justify-between">