Free up disk space by clearing Git worktree caches with Codex
Codex + shell + Git worktrees
My laptop was almost out of space. Git worktrees let me work on several branches at once, but each checkout can accumulate its own dependencies and build files. One Next.js cache alone was taking up 18.9 GiB.
- I asked Codex to use the terminal to find the biggest folders and explain what they contained.
- It checked Git status and running processes to separate my code and active work from files the tools could recreate.
- I picked what to remove, and Codex cleared those cache and dependency folders.
That recovered 24.7 GiB. The worktrees and uncommitted changes stayed; dependencies in the cleaned folders would need reinstalling. Having an agent investigate the folders first saved me from guessing what was safe to delete.
# Make room, keep the work
Help me recover disk space in the repositories and worktrees I select.
## 01. Look before touching
Measure disk usage. Identify large generated caches and reinstallable dependencies. Check Git status, ignored files, and active processes. Keep source files, local work, credentials, and databases out of the cleanup list.
## 02. Make the plan concrete
Show the exact paths, their sizes, what each contains, and whether a running process uses them. Separate cache cleanup from deleting whole worktrees. Explain what will need reinstalling or rebuilding.
Ask me to approve the exact cleanup targets and any processes you need to stop.
## 03. Clean only the approved targets
Use the narrowest appropriate operation. Never expand a target to its parent directory or delete worktrees just because their caches are large.
## 04. Verify the result
Measure the space recovered. Confirm source files and uncommitted changes are unchanged. Report any stopped processes and what I need to reinstall before running a project again.