Skip to content

fix(paths): follow CLAUDE_CONFIG_DIR to the session tree (#166) - #167

Merged
fdaviddpt merged 2 commits into
mainfrom
fix/166-claude-config-dir
Jul 26, 2026
Merged

fdaviddpt merged 2 commits into
mainfrom
fix/166-claude-config-dir

Conversation

@fdaviddpt

Copy link
Copy Markdown
Contributor

Closes #166.

Claude Code relocates its whole config tree — projects/ included — when CLAUDE_CONFIG_DIR is set, which people use to run a separate account per project. The plugin hardcoded ~/.claude, so it listed a directory holding no current transcripts and the save pipeline no-oped in silence.

The reporter's numbers: five days, ~2000 PostToolUse invocations, zero saves. Empty logs/autonomous/, empty tmp/, no now.md, and nothing anywhere suggesting a problem — the hook wrote its env line and exited 0 every time.

Not finding anything is the mild version. A stale transcript left in the default tree with more lines than delta_lines_trigger would have been summarized into memory as though it were the live session.

The fix

All four sites resolve through one claude_projects_dir() helper instead of four copies of the path. Four copies is how the session slug ended up with five implementations that drifted apart, and three consecutive review rounds each found a copy that had missed an update.

The half that was hiding it

The test suite leaked the same variable. Sandboxes point HOME at a temp directory and never cleared CLAUDE_CONFIG_DIR, so a developer who exports it had the real value follow the code straight out of the fixture and into their actual store.

That stayed invisible precisely because of the bug: while the plugin ignored the variable, the leak and the defect cancelled out. Honouring it exposed both at once.

Cleared in conftest.py for every test rather than in the five fixtures that happened to break, so the next sandbox is hermetic without anyone needing to know why. Verified the only way that means anything — running the whole suite with the variable exported:

with the guard    →  684 passed
without the guard →    5 failed   ← exactly the five @samoilovartem predicted

Credit

@samoilovartem reported this with a verified patch, the four exact call sites, the worse-variant analysis, and a correct prediction of which five tests would break and why. The test-fixture insight is the part that turns a one-line patch into a fix that stays fixed.

684 passing.

Florian DAVID added 2 commits July 26, 2026 11:22
Claude Code relocates its whole config tree, projects/ included, when
CLAUDE_CONFIG_DIR is set — a separate account per project. The plugin
hardcoded ~/.claude, listed a directory with no current transcripts, and
the save pipeline no-oped in silence: five days, ~2000 PostToolUse
invocations, zero saves, nothing in the logs.

Not finding anything is the mild version. A stale transcript sitting in
the default tree with more lines than delta_lines_trigger would have been
summarized into memory as though it were the live session.

Resolved through one claude_projects_dir helper rather than four copies
of the path, because four copies of a path is how the slug ended up with
five implementations that drifted.

The test suite leaked the same variable. Sandboxes point HOME at a temp
dir and never cleared CLAUDE_CONFIG_DIR, so a developer who exports it
had the real value follow the code out of the fixture. It was invisible
while the plugin ignored the variable and appeared the moment it stopped
— cleared in conftest for every test, and verified by running the whole
suite with it exported: 684 pass with the guard, the reporter's exact
five fail without it.

Co-Authored-By: Max <noreply>
Review caught the sweep missing scripts/run-tests.sh:146, which still
hardcoded $HOME/.claude. So the harness wrote its fixture transcript to
one tree while pipeline.shell — now correctly following
CLAUDE_CONFIG_DIR — read another, and `shell extract` failed for exactly
the developers this fix is for.

Pointedly ironic: the commit that introduced the helper says four copies
of a path is how the slug ended up with five implementations that
drifted. This was a fifth copy of this one, missed by the sweep that
argued against copies.

detect-tools.sh is not sourced by run-tests.sh, so it expands the
variable the same way claude_projects_dir does rather than growing a
sixth definition.

Verified: with CLAUDE_CONFIG_DIR exported, `shell extract` now passes.
The one remaining ✗ (save-session.sh --dry) fails identically with the
variable unset — environmental, no session transcript for this checkout,
untouched by this branch.

Co-Authored-By: Max <noreply>
@fdaviddpt
fdaviddpt merged commit 9dab1ab into main Jul 26, 2026
12 checks passed
@fdaviddpt
fdaviddpt deleted the fix/166-claude-config-dir branch July 26, 2026 10:03
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.

Save pipeline silently no-ops when CLAUDE_CONFIG_DIR is set

1 participant