How to Clean Up Local Claude Code Cache and Data
Claude Code generates a significant amount of cache, logs, and temporary files during use. Regular cleanup can free up disk space and resolve common issues.
Why Clean Up?
Common Problem Scenarios
- 💾 Low Disk Space - Claude Code cache consuming large amounts of space
- 🐛 Runtime Errors - Corrupted cache causing errors
- 🔄 Configuration Issues - Need to reset to initial state
- ⚡ Performance Degradation - Excessive cache affecting performance
Benefits of Cleanup
- ✅ Free up disk space
- ✅ Resolve cache-related errors
- ✅ Improve runtime performance
- ✅ Reset to clean state
Cleanup Methods
Windows System
Method 1: Using File Explorer
Clean User Data Directory
%APPDATA%\.claude-code- Press
Win + Rto open Run dialog - Enter
%APPDATA%\.claude-code - Delete the entire folder
- Press
Clean Cache Directory
%LOCALAPPDATA%\.claude-code-cache- Press
Win + Rto open Run dialog - Enter
%LOCALAPPDATA%\.claude-code-cache - Delete the entire folder
- Press
Clean Temporary Files
%TEMP%\claude-code-*- Press
Win + Rto open Run dialog - Enter
%TEMP% - Delete all folders starting with
claude-code-
- Press
Method 2: Using PowerShell Script
Open PowerShell (with administrator privileges) and run:
powershell
# Stop Claude Code processes
Get-Process | Where-Object {$_.ProcessName -like "*claude*"} | Stop-Process -Force
# Clean user data
Remove-Item -Path "$env:APPDATA\.claude-code" -Recurse -Force -ErrorAction SilentlyContinue
# Clean cache
Remove-Item -Path "$env:LOCALAPPDATA\.claude-code-cache" -Recurse -Force -ErrorAction SilentlyContinue
# Clean temporary files
Remove-Item -Path "$env:TEMP\claude-code-*" -Recurse -Force -ErrorAction SilentlyContinue
# Clean npm cache
npm cache clean --force
Write-Host "Claude Code cleanup complete!" -ForegroundColor Green
macOS System
Method 1: Using Finder
Clean User Data Directory
~/Library/Application Support/claude-code- Press
Cmd + Shift + Gto open Go to Folder - Enter the path above
- Delete the entire folder
- Press
Clean Cache Directory
~/Library/Caches/claude-code- Press
Cmd + Shift + G - Enter the path above
- Delete the entire folder
- Press
Clean Log Files
~/Library/Logs/claude-code- Press
Cmd + Shift + G - Enter the path above
- Delete the entire folder
- Press
Method 2: Using Terminal Commands
Open Terminal and run:
bash
#!/bin/bash
# Stop Claude Code processes
pkill -f "claude-code"
# Clean user data
rm -rf ~/Library/Application\ Support/claude-code
# Clean cache
rm -rf ~/Library/Caches/claude-code
# Clean logs
rm -rf ~/Library/Logs/claude-code
# Clean temporary files
rm -rf /tmp/claude-code-*
# Clean npm cache
npm cache clean --force
echo "✅ Claude Code cleanup complete!"
Linux System
Using Terminal Commands
bash
#!/bin/bash
# Stop Claude Code processes
pkill -f "claude-code"
# Clean user data
rm -rf ~/.config/claude-code
rm -rf ~/.local/share/claude-code
# Clean cache
rm -rf ~/.cache/claude-code
# Clean temporary files
rm -rf /tmp/claude-code-*
# Clean npm cache
npm cache clean --force
echo "✅ Claude Code cleanup complete!"
Files to Keep
Important: Backup Before Cleanup
If you have custom configurations, backup these files before cleanup:
Windows
%APPDATA%\.claude-code\config.json
%APPDATA%\.claude-code\settings.json
macOS/Linux
~/.config/claude-code/config.json
~/.config/claude-code/settings.json
Configuration File Descriptions
- config.json - Claude Code main configuration file
- settings.json - User personalization settings
- .env - Environment variable configuration (if exists)
Common Questions
Q1: Do I need to reinstall after cleanup?
A: No. Cleanup only removes cache and user data, not the Claude Code program itself. You can run it directly after cleanup.
Q2: What data will be lost after cleanup?
A: Will lose:
- Cached conversation history
- Local settings and configurations
- Login status
Won't lose:
- Claude Code program itself
- Your project code
Q3: What if it won't start after cleanup?
A: Try these steps:
- Completely uninstall Claude Code
- Reinstall the latest version
- Check system environment variable configuration
Q4: How often should I clean up?
A: Recommendations:
- Normal use : Once a month
- Heavy use : Once a week
- When issues occur : Immediately
Automated Cleanup Scripts
Windows Batch Script
Create cleanup-claude-code.bat file:
batch
@echo off
echo Cleaning Claude Code...
taskkill /F /IM claude-code.exe 2>nul
rmdir /S /Q "%APPDATA%\.claude-code" 2>nul
rmdir /S /Q "%LOCALAPPDATA%\.claude-code-cache" 2>nul
del /Q "%TEMP%\claude-code-*" 2>nul
npm cache clean --force
echo.
echo ✅ Claude Code cleanup complete!
pause
macOS/Linux Shell Script
Create cleanup-claude-code.sh file:
bash
#!/bin/bash
echo "Cleaning Claude Code..."
# Stop processes
pkill -f "claude-code"
# Clean files
rm -rf ~/Library/Application\ Support/claude-code 2>/dev/null
rm -rf ~/Library/Caches/claude-code 2>/dev/null
rm -rf ~/Library/Logs/claude-code 2>/dev/null
rm -rf ~/.config/claude-code 2>/dev/null
rm -rf ~/.cache/claude-code 2>/dev/null
rm -rf /tmp/claude-code-* 2>/dev/null
# Clean npm cache
npm cache clean --force
echo ""
echo "✅ Claude Code cleanup complete!"
Grant execution permission:
bash
chmod +x cleanup-claude-code.sh
Run the script:
bash
./cleanup-claude-code.sh
Selective Cleanup
If you don't want a complete cleanup, you can selectively clean specific content:
Only Clean Cache (Keep Configuration)
Windows:
powershell
Remove-Item -Path "$env:LOCALAPPDATA\.claude-code-cache" -Recurse -Force
macOS/Linux:
bash
rm -rf ~/Library/Caches/claude-code
rm -rf ~/.cache/claude-code
Only Clean Logs
Windows:
powershell
Remove-Item -Path "$env:APPDATA\.claude-code\logs" -Recurse -Force
macOS:
bash
rm -rf ~/Library/Logs/claude-code
Linux:
bash
rm -rf ~/.local/share/claude-code/logs
Only Clean Temporary Files
Windows:
powershell
Remove-Item -Path "$env:TEMP\claude-code-*" -Recurse -Force
macOS/Linux:
bash
rm -rf /tmp/claude-code-*
Reconfiguration After Cleanup
1. Re-login
You'll need to log in to your Claude account again after the first startup following cleanup.
2. Restore Configuration
If you backed up configuration files, you can restore them:
Windows:
powershell
Copy-Item -Path "backup_path\config.json" -Destination "$env:APPDATA\.claude-code\"
macOS/Linux:
bash
cp ~/backup/config.json ~/.config/claude-code/
3. Reconfigure Environment Variables
If you used custom environment variables, you'll need to set them up again. Reference: Claude Code Environment Variable Configuration
Related Articles
- How to Uninstall Claude Code - Complete uninstallation
- Claude Code Installation Guide - Reinstall Claude Code
- Windows Environment Variable Setup - Configure environment variables
💡 Best Practices
- Regular Cleanup - Recommend cleaning cache and logs monthly
- Backup Configuration - Always backup important configuration files before cleanup
- Complete Exit - Ensure Claude Code is completely closed before cleanup
- Use Scripts - Create automation scripts to simplify the cleanup process
- Troubleshooting - Try cleaning cache first when encountering issues
Need Help?
If you encounter issues after cleanup, feel free to join our Carpool Community for technical support.
Last updated: October 2025
