{"slug": "claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it", "title": "Claude Code Ate My Storage, So I Asked Claude Code to Fix It", "summary": "A developer found that Anthropic's Claude Code AI assistant consumed significant storage space on Windows. After running out of disk space, the developer asked Claude Code to generate a cleanup script, which claimed it could reclaim 15GB but only freed about 1GB. The script's misleading output highlights the gap between AI-generated promises and actual results.", "body_md": "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.\"\n\nI 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.\n\nBut it has also helped me finish my storage quicker.\n\nAt 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.\n\nSo, naturally, my first instinct was to ask Claude Code how to fix the problem it had helped create.\n\nI asked it to give me a script that could clear about 15GB of storage.\n\nIt gave me one.\n\n```\n# --- CLAUDE CODE MASTER CLEANUP & OPTIMIZATION ---\n\n# 1. AUTO-FIX: Set 2GB Node Memory Limit (Prevents 15GB Pagefile Bloat)\n$varName = \"NODE_OPTIONS\"\n$varValue = \"--max-old-space-size=2048\"\n$currentValue = [Environment]::GetEnvironmentVariable($varName, \"User\")\n\nWrite-Host \"⚙️  Optimizing system memory limits...\" -ForegroundColor Cyan\nif ($currentValue -like \"*$varValue*\") {\n    Write-Host \"   - ✅ Memory limit is already correctly configured.\" -ForegroundColor Green\n} else {\n    $newValue = if ($currentValue) { \"$currentValue $varValue\" } else { $varValue }\n    [Environment]::SetEnvironmentVariable($varName, $newValue, \"User\")\n    Write-Host \"   - 🛠 Applied 2GB limit to Windows User Variables.\" -ForegroundColor Yellow\n}\n\n# 2. KILL LEAKING PROCESSES (Releases locked RAM/Pagefile)\nWrite-Host \"`n🛑 Terminating orphaned Claude & MCP processes...\" -ForegroundColor Yellow\n$procs = Get-Process -Name \"claude\", \"node\" -ErrorAction SilentlyContinue | \n         Where-Object { $_.Path -match \"anthropic\" -or $_.CommandLine -match \"mcp\" }\nif ($procs) {\n    $procs | Stop-Process -Force\n    Write-Host \"   - Closed $($procs.Count) ghost processes.\" -ForegroundColor Green\n}\n\n# 3. GLOBAL CACHE CLEANUP\n$claudePath = \"$HOME\\.claude\"\nif (Test-Path $claudePath) {\n    Write-Host \"`n🧹 Wiping global Claude cache (Logs, History, Temporary files)...\" -ForegroundColor Cyan\n    $folders = \"debug\", \"projects\", \"file-history\", \"image-cache\", \"shell-snapshots\", \"todos\", \"plans\"\n    foreach ($folder in $folders) {\n        $subDir = Join-Path $claudePath $folder\n        if (Test-Path $subDir) { \n            Remove-Item -Path \"$subDir\\*\" -Recurse -Force -ErrorAction SilentlyContinue \n        }\n    }\n}\n\n# 4. DEEP SCAN: Hidden Worktrees & Project Memory\n$searchRoot = \"C:\\code\" # <--- Change this to your main folder if different\nWrite-Host \"`n🔍 Deep scanning $searchRoot for hidden .claude folders...\" -ForegroundColor Cyan\n$worktrees = Get-ChildItem -Path $searchRoot -Include \"worktrees\" -Recurse -Hidden -ErrorAction SilentlyContinue | \n             Where-Object { $_.FullName -match \"\\.claude\\\\worktrees\" }\n\nif ($worktrees) {\n    $worktrees | ForEach-Object {\n        Write-Host \"   - Removing: $($_.FullName)\" -ForegroundColor Gray\n        Remove-Item -Path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue\n    }\n} else {\n    Write-Host \"   - No hidden worktrees found.\" -ForegroundColor Gray\n}\n\n# 5. FINAL SPACE AUDIT\n$drive = Get-PSDrive C\n$freeGB = [math]::Round($drive.Free / 1GB, 2)\nWrite-Host \"`n✨ CLEANUP COMPLETE!\" -ForegroundColor Green\nWrite-Host \"📊 Current Free Space: $freeGB GB\" -ForegroundColor White\nWrite-Host \"🚀 IMPORTANT: RESTART YOUR PC NOW to shrink the Pagefile and reclaim the full 15GB.\" -ForegroundColor Magenta\n```\n\nNotice section 5: it prints `reclaim the full 15GB`\n\nas fixed text. It never measured anything. That one line is the whole reason the numbers never added up.\n\nI ran the script, and in the terminal it showed that around 15GB would be restored after restarting my PC.\n\nI restarted.\n\nI got back about 1GB.\n\nSometimes it was even just a few hundred MBs.\n\nI 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.\n\nAt first, I thought Claude had given me a bad script.\n\nBut then I looked at my original prompt.\n\nI had asked it to create a script that would clear 15GB every time I ran it.\n\nThat was the mistake.\n\nA 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.\n\nSo that part was not really Claude's fault. It was mine.\n\nMy prompt should have been something like:\n\nCheck 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.\n\nThat would have made more sense than telling it, \"Give me back 15GB.\"\n\nI 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.\n\nI also ran `npm cache clean --force`\n\n, 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-downloading later. Same lesson as before: clearing caches feels productive but mostly costs you data when everything downloads again.\n\nI deleted ZIP files, old downloads, unused folders, extensions and other things I thought I no longer needed.\n\nStill, the storage situation did not improve as much as I expected.\n\nSo today, I decided to put on my man pants and properly investigate the monster I had created.\n\nI 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.\n\n```\n# --- CLAUDE CODE MASTER CLEANUP & OPTIMIZATION (v2) ---\n\n# 0. MEASURE BEFORE — so we can report what we actually freed\n$beforeGB = [math]::Round((Get-PSDrive C).Free / 1GB, 2)\nWrite-Host \"📊 Free space before cleanup: $beforeGB GB\" -ForegroundColor White\n\n# 1. AUTO-FIX: Set 2GB Node Memory Limit (caps FUTURE Node memory growth)\n$varName = \"NODE_OPTIONS\"\n$varValue = \"--max-old-space-size=2048\"\n$currentValue = [Environment]::GetEnvironmentVariable($varName, \"User\")\n\nWrite-Host \"`n⚙️  Optimizing Node memory limit (affects future sessions)...\" -ForegroundColor Cyan\nif ($currentValue -like \"*$varValue*\") {\n    Write-Host \"   - ✅ Memory limit already configured.\" -ForegroundColor Green\n} else {\n    $newValue = if ($currentValue) { \"$currentValue $varValue\" } else { $varValue }\n    [Environment]::SetEnvironmentVariable($varName, $newValue, \"User\")\n    Write-Host \"   - 🛠 Applied 2GB cap to Windows User Variables.\" -ForegroundColor Yellow\n}\n\n# 2. KILL LEAKING PROCESSES\nWrite-Host \"`n🛑 Terminating orphaned Claude & MCP processes...\" -ForegroundColor Yellow\n$procs = Get-Process -Name \"claude\", \"node\" -ErrorAction SilentlyContinue |\n         Where-Object { $_.Path -match \"anthropic\" -or $_.CommandLine -match \"mcp\" }\nif ($procs) {\n    $procs | Stop-Process -Force\n    Write-Host \"   - Closed $($procs.Count) ghost processes.\" -ForegroundColor Green\n} else {\n    Write-Host \"   - No orphaned processes found.\" -ForegroundColor Gray\n}\n\n# 3. GLOBAL CACHE CLEANUP\n$claudePath = \"$HOME\\.claude\"\nif (Test-Path $claudePath) {\n    Write-Host \"`n🧹 Wiping global Claude cache (Logs, History, Temp files)...\" -ForegroundColor Cyan\n    $folders = \"debug\", \"projects\", \"file-history\", \"image-cache\", \"shell-snapshots\", \"todos\", \"plans\"\n    foreach ($folder in $folders) {\n        $subDir = Join-Path $claudePath $folder\n        if (Test-Path $subDir) {\n            Remove-Item -Path \"$subDir\\*\" -Recurse -Force -ErrorAction SilentlyContinue\n        }\n    }\n}\n\n# 4. DEEP SCAN: Hidden Worktrees\n$searchRoot = \"C:\\code\"   # <--- change to your main code folder if different\nWrite-Host \"`n🔍 Deep scanning $searchRoot for hidden .claude worktrees...\" -ForegroundColor Cyan\n$worktrees = Get-ChildItem -Path $searchRoot -Include \"worktrees\" -Recurse -Hidden -ErrorAction SilentlyContinue |\n             Where-Object { $_.FullName -match \"\\.claude\\\\worktrees\" }\n\nif ($worktrees) {\n    $worktrees | ForEach-Object {\n        Write-Host \"   - Removing: $($_.FullName)\" -ForegroundColor Gray\n        Remove-Item -Path $_.FullName -Recurse -Force -ErrorAction SilentlyContinue\n    }\n} else {\n    Write-Host \"   - No hidden worktrees found.\" -ForegroundColor Gray\n}\n\n# 5. FINAL SPACE AUDIT — report the REAL delta, not a guess\n$afterGB = [math]::Round((Get-PSDrive C).Free / 1GB, 2)\n$reclaimedGB = [math]::Round($afterGB - $beforeGB, 2)\n\nWrite-Host \"`n✨ CLEANUP COMPLETE!\" -ForegroundColor Green\nWrite-Host \"📊 Before: $beforeGB GB  |  After: $afterGB GB\" -ForegroundColor White\nWrite-Host \"♻️  Actually reclaimed: $reclaimedGB GB\" -ForegroundColor White\n\nif ($reclaimedGB -lt 1) {\n    Write-Host \"ℹ️  Small gain is normal — most space here is cache/logs.\" -ForegroundColor Gray\n    Write-Host \"    If your pagefile is system-managed and large, a reboot may free more.\" -ForegroundColor Gray\n}\n```\n\nThe 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.\n\nSo yey, progress.\n\nAt this point, I may still need to increase my storage or finally accept that this PC has served its time and purpose.\n\nUnless someone here knows a safe way to clear Windows storage without deleting important project files or forcing my apps to download everything again.\n\nHas anyone else had their storage disappear while using Claude Code or other AI development tools?", "url": "https://wpnews.pro/news/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it", "canonical_source": "https://dev.to/sitatiwritescode/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it-1o38", "published_at": "2026-06-24 12:00:00+00:00", "updated_at": "2026-06-24 12:09:27.244981+00:00", "lang": "en", "topics": ["artificial-intelligence", "developer-tools", "large-language-models"], "entities": ["Anthropic", "Claude Code", "Windows"], "alternates": {"html": "https://wpnews.pro/news/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it", "markdown": "https://wpnews.pro/news/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it.md", "text": "https://wpnews.pro/news/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it.txt", "jsonld": "https://wpnews.pro/news/claude-code-ate-my-storage-so-i-asked-claude-code-to-fix-it.jsonld"}}