Repository navigation
Conversation
…CT_DIR
When Claude Code runs from a directory that isn't a git repo (e.g. $HOME,
a scratch dir, anywhere the user doesn't `cd` into a project first), the
`## HH:MM | <branch>` identity slot in each today-*.md entry falls back
to the literal string `unknown`. Every entry then looks the same — the
slot loses all signal, and instances running from non-git CWDs end up
indistinguishable in the daily log.
`scripts/save-session.sh` now honors `$REMEMBER_BRANCH` as the highest-
priority source for that slot:
BRANCH="${REMEMBER_BRANCH:-$(... git branch ... || echo "unknown")}"
The `:-` form (not the bare `-`) treats `REMEMBER_BRANCH=` as unset, so
an accidental empty export in a shell rc doesn't propagate an empty
header — it walks down to the existing git/unknown fallback chain.
Backward compatible: zero behavior change when the env var is not set.
Use case: export `REMEMBER_BRANCH=laptop` / `cloud` / `staging` /
`$HOSTNAME` / etc. in your shell rc and the identity slot becomes a
useful per-instance tag. Cross-instance memory protocols where the
remember-plugin's output lands in a shared store benefit the most —
the slot becomes a who-wrote-this tag instead of a git artifact.
Tests:
- `tests/test_save_session_branch_override.py` pins the four-case truth
table: env-set + git-repo (env wins), env-unset + git-repo (git
wins), env-unset + no-git (`unknown`), env-set-empty (treated as
unset by `:-`, walks down). Plus a guard that the BRANCH= line uses
the safe `:-` operator (not bare `-`), so a drift-back to unsafe
substitution surfaces in code review.
- Snapshots the BRANCH= line out of the live save-session.sh rather
than reasserting a copy, so future edits fail the test on intent
rather than on string-equality drift.
Docs:
- `README.md` gains an "Environment variables" subsection under
Configuration documenting `REMEMBER_BRANCH`, `REMEMBER_DEBUG`, and
`REMEMBER_TZ`.
- `CHANGELOG.md` Unreleased entry with the rationale.
396 tests pass (was 391 + 5 new).
Contributor
|
Thanks @gandfrey — clean fix. The One note for a follow-up if multi-instance identity grows legs: the |
This was referenced Sep 4, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Claude Code runs from a directory that isn't a git repo (e.g.
\$HOME, a scratch dir, anywhere the user hasn'tcd'd into a project first), the## HH:MM | <branch>identity slot in everytoday-*.mdentry falls back to the literal stringunknown. The slot collapses across all entries from that working directory — and across multiple Claude Code instances that each run from non-git CWDs, the daily log becomes indistinguishable per writer.This PR adds
\$REMEMBER_BRANCHas the highest-priority source for that slot. Backward compatible — zero behavior change when the env var is unset.Use case I hit: a multi-instance memory protocol where
today-*.mdentries from two Claude Code instances (one on a laptop, one on a Lightsail box) get rsync'd into a shared_inbox/. Both ran Claude Code from\$HOME— neither was a git repo — so every entry's identity slot readunknown. Withexport REMEMBER_BRANCH=laptop/export REMEMBER_BRANCH=cloudin each shell rc, the slot becomes a who-wrote-this tag and the log becomes useful again.Changes
scripts/save-session.sh— one-line change to theBRANCH=line (line 150) using\${REMEMBER_BRANCH:-…}. The:-form (not bare-) intentionally treatsREMEMBER_BRANCH=as unset, so an accidental empty export in a shell rc doesn't propagate an empty header — it walks the existing git/unknown fallback chain.tests/test_save_session_branch_override.py— new test file pinning the four-case truth table (env-set + git-repo, env-unset + git-repo, env-unset + no-git, env-set-empty). Snapshots the liveBRANCH=line out ofsave-session.shrather than reasserting a copy, so future edits to the line fail this test on intent rather than on string-equality drift. Includes a guard that the line uses the safe:-operator, so a regression back to bare-(which would propagate the empty string) surfaces in code review even before tests run.README.md— new "Environment variables" subsection under Configuration documentingREMEMBER_BRANCH,REMEMBER_DEBUG, andREMEMBER_TZ.CHANGELOG.md— Unreleased entry.Test plan
pytestpasses locally — 396 passed, 1 skipped (was 391 + 5 new in this PR).:--operator guard, all intests/test_save_session_branch_override.py.scripts/save-session.sh) — manually verified by applying the same one-line patch to the locally-cached plugin (~/.claude/plugins/cache/claude-plugins-official/remember/0.7.3/scripts/save-session.sh) and exportingREMEMBER_BRANCH=laptopin~/.zshrc. The local change is what motivated submitting this upstream so it survives plugin updates.One transparency note: I have not yet round-tripped a full
Stop → save-session → today-*.md writeagainst this exact branch after runningclaudein a fresh shell that picked up the new env var (the env var was set after this session started). The behavior is exercised by the new tests; the live round-trip is whatever the next session start does, which I'd verify post-merge.Checklist
README.mdConfiguration block; no new config key, hook, or skill was added (just a new env-var input to an existing hook)..claude-plugin/plugin.json— left to maintainer at release time.CHANGELOG.md(existing PRs touch CHANGELOG.md; the template wording mentionsREADME.mdbut I followed the actual project convention).