[BUG] ~/.cache/claude-cli-nodejs is only swept for the current cwd's slug — slugs for deleted projects and for /tmp scratchpad cwds are unreachable forever

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 1 comment · opened Aug 18, 2026

What happened

~/.cache/claude-cli-nodejs holds one directory per project slug (mcp-logs-*, errors, messages). The cleanup that targets it derives its path from the current working directory — join(cacheDir, slugify(process.cwd())) — so it can only ever clean the slug of the session doing the cleaning.

Every other slug is unreachable. Not "cleaned late", unreachable: once you stop opening sessions in a directory, its cache dir can never be selected again.

21 slugs / 6.5 MB on this box. Two categories are permanently stranded.

Deleted projects. I removed two repos today; their slugs stayed:

-root-consent-harbor     260K
-root-harbormaster       144K

Ephemeral cwds. These are the interesting ones — slugs derived from session scratchpad paths under /tmp:

-tmp-claude-0--root--claude-0c4c374c-6208-4db8-bef4-8426771df7d6-scratchpad
-tmp-claude-0--root--claude-2ee2c2c1-9f50-4cb5-8a82-3f777e559e0a-scratchpad-refinstall-skills-gstack
-tmp-claude-0--root--claude-9e1617e0-ad82-466b-b760-7f4e39197297-scratchpad-bigctx
-tmp-claude-0--root--claude-9e1617e0-ad82-466b-b760-7f4e39197297-scratchpad-final
-tmp-claude-0--root--claude-9e1617e0-ad82-466b-b760-7f4e39197297-scratchpad-pinned
-tmp-claude-0--root--claude-9e1617e0-ad82-466b-b760-7f4e39197297-scratchpad-repro

A scratchpad path contains a session UUID. It is used once and never again, so those six slugs are guaranteed dead on arrival — the cwd they encode cannot recur even in principle. Six of 21 slugs here were unreclaimable the moment they were created.

Expected

The sweep enumerates the cache directory and prunes by mtime like it does elsewhere, instead of only looking at the slug it happens to be standing in.

Actual

Monotonic growth. There's no user-facing way to clear it either — cleanupPeriodDays doesn't reach it, and the directory names are opaque enough that hand-deleting them means reverse-engineering the slug encoding first (which is lossy: -root-signalyze-v2 could be /root/signalyze/v2 or /root/signalyze-v2).

Suggested fix

Iterate the cache root and apply the same age policy to every slug, not just slugify(process.cwd()). Slugs whose decoded path no longer exists are safe to drop outright, and anything under a /tmp/claude-* prefix can be dropped as soon as the owning session is gone.

Environment

Claude Code 2.1.220, Ubuntu 22.04.5, single ext4 root, several concurrent sessions.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗