Background
I use Claude Code heavily with multiple git projects in parallel. I installed the memsearch plugin so every project's Stop hook auto-captures sessions into .memsearch/memory/YYYY-MM-DD.md.
Problem: every project produces a file with the same name YYYY-MM-DD.md. When I open ~/.memsearch/memory/ a week later I can't tell which file belongs to which project unless I remember when I started each session.
It gets worse when I sync or back up across projects — for example, dumping .memsearch/memory/ into a single shared location: same-name files silently overwrite each other.
Reproduction
# Project A
cd <user>/projects/alpha
claude # ask something → Stop hook writes .memsearch/memory/2026-08-06.md
# Project B
cd <user>/projects/beta
claude # ask something → Stop hook writes .memsearch/memory/2026-08-06.md
# ↑ Same filename, different projects.
Expected Behavior
The filename should be customizable, with at least the project / collection identifier included. Examples:
| Template |
Output |
{date} (current) |
2026-08-06.md |
{project}-{date} |
alpha-2026-08-06.md |
{date}-{project} |
2026-08-06-beta.md |
{project}/{date} (subdir) |
alpha/2026-08-06.md |
{date}-{session_short} |
2026-08-06-abc12345.md (first 8 chars of session UUID) |
Template variables should at least include:
{date} — YYYY-MM-DD
{project} — collection name (already exists via scripts/derive-collection.sh)
{session} — short session ID (first 8 chars of session UUID)
{time} — HH-MM
Proposed Config
# ~/.memsearch/config.toml
[memory]
# existing path stays the same
dir = "~/.memsearch/memory"
# new: filename template
filename_template = "{project}-{date}"
# optional: subdirectory under `dir` (e.g. per-project)
subdir_template = "{project}" # or "" for flat layout
Implementation Reference
Current (plugins/claude-code/hooks/stop.sh:72-74):
TODAY=$(date +%Y-%m-%d)
MEMORY_FILE="$MEMORY_DIR/$TODAY.md"
Suggested patch:
DATE=$(date +%Y-%m-%d)
PROJECT=$(derive_collection_name "$_PROJECT_DIR") # already exists
SESSION=$(basename "$TRANSCRIPT_PATH" .jsonl | head -c 8)
TIME=$(date +%H-%M)
TPL=$($MEMSEARCH_CMD config get memory.filename_template 2>/dev/null)
[ -z "$TPL" ] && TPL="{date}"
FILENAME=$(echo "$TPL" | sed \
-e "s/{date}/$DATE/g" \
-e "s/{project}/$PROJECT/g" \
-e "s/{session}/$SESSION/g" \
-e "s/{time}/$TIME/g")
SUBDIR_TPL=$($MEMSEARCH_CMD config get memory.subdir_template 2>/dev/null)
SUBDIR=$(echo "$SUBDIR_TPL" | sed -e "s/{project}/$PROJECT/g")
MEMORY_FILE="$MEMORY_DIR/${SUBDIR:+$SUBDIR/}$FILENAME"
mkdir -p "$(dirname "$MEMORY_FILE")"
Compatibility
- Default unchanged: when
filename_template is unset the file is still YYYY-MM-DD.md, no behavior change for existing users.
- Index compatibility: collection name logic is unchanged (still
derive-collection.sh); files inside one collection are still indexed together.
- Cross-collection: multiple projects sharing one
MEMORY_DIR no longer collide.
Use Cases
Single-project user (default)
No config change → behavior unchanged.
Multi-project user
Set filename_template = "{project}-{date}" →
alpha-2026-08-06.md
beta-2026-08-06.md
Identifiable at a glance.
Backup / migration
Set subdir_template = "{project}" + filename_template = "{date}" →
~/.memsearch/memory/
├── alpha/2026-08-06.md
├── beta/2026-08-06.md
└── gamma/2026-08-06.md
Per-project directory tree, copy safe.
Alternatives Considered
| Option |
Why it falls short |
Force a different MEMSEARCH_DIR per project |
User has to set per-project env var; backup paths must be tracked separately |
Write a sentinel file in SessionStart |
One more file per session, doesn't fix the name collision |
| Just fork the plugin |
Loses upstream upgrades |
Additional Benefits
- Visibility:
git log --follow immediately shows which project a memory file belongs to
- Observability:
ls shows at a glance "alpha had 3 sessions today, beta had 5"
- Portability: exporting
~/.memsearch/memory/ to a tarball preserves structure
Testing
# 1. No template set → default YYYY-MM-DD.md
cd <user>/projects/alpha && claude # ask
ls .memsearch/memory/ # should be 2026-08-06.md
# 2. With template → alpha-2026-08-06.md
memsearch config set memory.filename_template "{project}-{date}"
cd <user>/projects/alpha && claude # ask
ls .memsearch/memory/ # should be alpha-2026-08-06.md
# 3. Cross-project, no collision
cd <user>/projects/beta && claude
ls .memsearch/memory/ # should be alpha-2026-08-06.md AND beta-2026-08-06.md
Impact / Scope
Small. Changes:
stop.sh — expand filename resolution to use template
~/.memsearch/config.toml schema — add memory.filename_template and memory.subdir_template
Reuses existing derive-collection.sh, no new dependencies.
Priority
Medium. Workarounds exist (MEMSEARCH_DIR per project) but they don't survive backup / sync / multi-user scenarios cleanly.
Background
I use Claude Code heavily with multiple git projects in parallel. I installed the memsearch plugin so every project's
Stop hookauto-captures sessions into.memsearch/memory/YYYY-MM-DD.md.Problem: every project produces a file with the same name
YYYY-MM-DD.md. When I open~/.memsearch/memory/a week later I can't tell which file belongs to which project unless I remember when I started each session.It gets worse when I sync or back up across projects — for example, dumping
.memsearch/memory/into a single shared location: same-name files silently overwrite each other.Reproduction
Expected Behavior
The filename should be customizable, with at least the project / collection identifier included. Examples:
{date}(current)2026-08-06.md{project}-{date}alpha-2026-08-06.md{date}-{project}2026-08-06-beta.md{project}/{date}(subdir)alpha/2026-08-06.md{date}-{session_short}2026-08-06-abc12345.md(first 8 chars of session UUID)Template variables should at least include:
{date}—YYYY-MM-DD{project}— collection name (already exists viascripts/derive-collection.sh){session}— short session ID (first 8 chars of session UUID){time}—HH-MMProposed Config
Implementation Reference
Current (
plugins/claude-code/hooks/stop.sh:72-74):Suggested patch:
Compatibility
filename_templateis unset the file is stillYYYY-MM-DD.md, no behavior change for existing users.derive-collection.sh); files inside one collection are still indexed together.MEMORY_DIRno longer collide.Use Cases
Single-project user (default)
No config change → behavior unchanged.
Multi-project user
Set
filename_template = "{project}-{date}"→alpha-2026-08-06.mdbeta-2026-08-06.mdIdentifiable at a glance.
Backup / migration
Set
subdir_template = "{project}"+filename_template = "{date}"→Per-project directory tree, copy safe.
Alternatives Considered
MEMSEARCH_DIRper projectSessionStartAdditional Benefits
git log --followimmediately shows which project a memory file belongs tolsshows at a glance "alpha had 3 sessions today, beta had 5"~/.memsearch/memory/to a tarball preserves structureTesting
Impact / Scope
Small. Changes:
stop.sh— expand filename resolution to use template~/.memsearch/config.tomlschema — addmemory.filename_templateandmemory.subdir_templateReuses existing
derive-collection.sh, no new dependencies.Priority
Medium. Workarounds exist (
MEMSEARCH_DIRper project) but they don't survive backup / sync / multi-user scenarios cleanly.