repo-diet
Skill7 starsChanged 5 days agoMITView on GitHub
Finds why a git repo is heavy or slow to clone (big or deleted files bloating history, committed junk, Git LFS candidates) and plans a safe cleanup. Use when asked why the .git folder is so big, to find large files in history, or shrink the repo.
- Deletes or force-pushes
- Commits and pushes
In this repository71 other files it gives its agents.
- docs/llms.txtllms.txt
- a11y-fixerSkill
- ad-copy-generatorSkill
- agent-guardrailsSkill
- agent-memory-keeperSkill
- ai-slop-detectorSkill
- api-to-sdkSkill
- app-store-optimizerSkill
- architecture-doctorSkill
- brand-voice-guideSkill
- bug-detectiveSkill
- bus-factorSkill
- changelog-from-gitSkill
- codebase-explainerSkill
- codebase-time-machineSkill
- codebase-valuationSkill
- commit-craftSkill
- commit-roastSkill
- competitor-spySkill
- content-repurposerSkill
- copy-paste-detectorSkill
- cost-cutterSkill
- dead-code-funeralSkill
- demo-recorderSkill
- dependency-doctorSkill
- dependency-weigh-inSkill
- dev-wrappedSkill
- dockerize-anythingSkill
- domain-modelerSkill
- durable-agent-workflowsSkill
- e2e-flow-testerSkill
- email-campaign-writerSkill
- env-secrets-guardSkill
- gh-actions-auditorSkill
- github-portfolioSkill
- hook-generatorSkill
- incident-commanderSkill
- influencer-outreachSkill
- instagram-growth-managerSkill
- issue-triageSkill
- landing-page-roasterSkill
- launch-post-writerSkill
- meeting-notes-to-ticketsSkill
- merge-conflict-resolverSkill
- migration-wizardSkill
- name-checkerSkill
- plan-grillerSkill
- pre-commit-setupSkill
- prompt-injection-scannerSkill
- pr-reviewer-proSkill
- readme-glow-upSkill
- repo-cardSkill
- roast-my-githubSkill
- screenshot-to-componentSkill
- seo-blog-writerSkill
- skill-creator-proSkill
- skill-finderSkill
- skills-doctorSkill
- social-analytics-reporterSkill
- social-media-calendarSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 1 is distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 35
Add the missing lines the script printed (node_modules/, .DS_Store, *.pyc, dist/ ...) to .gitignore.
- Very specific: line 41
Check git status and confirm the list with the user before committing.
- Distinctive: line 58
Only with the user's explicit OK, and with git-filter-repo installed (see its INSTALL.md):
- Very specific: line 62
If useful, git filter-repo --analyze writes reports to .git/filter-repo/analysis/.
- Very specific: line 63
Run the agreed command, then run repo_diet.py again and report before and after.
- Very specific: line 70
Run git filter-repo, git lfs migrate import without --no-rewrite, or any force push without the user's explicit OK for that step.
- Very specific: line 71
Use --force on filter-repo, or rewrite a repo that has no backup.
- Very specific: line 72
Commit the .gitignore and git rm --cached changes without showing the file list.
- Very specific: line 75
Treat node_modules size on disk as repo weight.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Repo Diet
A repo is heavy for two different reasons: junk that is committed now, and files that were deleted long ago but still ride along in every clone. The first is a normal commit. The second means rewriting history, which costs every collaborator something. Fix them in that order.
1. Weigh the repo
python3 scripts/repo_diet.py # repo in the current directory
python3 scripts/repo_diet.py -C path/to/repo --top 15
python3 scripts/repo_diet.py --svg diet.svg # also write a 1200x630 card
python3 scripts/repo_diet.py --svg diet.svg --no-credit # same card without the small "made with agent-skills" line
python3 scripts/repo_diet.py --json # every number, for follow-up questions
python3 scripts/repo_diet.py --show-authors # who added each big blob (hidden by default)The script only reads. It never rewrites history, never runs filter-repo and never pushes. It works on a bare or mirror clone too, minus the .gitignore and LFS checks.
History means every object reachable from any ref (git rev-list --objects --all), sized by what it takes in the packs (%(objectsize:disk)), which is roughly what a clone downloads. A blob is deleted when its path is gone from HEAD and old version when the path still exists with other content. Paths under fixtures/ or testdata/ are not called junk.
Exit codes: 0 lean · 1 findings · 2 not a git repository · 3 the SVG could not be written.
2. Explain what you found
Lead with the headline as printed and the card path, if any. Then give the top five blobs with their status and the commit that added them, how much of history is deleted files, each junk category with its size and whether .gitignore covers it, and the LFS candidates. Use only the script's numbers. A 13 MB history with 7% deleted is lean, so say so and stop there.
3. Fix the cheap stuff first (no history rewrite)
For junk committed now, in one normal commit on a branch:
- Add the missing lines the script printed (
node_modules/,.DS_Store,*.pyc,dist/...) to.gitignore. - Untrack what is now ignored, keeping the files on disk:
git ls-files -z -c -i --exclude-standard | xargs -0 git rm --cached -- git rm -r --cached -- web/node_modules # or one root at a time - Check
git statusand confirm the list with the user before committing. Adist/orbuild/that is deployed from the repo (GitHub Pages, a published package) may be there on purpose: ask.
For LFS candidates: git lfs track "*.psd" and commit .gitattributes. That only affects new commits; git lfs migrate import --no-rewrite moves existing files in a new commit, and git lfs migrate import --include="*.psd" --everything rewrites history like step 4.
This makes the next commit lighter. It does not shrink the clone, because the old blobs are still in history.
4. History bloat: plan it, then wait for an explicit OK
Show the git filter-repo commands the script suggested, for example:
git filter-repo --invert-paths --path assets/video.mp4 --path old/dump.sql
git filter-repo --strip-blobs-bigger-than 10M # cut chosen above the largest file in HEADThen spell out the cost before anyone runs them. Every commit hash from the first rewritten commit onward changes, and the tags with them, so every branch and tag needs a force push. Every collaborator has to delete their clone and re-clone; an old clone's next push brings the history back. Open pull requests point at old commits and break, so merge or close them first. The hosting service may keep the old objects alive through refs it locks (refs/pull/*) until its own cleanup runs.
Only with the user's explicit OK, and with git-filter-repo installed (see its INSTALL.md):
- Make a backup with
git clone --mirror <url> backup.git. - Work in a fresh clone (
git clone --no-localfor a local path); filter-repo refuses anything else. Do not add--forceto get around that. - If useful,
git filter-repo --analyzewrites reports to.git/filter-repo/analysis/. - Run the agreed command, then run
repo_diet.pyagain and report before and after. - filter-repo removes
originon purpose. Pushing is a separate yes:git remote add origin <url>thengit push --force --branches --tags --prune origin.
Sources for every figure and flag are in references/sources.md.
Do not
- Run
git filter-repo,git lfs migrate importwithout--no-rewrite, or any force push without the user's explicit OK for that step. - Use
--forceon filter-repo, or rewrite a repo that has no backup. - Commit the
.gitignoreandgit rm --cachedchanges without showing the file list. - Name who committed a big file unless the user asks (
--show-authors). - Hunt for leaked secrets here. Passwords and keys in history are a security job; a diet only weighs files.
- Treat
node_modulessize on disk as repo weight. If it is not committed, it is a dependency question, not a git one.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

