01 / Find logs and other local data
Claude Code log locations and the data stored alongside them
Local data defaults to ~/.claude, and the natively installed CLI usually lives in ~/.local/share/claude. Project worktrees may be in the repository's own .claude/worktrees. The CLI, VS Code / JetBrains extensions, and desktop app may share user data, so check them together.
The table below uses default paths; ~ means your home directory. If CLAUDE_CONFIG_DIR is set, user data and related configuration use that custom location. Not every version has every directory, and there is no typical size that applies to every Mac. Use the commands in the next section to measure yours.
| Path | Contents | Size reference | Effect of deletion |
|---|---|---|---|
~/.claude/cache/changelog.md~/.claude/debug | The changelog cache, which can be fetched again, and session debug logs. | There is no single typical size; extensive debug output may keep growing. | Safe to delete · With conditionsAfter stopping related tasks, you can remove old logs confirmed to be unnecessary for troubleshooting and this changelog cache. Do not treat all of .claude as a cache. |
~/.claude/logs~/.claude/statsig | Log and statistics directories that older versions may have left behind; current documentation lists them as legacy directories. | Depends on installation and upgrade history; skip them if absent. | Safe to delete · Legacy leftoversCheck your current version and each directory's purpose before cleaning. Keep files needed to troubleshoot older versions. |
~/.local/bin/claude~/.local/share/claude/versions | The native installer's command entry point and executable files for each version. The entry point is usually a link to a version in versions. | Depends on the number of versions and architecture; the small launcher link does not reflect the program's actual size. | Wrong deletion requires reinstallingFirst confirm the active version, running sessions, and custom startup scripts. Deleting the wrong executable can break the CLI and require repair or reinstallation. |
Directory returned by npm root -gHomebrew claude-code / claude-code@latest | The CLI and platform dependencies managed by npm or Homebrew, not session records. | Depends on installation source and version; each Node environment may have its own copy. | Uninstalling requires reinstallingMaintain these through their original package manager. Do not count the entire shared npm or Homebrew cache as Claude Code storage. |
~/.claude/projects/<project>/<session>.jsonl~/.claude/projects/<project>/<session>/ | Session content, subagent records, large tool outputs, and data needed to resume tasks. | Accumulates with conversations and tool output; there is no reliable average. | Loses conversation historyAffects resume, continue, and restoring old sessions. projects may also contain auto memory, so do not empty the entire directory as if it contained only logs. |
~/.claude/projects/<project>/memory/~/.claude/agent-memory/ | Project auto memory and persistent subagent memory, which may include MEMORY.md and topic files. | Depends on the number and contents of memories; storage may also be configured elsewhere. | Loses memoryDeletion loses saved context. Session retention does not define auto memory retention; review these through the memory features first. |
~/.claude/history.jsonl~/.claude/paste-cache | Previously entered prompts and large pasted text blocks. | Measure actual usage; this is not the size of all sessions. | Loses input historyMay lose up-arrow recall, history search, and pasted content. Deleting history.jsonl does not also clear session records in projects. |
~/.claude/file-history | Snapshots saved before Claude modifies files, used for checkpoint restoration. | Depends on modified files and retained checkpoints. | Loses file restoration abilityAfter deletion, /rewind in past sessions may no longer restore files. Confirm that code is committed or fully backed up elsewhere first. |
~/.claude/stats-cache.json~/.claude/usage-data | Historical usage statistics for /usage, plus /insights reports and analysis data. | Varies with usage and report counts; measure the actual files. | Loses historical statisticsEven with cache in the name, historical statistics cannot be guaranteed to rebuild without loss. Keep these if you need usage history or old reports. |
~/.claude/tasks~/.claude/plans~/.claude/uploads~/.claude/feedback-bundles~/.claude/feedback/drafts | Task lists, plans, attachments, and feedback drafts; some are referenced by old sessions or unfinished tasks. | Depends on features used and attachment sizes. | Loses task dataFinish tasks and save needed files first. Being called temporary data does not mean it contains nothing worth keeping. |
~/.claude/backups~/.claude.json.backup*~/.claude/skills/.trash~/.claude/plugins/.trash | Configuration backups left by different versions and recovery copies of removed synced skills and plugins. | Varies with version history and synchronization activity. | Loses recovery copiesDeleting these removes the corresponding recovery options. First confirm that the current configuration works and the old copies are no longer needed. |
~/.claude.json~/.claude/settings.json~/.claude/.credentials.json~/.claude/plugins~/.claude/skillsproject/.claudeproject/CLAUDE.mdproject/.mcp.json | Account and project state, preferences, credentials, plugins, custom skills, and project configuration. Credentials on macOS usually also involve the system Keychain. | Identify their purpose first; size does not determine whether they can be deleted. | Keep configuration / capabilitiesKeep these. Clearing them may lose settings, affect sign-in, or break plugins. Uninstalling the CLI does not require deleting this data. |
project/.claude/worktrees/<name> | Git working copies created inside the repository by default by the CLI; they may contain unmerged code, dependencies, and build outputs. | Depends on project size and the number of parallel tasks; may exceed log sizes. | May lose code / filesCheck modifications, unpushed commits, and ignored files before using worktree management. Do not empty the project's .claude directory as a cache. |
/private/tmp/claude-<user ID>claude-<user ID> under CLAUDE_CODE_TMPDIR | Temporary files stored by project and session, including images and scratchpad drafts in some versions. | Affected by attachments and intermediate files; temporary directories are not necessarily small. | Check temporary outputs firstRunning tasks may still use these files. Move scratchpad outputs you want to keep into the project first. Do not bulk-empty /tmp. |
Parent directory totals already include their subdirectories, so do not add every row together. This guide covers Claude Code. Other Claude desktop app caches, remote hosts, containers, and cloud tasks need separate checks; they cannot all be counted as local CLI usage.
02 / Three inspection steps
Measure user data, the CLI, and temporary files separately
Save project files first, stop agents, background sessions, and related tasks, then quit the CLI, IDE extensions using Claude Code, and the desktop app. Run the following commands in macOS Terminal. They only inspect paths and disk usage, do not delete files, and do not require sudo.
Step 1: Save directory and disk baselines before cleanup
du -sh summarizes directory usage, while df -k shows space on the volume containing that path. The -H flag follows directory links passed as arguments; it does not recursively follow every link inside them.
claude_data_dir="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
claude_temp_dir="${CLAUDE_CODE_TMPDIR:-/tmp}/claude-$(id -u)"
for p in \
"$claude_data_dir" \
"$HOME/.local/share/claude" \
"$claude_temp_dir"
do
if [ -d "$p" ]; then
printf '\n%s\n' "$p"
du -shH "$p"
df -k "$p"
else
printf '%s %s\n' 'Does not exist, skipping:' "$p"
fi
doneOn macOS, /tmp usually corresponds to /private/tmp. The commands inspect only the current user's claude-userID subdirectory; they do not scan or empty the entire temporary directory. Project worktrees and package manager installations are checked separately in section 5.
Step 2: Inspect one directory level and each native CLI version
Start with directories such as projects, file-history, and debug. The native versions directory is checked with -a to include files, because each version may be an executable rather than a folder.
claude_data_dir="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
if [ -d "$claude_data_dir" ]; then
du -h -d 1 -H "$claude_data_dir"
fi
if [ -d "$HOME/.local/share/claude/versions" ]; then
du -ah -d 1 -H "$HOME/.local/share/claude/versions"
fiStep 3: Separate removable logs from records to keep
If projects is using the space, inspect sessions and memory. If it is file-history, consider the ability to restore files. A large directory is not automatically a cleanup candidate.
claude_data_dir="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
for name in projects file-history debug cache plugins backups \
tasks plans uploads paste-cache usage-data agent-memory
do
if [ -d "$claude_data_dir/$name" ]; then
du -shH "$claude_data_dir/$name"
fi
done
for name in history.jsonl stats-cache.json
do
if [ -f "$claude_data_dir/$name" ]; then
du -shH "$claude_data_dir/$name"
fi
doneEach measurement block independently reads CLAUDE_CONFIG_DIR from the current terminal. When this variable is set, .claude.json, normally in your home directory, also uses the custom configuration directory. CLAUDE_CODE_TMPDIR determines the parent location for temporary files, and autoMemoryDirectory can separately change where auto memory is stored. Desktop app or startup script settings may differ from the current terminal, so verify and measure them separately.
Skip directories that do not exist. Permission errors mean the measurement is incomplete, not that usage is zero. Keep the quotes around paths, and do not add parent totals to their subdirectory totals.
03 / Clean with the consequences in mind
Three safety levels: where should you start?
Caches that can be fetched again and debug logs you no longer need
Stop related processes first, then remove the verified changelog cache, old debug output, and leftover logs from applicable versions. Keep records needed for ongoing troubleshooting. “Safe to delete” does not include the entire ~/.claude directory.
Unused CLI installations and old versions
Confirm the installation source and active version, then maintain it using the corresponding method. Native, npm, and Homebrew installations may coexist. Do not delete versions that are running or referenced by custom startup scripts.
Sessions, memory, file snapshots, tasks, and historical statistics
Keep any needed projects, file-history, input history, and worktrees. To retain historical totals in /usage or /insights reports, also keep stats-cache.json and usage-data.
Clean level A only: confirm each item in Finder
- Save files and finish tasks. Confirm that the CLI, IDE extensions, and desktop app are no longer reading or writing the related data.
- In Finder, press ⇧⌘G to open the actual Claude Code data directory, then enter the cache or log subdirectory you have verified.
- Move only files you no longer need to the Trash. Do not also select projects, file-history, configuration files, or the entire user data directory.
- Review the items moved to the Trash this time, permanently delete them only after confirming they are no longer needed, then remeasure as described in the next section. Moving files to the Trash alone does not free space.
Automatic retention does not mean everything disappears after 30 days
In the current documentation, cleanupPeriodDays defaults to 30 days and governs background cleanup of sessions and some application data. Auto memory, input history, and some statistics follow different rules. Sessions started or most recently continued in the desktop app or Cowork also involve desktopSessionCleanupPeriodDays, the version, and enterprise policies.
The minimum value for cleanupPeriodDays is 1; setting it to 0 fails validation. A shorter period removes old records and file snapshots sooner, and configuration problems may also pause cleanup. Adjusting retention is not a way to reduce storage while keeping all history.
If you truly no longer need a project's history, preview the impact first
Current versions provide claude purge, which handles project sessions, auto memory, associated tasks and file snapshots, matching input history, and project state in .claude.json. This discards local project records; it is not ordinary cache cleanup. Back up anything you need first.
First enter the project root directory you want to inspect, confirm your location with pwd, then run the read-only preview below. You must keep --dry-run. Older versions may not have this command; check support in your version with claude purge --help first.
claude purge "$PWD" --dry-runThe preview does not delete files. Before actually cleaning, read each confirmation prompt in your current version. Purge is also not guaranteed to handle images, scratchpad files, or old configuration backups in temporary directories, so it does not establish that every copy has been removed.
04 / Verify cleanup results
How can you confirm that deleted files really freed space?
Compare both the reduction in target directory usage and the increase in available space on the same volume. Keep Claude Code closed, pause large downloads, builds, and file copies, and repeat the commands from step 1. Remeasure custom paths and project worktrees using the same paths as before cleanup.
claude_data_dir="${CLAUDE_CONFIG_DIR:-$HOME/.claude}"
claude_temp_dir="${CLAUDE_CODE_TMPDIR:-/tmp}/claude-$(id -u)"
for p in \
"$claude_data_dir" \
"$HOME/.local/share/claude" \
"$claude_temp_dir"
do
if [ -d "$p" ]; then
printf '\n%s\n' "$p"
du -shH "$p"
df -k "$p"
else
printf '%s %s\n' 'Does not exist, skipping:' "$p"
fi
doneCompare Available for the same Filesystem. df -k counts 1,024-byte blocks; dividing the increase by 1,048,576 gives approximately the additional GiB. If several paths are on the same volume, available space is repeated and must not be added together.
The directory is smaller but available space has not increased? Check in this order
Files are still in the Trash, or backups remain on the same disk
Moving files to the Desktop, renaming a directory, or adding
.bakdoes not free space. Move files you need to another disk and verify they are complete. Permanently delete only the items from this cleanup that you are sure you no longer need.The CLI has quit, but an extension, the desktop app, or a background session is still running
They may share the same configuration directory. If a file has disappeared from the directory but a process still has it open, its disk blocks may not yet be reclaimed. Save your work and quit related processes normally; restart your Mac if needed, then remeasure. Empty output from the following read-only check cannot rule out every process.
lsof +L1The context was cleared, but records remain on disk
/clearand/compactoperate on sessions and context; they do not delete local files in projects. history.jsonl, file snapshots, auto memory, and temporary attachments also need separate assessment.APFS snapshots retain old data, and different views report space differently
Time Machine local snapshots may retain data from before deletion, and the system manages purgeable space. Finder, Storage settings, and
dfmay therefore show different values. Decimal GB and GiB also cannot be compared directly.tmutil listlocalsnapshots /This command does not delete snapshots or cover every APFS snapshot. Do not bulk-delete recovery points just to make the number change immediately.
You checked a different configuration, or reopening generated more data
Multiple accounts may each use a different
CLAUDE_CONFIG_DIR, and native, npm, and Homebrew installations may coexist. Reopening apps, continuing tasks, restoring worktrees, or installing dependencies writes data. Record the state while apps are closed and again after reopening them.
The selected directories use less space, and available space on the same volume increases under the same conditions. Then reopen Claude Code and confirm that the CLI, sign-in, sessions and memory you kept, and projects work normally. Record the amount processed by the app, the directory size reduction, and the increase in disk space separately; they do not have to match exactly.
05 / Remember the CLI
How do you check native, npm, and Homebrew installations and worktrees?
Find the claude currently being run first
The following lists command entry points and the version found by the current terminal, then runs the read-only installation diagnostic claude doctor. A missing command only means the current PATH is not configured; another copy may still exist in an IDE extension, the desktop app, or another Node environment.
if command -v claude >/dev/null 2>&1; then
type -a claude
claude --version
claude_command_path="$(command -v claude)"
if [ -f "$claude_command_path" ] || [ -L "$claude_command_path" ]; then
ls -l "$claude_command_path"
fi
claude doctor
else
printf '%s\n' 'No claude command found in PATH for the current terminal'
fiNative installation: the launcher link is small; version files use the space
By default, ~/.local/bin/claude links to an executable in ~/.local/share/claude/versions. The native installer manages old versions and retains the version targeted by the launcher and versions still running on this machine. Do not bulk-delete versions based solely on file dates.
If you replaced the entry point with a custom script or link, the current documentation says the installer may retain all versions because it cannot determine which one the script needs. Check claude doctor and the launcher's target before repairing or maintaining the installation. For versions shared with other machines, also confirm that those machines are not using them.
npm and Homebrew: maintain them using the original installation method
The npm package is @anthropic-ai/claude-code; current packages may also include separate platform binary dependencies. The query covers only the current Node environment. Switching environments with nvm, fnm, or similar tools may reveal another installation.
if command -v npm >/dev/null 2>&1; then
npm list -g @anthropic-ai/claude-code --depth=0
npm root -g
npm config get cache
else
printf '%s\n' 'npm was not found in the current terminal'
fiLook for claude-code or claude-code@latest in Homebrew output. Current documentation maps them to the stable and latest channels, respectively. Use the name of the cask actually installed when updating or uninstalling.
if command -v brew >/dev/null 2>&1; then
brew list --cask --versions
brew --cache
else
printf '%s\n' 'Homebrew was not found in the current terminal'
finpm config get cache and brew --cache point to shared caches, which cannot be attributed entirely to Claude Code. If you no longer need a CLI installation, uninstall it using its corresponding installation method. If you still need it, let the installer or package manager maintain versions first. Uninstalling the program and deleting user history are separate actions.
Worktrees live inside projects: include source code, dependencies, and outputs
The CLI's --worktree creates working copies in .claude/worktrees under the repository root by default, not in ~/.claude in your home directory. Run the commands below from the root of the repository you want to inspect. Check custom worktrees and desktop working copies at the actual locations shown by git worktree list.
git worktree list
git status --short --untracked-files=all
git status --short --ignored
if [ -d .claude/worktrees ]; then
du -h -d 1 .claude/worktrees
df -k .claude/worktrees
fiThe status command checks only the current working directory; enter each other worktree to inspect it. A clean working directory does not mean commits have been pushed, and Git-ignored files may be important outputs. Complete any merges, pushes, or separate backups first, then use worktree management when exiting the session or the normal Git removal workflow. Do not force-delete the entire directory.
User data and project directories may be on different disks. Record each worktree's directory size and volume separately, then remeasure the same paths after cleanup. Manage project node_modules and build caches using the project's tools.
06 / Spend less time hunting through directories
Prefer an automatic scan? Find Claude Code disk usage with AgentClean
AgentClean can scan supported local Claude Code cleanup items. Review the results, paths, and important considerations, then choose what to clean without switching between Terminal and Finder to inspect every directory.
Start with supported caches, debug logs, and old native CLI versions identified by version retention rules. Deselect the corresponding items if you want to keep sessions, auto memory, restore snapshots, or historical usage. Coverage of custom configuration directories, npm, Homebrew, and project worktrees depends on the actual scan results.
Stay tuned
AgentClean is currently available only for Mac. Other platforms aren’t available yet. Visit this site on a Mac to download.
The size found by a scan is not necessarily the space that can be freed. After cleanup, you can also verify results with the du / df method on this page.
07 / Frequently asked questions
Things to check before cleaning Claude Code
Can I delete the entire ~/.claude directory?
It is not recommended. It may contain sessions, auto memory, file snapshots, configuration, plugins, and task data together. The CLI, IDE extensions, and desktop app may all write to it, so stop related tasks before cleaning. Only remove verified caches and logs you no longer need. Keep settings.json, credentials, custom skills, and sessions you want to continue using.
Do /clear or /compact free disk space?
/clear clears the current conversation context and starts a new session; the old session may still be accessible through resume. /compact compresses context and should not be treated as deleting local records. Whether disk space is freed depends on changes in actual file sizes and available space on the containing volume.
Does projects contain only chat logs? Can I delete whole folders?
No. Along with session JSONL files, projects may contain subagent records, large tool outputs, and auto memory in memory/. Deleting an entire project's data directory loses its history and memory. If you need to completely remove a project's local state, back it up first, then check the project cleanup preview provided by your current version. Do not treat this as cache cleanup that preserves history.
Will deleting file-history affect my current code?
It stores snapshots from before file edits. Deleting it usually does not delete current project files, but it removes the ability to restore the corresponding checkpoints. /rewind in old sessions may no longer restore code. Confirm that needed changes are committed, pushed, or backed up elsewhere first. Checkpoints themselves also do not replace a complete Git version history.
Does uninstalling the CLI also delete sessions and configuration?
Program installations and user data are separate. Maintain or uninstall native, npm, and Homebrew installations using their respective methods. Do not additionally run commands to empty ~/.claude, ~/.claude.json, or project configuration. IDE extensions or the desktop app may still use this data, and a second CLI installation may also remain.
Is there not automatic cleanup after 30 days? Why do old records remain?
Current documentation gives cleanupPeriodDays a default of 30 days, but not all data is deleted by that rule: auto memory, input history, and some statistics are retained. Desktop app and Cowork sessions also involve desktopSessionCleanupPeriodDays, the version, and management policies. Configuration errors may pause cleanup too. The minimum value for cleanupPeriodDays is 1; setting it to 0 fails validation and is not a way to disable saving.
Why has available space on my Mac not increased much after deletion?
Check whether files remain in the Trash, backups are on the same disk, or the CLI or background sessions still have files open, and whether APFS snapshots or newly generated data affect the results. Compare du for the same paths and df for the same Filesystem. The directory size reduction and increase in available disk space do not necessarily match.
Can AgentClean scan Claude Code CLI data?
It can scan caches, debug logs, old native CLI versions, and history and task data requiring careful review that are covered by its scanning rules. Deselect the corresponding items if you need to keep sessions, memory, file snapshots, or historical statistics. Do not assume that custom CLAUDE_CONFIG_DIR locations, npm and Homebrew installations, or project worktrees are all covered; rely on the actual scan results from the current version.