hygiene: codemap leaves .codemap/ state in every repo it touches, unignored and sometimes committed; agent worktrees pollute scans
Symptoms, measured 2026-09-04 on one machine
- Every repository under
that a hook or scan touched has a .codemap/directory. In at least 10 repos it shows as untracked ingit statusbecause nothing ever added it to an ignore list. - In
business-skills,.codemap/agent_edits.jsonland.codemap/statuswere committed, and they change on every session, so every later commit carries state churn. codemap .on this repo countedwatch/testdatafive times because agent worktrees under.claude/worktrees/are scanned; that produced a wrong before/after figure in PR #179's original body.- The reputation this earns: "codemap leaves a lot behind."
Proposed fix
- State goes somewhere the repo does not see. Prefer a per-repo directory under the user cache (
$XDG_CACHE_HOME/codemap/<hash of repo root>/), or, if the in-repo location must stay, write.codemap/into.git/info/excludeon first use so it is ignored without touching a tracked.gitignore. codemap setupandcodemap doctorreport any tracked.codemap/*files and offergit rm --cached.- Ignore
.claude/worktrees/and.git/worktree checkouts by default in the walker, alongsidevendorandtestdata. - Hooks must never create
.codemap/in a repo that has no codemap config and was only visited by a scan (e.g. a one-offcodemap .in someone else's project).
Exit test
Fresh clone of any repo, run codemap ., run a session with hooks, then git status --porcelain is empty and codemap . file counts match git ls-files | wc -l modulo ignore rules.
Related: #179, #183, #172.
🤖 Generated with Claude Code
https://claude.ai/code/session_01TcyheQmM3HCvxF5wRL3s5t
The exit test here is now green on main via #198: a fresh clone of a repo with no codemap config, codemap ., and git status --porcelain is empty. The auto-written config from #189 stays, but whenever codemap creates .codemap/ in a checkout and nothing already ignores it, the rule goes to <git-common-dir>/info/exclude, never a tracked .gitignore. codemap doctor now reports already-committed .codemap/* files with the git rm -r --cached command, and nested worktrees under .claude/worktrees/ are skipped by the walker (#131).
Left open for the two remaining items: whether runtime state should move out of the repo entirely (an $XDG_CACHE_HOME/codemap/<hash>/ location), and the rule that hooks never create .codemap/ in a repo that has no codemap config.
Generated by Claude Code
Will there be a migration feature, to auto move from non-cache to cache location?