Git maintain

From laurigates/claude-plugins · View interactive version

Git maintain is an AI agent skill from the GitHub repository laurigates/claude-plugins. Repo maintenance — incremental repack, gc, branch pruning, stash cleanup, fsck. Use when asked to clean up the repo, run git maintenance/gc, delete merged branches, prune stashes, or shrink .git.

How to use this skill

Skill file

When to Use This Skill

| Use this skill when... | Use the alternative when... |

|---|---|

| Running git gc, repacking objects, or shrinking the .git directory | Use git-coworker-check first if other agents may be writing to the same checkout |

| Pruning merged local branches and old stashes | Use git-cli-agentic for read-only branch/stash queries without mutating state |

| Verifying repo integrity with git fsck | Use git-security-checks for secret scanning rather than object integrity |

| Cleaning up a checkout before a long-lived feature branch goes stale | Use git-rebase-patterns to clean up commit history rather than the object store |

Context

Parameters

Parse these parameters from the command (all optional):

Your task

Perform repository maintenance and cleanup based on the flags provided.

Step 1: Check for accidentally committed files

Step 2: Update .gitignore

Step 3: Delete merged branches (if --branches or --all)

Step 4: Clean up redundant stashes (if --stash or --all)

Step 5: Repository optimization (if --prune, --gc, --background, or --all)

Prefer incremental maintenance over gc --aggressive. Modern Git (2.31+)

replaced the blocking, rewrite-everything git gc --aggressive pass with

git maintenance and geometric repacking, which organizes packfiles in

logarithmic layers by object count. Geometric repacking is the default for

manual maintenance in recent Git (2.52+) and avoids the destructive,

time-consuming "all-in-one" repack. Default to it.

# Incremental geometric repack — logarithmic pack layering + on-disk
# multi-pack index; far cheaper than `gc --aggressive`, safe to run often
git repack --geometric=2 -d --write-midx

# Prune unreachable objects older than the default grace window
git prune --expire=2.weeks.ago

# Show size improvement
du -sh .git

For hands-off upkeep (--background), register the repo so Git quietly

pre-fetches, optimizes the commit-graph, and repacks loose objects on a

schedule instead of blocking on a manual pass:

# Register hourly background maintenance (one-time, per repo)
git maintenance start

# Or run the standard task set once, on demand (non-blocking, incremental)
git maintenance run --task=commit-graph --task=incremental-repack --task=loose-objects

Reserve a full git gc for a repo that has genuinely degraded (only with

--gc); skip --aggressive unless a one-off deep repack is explicitly needed:

# Full consolidation — only when --gc is requested and the repo is degraded
git gc

Step 6: Verify repository integrity (if --verify or --all)

git fsck --full --strict

Report any issues found.

Step 7: Final summary

Safe Operations

These operations are safe and non-destructive:

These require user confirmation:

Agentic Optimizations

| Context | Command |

|---------|---------|

| Routine optimize | git repack --geometric=2 -d --write-midx |

| Hands-off upkeep | git maintenance start |

| One-shot incremental pass | git maintenance run --task=incremental-repack --task=commit-graph |

| Integrity check | git fsck --full --strict |

| Size before/after | du -sh .git |

See Also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.