Repository navigation
fix(learn): honor CLAUDE_CONFIG_DIR when locating Claude logs and memory - #1642
Merged
JerrettDavis merged 3 commits intoJul 2, 2026
Merged
JerrettDavis merged 3 commits into
JerrettDavis merged 3 commits into
Conversation
`headroom learn` resolved the Claude config directory as `~/.claude` in `ClaudeCodePlugin.__init__` and wrote global memory to `~/.claude/CLAUDE.md`, ignoring `CLAUDE_CONFIG_DIR`. Users who relocate their Claude config via that env var had `learn` scan the wrong directory and detect no projects. Add a `claude_config_dir()` helper in the learn package that honors `CLAUDE_CONFIG_DIR` (falling back to `~/.claude`), mirroring the override already respected in `subscription` and `mcp_registry`, and use it in the scanner plugin and the memory writer. Closes headroomlabs-ai#1630
tenderdeve
requested review from
DevanshiVyas,
JerrettDavis and
chopratejas
as code owners
July 1, 2026 10:13
Contributor
PR governanceThis PR follows the template and is marked ready for human review. |
JerrettDavis
approved these changes
Jul 1, 2026
JerrettDavis
left a comment
Collaborator
There was a problem hiding this comment.
Looks good. The Claude learn scanner and global-memory writer now share one config-dir resolver, explicit constructor paths still win in tests, and the regression coverage catches both scan and write targets under CLAUDE_CONFIG_DIR.
# Conflicts: # CHANGELOG.md
JerrettDavis
approved these changes
Jul 2, 2026
JerrettDavis
added a commit
to peterlodri-sec/headroom
that referenced
this pull request
Jul 14, 2026
…ory (headroomlabs-ai#1642) ## Description `headroom learn` ignored `CLAUDE_CONFIG_DIR`. `ClaudeCodePlugin.__init__` resolved the Claude config directory as `~/.claude`, and the memory writer wrote the global `CLAUDE.md` to `~/.claude/CLAUDE.md`. A user who relocates their Claude config with that env var had `learn` scan the wrong directory and detect no projects. Other parts of the codebase already honor the override (`subscription/client.py`, `subscription/session_tracking.py`, `mcp_registry/claude.py`); the `learn` path was the outlier. Closes headroomlabs-ai#1630 ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) ## Changes Made - Add `claude_config_dir()` to `headroom/learn/_shared.py` — returns `$CLAUDE_CONFIG_DIR` when set, else `~/.claude` (via `Path.home()`, matching the existing override elsewhere). - `ClaudeCodePlugin.__init__` now defaults `claude_dir` to `claude_config_dir()` instead of a hardcoded `~/.claude` (an explicit `claude_dir=` argument still wins). - `ClaudeCodeWriter._resolve_context_path` writes the home-directory global memory to `claude_config_dir() / "CLAUDE.md"` instead of `~/.claude/CLAUDE.md`. ## Testing - [x] Unit tests pass (`pytest`) - [x] Linting passes (`ruff check .`) - [x] Type checking passes (`mypy headroom`) - [x] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ pytest tests/test_learn/test_claude_config_dir.py tests/test_learn/test_writer.py -q 35 passed, 1 warning in 0.18s $ ruff check headroom/learn/ tests/test_learn/test_claude_config_dir.py All checks passed! $ mypy headroom/learn/_shared.py headroom/learn/plugins/claude.py headroom/learn/writer.py Success: no issues found in 3 source files ``` ## Real Behavior Proof - Environment: macOS (arm64), Python 3.14 venv, editable install of this branch. - Exact command / steps: ran `python -c "from headroom.learn.plugins.claude import ClaudeCodePlugin; print(ClaudeCodePlugin().projects_dir)"` with and without `CLAUDE_CONFIG_DIR=/tmp/altclaude` set, then `pytest tests/test_learn/ tests/test_cli_learn.py`. - Observed result: default prints `/Users/<me>/.claude/projects`; with `CLAUDE_CONFIG_DIR=/tmp/altclaude` it prints `/tmp/altclaude/projects` (before this change the second still printed `~/.claude/projects`). Test suite: 226 passed, 3 skipped. New regression tests cover the plugin scan dir, explicit-arg precedence, and the writer's home-memory path. - Not tested: end-to-end `headroom learn` against a real relocated log tree with live Claude Code transcripts — verified at the plugin/writer resolution layer plus the existing scanner suite. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review ## Additional Notes The identical hardcode also exists at `headroom/cli/mcp.py:21` (`CLAUDE_CONFIG_DIR = Path.home() / ".claude"`), but that is a separate command outside this issue's scope, so I left it for a follow-up to keep this PR to one issue. --------- Co-authored-by: JerrettDavis <[email protected]>
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.
Description
headroom learnignoredCLAUDE_CONFIG_DIR.ClaudeCodePlugin.__init__resolved the Claude config directory as~/.claude, and the memory writer wrote the globalCLAUDE.mdto~/.claude/CLAUDE.md. A user who relocates their Claude config with that env var hadlearnscan the wrong directory and detect no projects.Other parts of the codebase already honor the override (
subscription/client.py,subscription/session_tracking.py,mcp_registry/claude.py); thelearnpath was the outlier.Closes #1630
Type of Change
Changes Made
claude_config_dir()toheadroom/learn/_shared.py— returns$CLAUDE_CONFIG_DIRwhen set, else~/.claude(viaPath.home(), matching the existing override elsewhere).ClaudeCodePlugin.__init__now defaultsclaude_dirtoclaude_config_dir()instead of a hardcoded~/.claude(an explicitclaude_dir=argument still wins).ClaudeCodeWriter._resolve_context_pathwrites the home-directory global memory toclaude_config_dir() / "CLAUDE.md"instead of~/.claude/CLAUDE.md.Testing
pytest)ruff check .)mypy headroom)Test Output
Real Behavior Proof
python -c "from headroom.learn.plugins.claude import ClaudeCodePlugin; print(ClaudeCodePlugin().projects_dir)"with and withoutCLAUDE_CONFIG_DIR=/tmp/altclaudeset, thenpytest tests/test_learn/ tests/test_cli_learn.py./Users/<me>/.claude/projects; withCLAUDE_CONFIG_DIR=/tmp/altclaudeit prints/tmp/altclaude/projects(before this change the second still printed~/.claude/projects). Test suite: 226 passed, 3 skipped. New regression tests cover the plugin scan dir, explicit-arg precedence, and the writer's home-memory path.headroom learnagainst a real relocated log tree with live Claude Code transcripts — verified at the plugin/writer resolution layer plus the existing scanner suite.Review Readiness
Additional Notes
The identical hardcode also exists at
headroom/cli/mcp.py:21(CLAUDE_CONFIG_DIR = Path.home() / ".claude"), but that is a separate command outside this issue's scope, so I left it for a follow-up to keep this PR to one issue.