Repository navigation
Conversation
is_protected() only inspected the first component of the path relative to ~/.claude, so a protected name at any greater depth was ignored. Files such as projects/<slug>/CLAUDE.md or projects/<slug>/agents/*.md have `projects` as their first component, so they were reported as unprotected and became eligible for remove_file() during a clean. Check every component instead. For a tool whose failure mode is deleting a file the user wanted to keep, matching too broadly is the safe direction. Adds unit tests covering top-level protection, nested protection, ordinary session data staying cleanable, and paths outside claude_dir. The nested test fails against the previous implementation. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Problem
is_protected()only inspects the first component of the path relative to~/.claude:A protected name at any greater depth is therefore ignored.
CLAUDE.mdis inPROTECTED, but~/.claude/projects/<slug>/CLAUDE.mdhasprojectsas its first component, so it is reported as unprotected andclean_directory()passes it toremove_file()once it is older than the expiry threshold. The same applies toagents/,commands/, andskills/nested inside a project's data directory.This is quiet: the file is simply gone after a clean, and because the Projects category is age-filtered rather than orphan-filtered for active projects, it can happen on a project you still use. Anything a user keeps under
~/.claude/projects/<slug>/is exposed — I hit this with a directory of long-lived notes that had accumulated under a project slug.Fix
Check every component instead of just the first. For a tool whose failure mode is deleting a file the user wanted to keep, matching too broadly is the safe direction to err in.
Tests
Four unit tests added:
protects_top_level_entries— existing behaviour preservedprotects_nested_entries— fails on the current implementation, passes with the fixdoes_not_protect_ordinary_session_data—.jsonltranscripts and telemetry stay cleanable, so the fix does not over-protectdoes_not_protect_paths_outside_claude_dir—strip_prefixmiss still returns falseVerified locally against the current implementation:
and with the fix applied:
cargo fmt --checkandcargo clippy --all-targets -- -D warningsare both clean.Note on scope
Deliberately limited to the protection bug. Two other things I noticed while reading, not touched here — happy to open separate issues if useful:
DEFAULT_SELECTED = ALLpre-selectsPlugins. Since cleaning is per-file and age-based, that shreds plugin git checkouts file by file (including inside.git) rather than uninstalling cleanly. On my machine that category was 1.4 GB of working tooling presented as reclaimable space.ConfigBackupsis also pre-selected, so a default run deletes~/.claude.json.backup*in the same pass that rewrites~/.claude.json— the recovery artifact and the original are modified together.