I knew AI tools and development work could take up storage, but using Claude Code ran through my space faster than you can say "go."
I started using Claude Code in the terminal in April, and honestly, it has been helpful. It helps me fix bugs faster, understand errors, and move through development quicker.
But it has also helped me finish my storage quicker.
At first, I did not realise how much space I was losing. I just kept working until Windows started reminding me that my storage was almost full every five minutes.
So, naturally, my first instinct was to ask Claude Code how to fix the problem it had helped create.
I asked it to give me a script that could clear about 15GB of storage.
It gave me one.
$varName = "NODE_OPTIONS"
$varValue = "--max-old-space-size=2048"
$currentValue = [Environment]::GetEnvironmentVariable($varName, "User")
Write-Host "⚙️ Optimizing system memory limits..." -ForegroundColor Cyan
if ($currentValue -like "*$varValue*") {
Write-Host " - ✅ Memory limit is already correctly configured." -ForegroundColor Green
} else {
$newValue = if ($currentValue) { "$currentValue $varValue" } else { $varValue }
[Environment]::SetEnvironmentVariable($varName, $newValue, "User")
Write-Host " - 🛠 Applied 2GB limit to Windows User Variables." -ForegroundColor Yellow
}
Write-Host "`n🛑 Terminating orphaned Claude & MCP processes..." -ForegroundColor Yellow
$procs = Get-Process -Name "claude", "node" -ErrorAction SilentlyContinue |
Where-Object { $_.Path -match "anthropic" -or $_.CommandLine -match "mcp" }
if ($procs) {
$procs | Stop-Process -Force
Write-Host " - Closed $($procs.Count) ghost processes." -ForegroundColor Green
}
$claudePath = "$HOME\.claude"
if (Test-Path $claudePath) {
Write-Host "`n🧹 Wiping global Claude cache (Logs, History, Temporary files)..." -ForegroundColor Cyan
$folders = "debug", "projects", "file-history", "image-cache", "shell-snapshots", "todos", "plans"
foreach ($folder in $folders) {
$subDir = Join-Path $claudePath $folder
if (Test-Path $subDir) {
Remove-Item -Path "$subDir\*" -Recurse -Force -ErrorAction SilentlyContinue
}
}
}
$searchRoot = "C:\code" # <--- Change this to your main folder if different
Write-Host "`n🔍 Deep scanning $searchRoot for hidden .claude folders..." -ForegroundColor Cyan
$worktrees = Get-ChildItem -Path $searchRoot -Include "worktrees" -Recurse -Hidden -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match "\.claude\\worktrees" }
if ($worktrees) {
$worktrees | ForEach-Object {
Write-Host " - Removing: $($_.FullName)" -ForegroundColor Gray
Remove-Item -Path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
}
} else {
Write-Host " - No hidden worktrees found." -ForegroundColor Gray
}
$drive = Get-PSDrive C
$freeGB = [math]::Round($drive.Free / 1GB, 2)
Write-Host "`n✨ CLEANUP COMPLETE!" -ForegroundColor Green
Write-Host "📊 Current Free Space: $freeGB GB" -ForegroundColor White
Write-Host "🚀 IMPORTANT: RESTART YOUR PC NOW to shrink the Pagefile and reclaim the full 15GB." -ForegroundColor Magenta
Notice section 5: it prints reclaim the full 15GB
as fixed text. It never measured anything. That one line is the whole reason the numbers never added up.
I ran the script, and in the terminal it showed that around 15GB would be restored after restarting my PC.
I restarted.
I got back about 1GB.
Sometimes it was even just a few hundred MBs.
I ran the script again, and the same thing happened. The terminal would make it look like I was about to recover all this space, but when I checked my actual storage, almost nothing had changed.
At first, I thought Claude had given me a bad script.
But then I looked at my original prompt.
I had asked it to create a script that would clear 15GB every time I ran it.
That was the mistake.
A script cannot clear 15GB when that number was never measured in the first place. The "15GB" was just hardcoded text the script printed every time, no matter what it actually deleted. I was asking it to give me a specific result instead of asking it to first check what was actually taking up space.
So that part was not really Claude's fault. It was mine.
My prompt should have been something like:
Check which folders are using the most storage, identify what can safely be deleted, calculate the real size of those files, and create a script that reports the actual space recovered.
That would have made more sense than telling it, "Give me back 15GB."
I also tried clearing the cache for some of my apps manually, but that created another problem. The apps had to download some of the same information again, which cost me data.
I also ran npm cache clean --force
, thinking it would help. npm politely warned me it had disabled its own protections and that the cache rebuilds itself anyway — so that freed almost nothing and just meant re-down later. Same lesson as before: clearing caches feels productive but mostly costs you data when everything downloads again.
I deleted ZIP files, old downloads, unused folders, extensions and other things I thought I no longer needed.
Still, the storage situation did not improve as much as I expected.
So today, I decided to put on my man pants and properly investigate the monster I had created.
I now have a better script that checks the available storage before and after the cleanup, instead of promising that it will magically recover 15GB every time.
$beforeGB = [math]::Round((Get-PSDrive C).Free / 1GB, 2)
Write-Host "📊 Free space before cleanup: $beforeGB GB" -ForegroundColor White
$varName = "NODE_OPTIONS"
$varValue = "--max-old-space-size=2048"
$currentValue = [Environment]::GetEnvironmentVariable($varName, "User")
Write-Host "`n⚙️ Optimizing Node memory limit (affects future sessions)..." -ForegroundColor Cyan
if ($currentValue -like "*$varValue*") {
Write-Host " - ✅ Memory limit already configured." -ForegroundColor Green
} else {
$newValue = if ($currentValue) { "$currentValue $varValue" } else { $varValue }
[Environment]::SetEnvironmentVariable($varName, $newValue, "User")
Write-Host " - 🛠 Applied 2GB cap to Windows User Variables." -ForegroundColor Yellow
}
Write-Host "`n🛑 Terminating orphaned Claude & MCP processes..." -ForegroundColor Yellow
$procs = Get-Process -Name "claude", "node" -ErrorAction SilentlyContinue |
Where-Object { $_.Path -match "anthropic" -or $_.CommandLine -match "mcp" }
if ($procs) {
$procs | Stop-Process -Force
Write-Host " - Closed $($procs.Count) ghost processes." -ForegroundColor Green
} else {
Write-Host " - No orphaned processes found." -ForegroundColor Gray
}
$claudePath = "$HOME\.claude"
if (Test-Path $claudePath) {
Write-Host "`n🧹 Wiping global Claude cache (Logs, History, Temp files)..." -ForegroundColor Cyan
$folders = "debug", "projects", "file-history", "image-cache", "shell-snapshots", "todos", "plans"
foreach ($folder in $folders) {
$subDir = Join-Path $claudePath $folder
if (Test-Path $subDir) {
Remove-Item -Path "$subDir\*" -Recurse -Force -ErrorAction SilentlyContinue
}
}
}
$searchRoot = "C:\code" # <--- change to your main code folder if different
Write-Host "`n🔍 Deep scanning $searchRoot for hidden .claude worktrees..." -ForegroundColor Cyan
$worktrees = Get-ChildItem -Path $searchRoot -Include "worktrees" -Recurse -Hidden -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match "\.claude\\worktrees" }
if ($worktrees) {
$worktrees | ForEach-Object {
Write-Host " - Removing: $($_.FullName)" -ForegroundColor Gray
Remove-Item -Path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue
}
} else {
Write-Host " - No hidden worktrees found." -ForegroundColor Gray
}
$afterGB = [math]::Round((Get-PSDrive C).Free / 1GB, 2)
$reclaimedGB = [math]::Round($afterGB - $beforeGB, 2)
Write-Host "`n✨ CLEANUP COMPLETE!" -ForegroundColor Green
Write-Host "📊 Before: $beforeGB GB | After: $afterGB GB" -ForegroundColor White
Write-Host "♻️ Actually reclaimed: $reclaimedGB GB" -ForegroundColor White
if ($reclaimedGB -lt 1) {
Write-Host "ℹ️ Small gain is normal — most space here is cache/logs." -ForegroundColor Gray
Write-Host " If your pagefile is system-managed and large, a reboot may free more." -ForegroundColor Gray
}
The difference is small but honest: the new version takes a snapshot before it starts, another at the end, and reports the real difference. No more magic 15GB.
So yey, progress.
At this point, I may still need to increase my storage or finally accept that this PC has served its time and purpose.
Unless someone here knows a safe way to clear Windows storage without deleting important project files or forcing my apps to download everything again.
Has anyone else had their storage disappear while using Claude Code or other AI development tools?