Skip to content
Git Hygiene·4 min·English

The disk rescue prompt

Out of space on your computer and deleting files does not help? A ready prompt for Claude Code that scans your machine, finds a runaway git repo eating your disk, and fixes it only with your approval.

The disk rescue prompt

What you get

One prompt to paste into Claude Code: a full report on every git repo on your machine, runaway repo detection, and a safe fix with your approval

Who it is for

For anyone whose disk fills up "for no reason", and anyone who ever ran git init in the wrong folder, or had a tool do it for them.

1. What happened to me

I ran out of space on my Mac. I deleted movies, deleted apps, and nothing came back. I asked Claude Code to find what was eating my disk, and the answer was one hidden folder: a git repo on my home directory.

  • At some point git init got run on my home directory. From that moment, every file saved on the machine also went into git's history.
  • And here is the annoying part: even when you delete a file, the history keeps it. That is why I kept deleting and the disk stayed full.
  • You cannot see this in Finder: the .git folder is hidden. The disk fills up and nothing points to the cause.

2. What the prompt does

  • Scans the machine and finds every git repo, including hidden ones.
  • Measures how big each one is and sorts them from largest to smallest.
  • Identifies a runaway repo: one created by mistake on a broad folder that swallows files that do not belong to one project.
  • Proposes a fix for every problem, and does not delete anything without your explicit approval for each action separately.
  • A repo with unsaved work or unpushed commits: it does not touch it at all, only reports it.

3. The prompt

Open a terminal, run claude, and paste this whole block:

Copy box
I want to check whether git is eating disk space on my machine by mistake. Work in stages, and do not delete anything without my explicit approval for each action separately.

Stage 1 - detection:
1. Check whether my home directory sits inside a git repo:
   git -C ~ rev-parse --show-toplevel
2. Find .git folders up to depth 3 from the home directory, excluding Library, node_modules, and .Trash:
   find ~ -maxdepth 3 -name ".git" -not -path "*/Library/*" -not -path "*/node_modules/*" -not -path "*/.Trash/*"
3. Measure each result with du -sh and sort from largest to smallest.

Stage 2 - diagnosis for every repo over 500MB, and every repo sitting on a broad folder (home, Desktop, Documents, Downloads):
- How many files it tracks: git ls-files | wc -l
- Whether it has a remote: git remote -v
- Whether there are unsaved changes or unpushed commits
- What the heaviest objects in its history are

Stage 3 - report:
Show a table: path, .git size, file count, remote, diagnosis.
Flag every repo that is likely a "runaway repo": one created by mistake on a broad folder that swallows files that do not belong to one project.

Stage 4 - fix, only after my approval for each action:
- A runaway repo with no remote and no important history: back up first (tar of the .git folder only), then delete only the .git folder. The files themselves are not deleted.
- A real repo that has bloated: add a .gitignore for heavy folders, run git gc, and if the history itself is heavy, propose a clean clone from the remote.
- A repo with unsaved changes or unpushed commits: do not touch it. Report to me and stop.

At the end, give one line: how much space was freed, and what to check again in a month.

4. What you get back

  • A table of every repo on your machine with the real size of its .git folder, and a flag on a runaway repo if there is one.
  • Fix suggestions one at a time. Nothing gets deleted automatically.
  • Before deleting a runaway repo, a tar backup is saved, and only the .git folder gets deleted. Your files stay in place.

5. How not to fall into this again

  • Before git init, check where you are: pwd. The command applies to the current folder, not the folder you thought you were in.
  • Want git on your home directory on purpose, for example for dotfiles? Work with a .gitignore that excludes everything and adds back only what you need.
  • Once a month: run the prompt again. Two minutes, no surprises.

How to use this now

Your disk should not fill up quietly. One prompt in Claude Code gives you a full report, and a fix that happens only with your approval.

AI-native products, workshops, and automations. Built from everywhere.

© 2026 Daniel Goldman