Skip to content

Do not scan ~/.claude as project scope when launched from the home directory - #2

Open
sukidev07 wants to merge 1 commit into
Magic-Man-us:mainfrom
sukidev07:fix-home-launch-scope-dedupe
Open

Do not scan ~/.claude as project scope when launched from the home directory#2
sukidev07 wants to merge 1 commit into
Magic-Man-us:mainfrom
sukidev07:fix-home-launch-scope-dedupe

Conversation

@sukidev07

Copy link
Copy Markdown

Summary

When capdisc runs with the working directory set to the home directory itself (a real case: running it right after install, before cd-ing anywhere), ScopeRoots.discover walks up from start = ~, finds ~/.claude, and labels it project scope — while the same physical directory is also added as the user root. Every artifact in ~/.claude is then captured twice, once per scope label. Observed live: a 6-artifact user inventory (5 commands + hooks) reported as 12 entries.

This is the same double-capture class the existing add-dir dedupe comment in discover already guards against, just via the home-launch path.

Fix: ~/.claude is owned by user scope. discover() now drops a project-scope base that resolves to home_dir/.claude, and the same resolved path is added to seen_project_bases so an --add-dir pointing at home is skipped by the existing guard. Behavior with home_dir=None is unchanged.

Testing

  • New test_home_launch_does_not_double_scan_user_claude: discover(start=home, home_dir=home) yields exactly one root for ~/.claude, labelled user, and the scanned inventory captures each artifact once.
  • Full suite 157 passed; ruff clean; pyright clean on the touched files (the 12 pre-existing errors elsewhere reproduce identically on upstream HEAD with a current pyright, unrelated to this change).

Generated with Claude Code

…rectory

Launched with cwd = ~, the project-scope walk-up finds ~/.claude and
labels it project scope while the same physical directory is also added
as the user root - so every artifact in it is captured twice (observed
live: a 6-artifact user inventory listed as 12, each once per scope).
The user root is the true owner of ~/.claude; discover() now drops the
project-scope alias, and an --add-dir resolving to ~/.claude is skipped
by the same guard, mirroring the existing add-dir dedupe.

Regression test: discover(start=home, home_dir=home) yields exactly one
root for ~/.claude, labelled user, and the inventory captures each
artifact once.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

1 participant