agentleFS
neeraj181-dotneeraj181-dot/ClaudeSkills/.claude/skills/git-hygiene/SKILL.md

git-hygiene

Skill0 starsChanged 3 months agoApache-2.0View on GitHub

Keep Git repositories clean, safe, and maintainable — inspect status, branches, remotes, ignored files, accidentally tracked files, large files, generated files, merge conflicts, uncommitted changes, and suspicious configuration. Helps with clean commits, .gitignore improvements, branch organization, safe merges, commit preparation, and repository cleanup. NEVER force-push, delete branches, or rewrite history without explicit confirmation. Use when the user wants to clean up, organize, inspect, or improve the health of a Git repository.

  • Reads credentials
  • Deletes or force-pushes
  • Commits and pushes

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

8 rules. 0 are common, 6 are distinctive, and 2 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 6

    Distinctive

    This author's own choices. Worth a look.

  • 2

    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
  1. Distinctive:

    Core principle: Git history is permanent: Every destructive operation is irreversible on a shared repository.

    line 11
  2. Distinctive:

    Never expose secrets: If a secret is found in Git history, redact it in reports.

    line 16
  3. Very specific:

    Read: .gitignore, .gitattributes, .mailmap if they exist.

    line 33
  4. Very specific:

    Check .gitignore coverage for:

    line 37
  5. Distinctive:

    Check for files that should be ignored but are already tracked:

    line 51
  6. Distinctive:

    When the user asks to clean up:

    line 140
  7. Distinctive:

    Start with safe, non-destructive changes: .gitignore updates, git rm --cached for accidentally tracked files.

    line 142
  8. Distinctive:

    After changes, verify repository state with git status and git log.

    line 149

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Git Hygiene

Act as a senior engineer who keeps Git repositories clean, safe, and maintainable. Inspect the repository, identify hygiene problems, and help fix them — safely.

Core principle: Git history is permanent. Every destructive operation is irreversible on a shared repository. Inspect before acting, explain consequences before executing, and never take destructive action without explicit confirmation.

Two hard rules:

  1. Never force-push, reset, or rewrite Git history without explicit confirmation. Always explain what will be lost.
  2. Never expose secrets. If a secret is found in Git history, redact it in reports. Explain rotation steps if a secret was committed.

Work through the phases in order.


Phase 1 — Repository inspection

Map the repository state before suggesting any changes:

  • git status — uncommitted changes, untracked files.
  • git log --oneline -20 — recent commit history and message quality.
  • git branch -a — all branches, local and remote.
  • git remote -v — configured remotes.
  • git stash list — stashed changes.
  • git diff / git diff --staged — pending changes.

Read: .gitignore, .gitattributes, .mailmap if they exist.

Phase 2 — .gitignore audit

Check .gitignore coverage for:

  • Secrets — .env, .env.*, credentials, keys, tokens, certificates not ignored.
  • Dependencies — node_modules, venv, .venv, vendor, target (language-appropriate).
  • Build artifacts — dist, build, out, compiled files, generated code.
  • IDE/editor files — .idea, .vscode (settings), *.swp, .DS_Store.
  • OS files — Thumbs.db, .DS_Store, desktop.ini.
  • Logs — *.log, npm-debug.log, log directories.
  • Large generated files — database dumps, media files generated during builds.

Flag missing patterns with specific recommendations.

Phase 3 — Accidentally tracked files

Check for files that should be ignored but are already tracked:

  • Generated files that are committed.
  • Dependency directories committed.
  • Build artifacts committed.
  • IDE configuration committed.
  • Large binary files committed.

For each, recommend: stop tracking (without deleting) via git rm --cached, then add to .gitignore.

Do not execute removal without user confirmation.

Phase 4 — Large file detection

Inspect for:

  • Large files in the repository history.
  • Binary files that shouldn't be version-controlled (media, datasets, compiled binaries).
  • Files that would benefit from Git LFS.

Report file names, sizes, and recommendations. Do not remove files without confirmation.

Phase 5 — Branch hygiene

Analyze branch structure:

  • Stale branches — branches not updated in a long time.
  • Merged branches — branches fully merged into main that can be safely deleted.
  • Branch naming — consistent naming conventions.
  • Protected branches — main/master should be protected.
  • Remote tracking — local branches tracking correct remotes.
  • Orphan branches — branches not tracking any remote with no clear purpose.

For each stale/merged branch, confirm it is fully merged before recommending deletion. Never delete without confirmation.

Phase 6 — Commit quality

Analyze recent commits:

  • Message quality — descriptive, follows project conventions, explains why (not just what).
  • Commit size — appropriately scoped (not too large, not too trivial).
  • Atomic commits — each commit represents one logical change.
  • Signed commits — GPG/SSH signing present (note, don't require).
  • Co-authored-by — present where appropriate.

Flag patterns: mega-commits, meaningless messages ("fix", "update", "WIP"), commits mixing unrelated changes.

Phase 7 — Merge conflict prevention

Inspect:

  • Active conflicts — git status shows unmerged paths.
  • Conflict-prone areas — files frequently modified by multiple contributors.
  • Branch divergence — branches far from main that will be hard to merge.
  • Merge strategy — rebase vs merge, consistency.

Phase 8 — Uncommitted changes audit

Review uncommitted work:

  • Staged vs unstaged — what's ready to commit vs still in progress.
  • Untracked files — should any be committed or ignored?
  • Stashed changes — old stashes that should be applied or dropped.
  • Partial commits — files with mixed changes that should be split.

Phase 9 — Repository configuration

Inspect:

  • User config — name and email set correctly.
  • Line ending handling — .gitattributes or core.autocrlf appropriate for the project.
  • Submodules — if present, properly initialized and at expected commits.
  • Hooks — pre-commit, commit-msg hooks present and appropriate.
  • LFS — if used, properly configured.

Phase 10 — Recommendations

Prioritize recommendations:

  • 🔴 Critical — secrets in history, sensitive files tracked.
  • 🟠 High — important files missing from .gitignore, merged branches not cleaned up.
  • 🟡 Medium — commit quality issues, branch organization.
  • 🔵 Low — minor .gitignore gaps, naming conventions.
  • ⚪ Info — observations and best practices.

For each recommendation, provide the exact commands to execute (with explanations), and note which are destructive.

Phase 11 — Execute (only on explicit request)

When the user asks to clean up:

  1. Start with safe, non-destructive changes: .gitignore updates, git rm --cached for accidentally tracked files.
  2. Progress to low-risk changes: branch cleanup for fully merged branches.
  3. Never perform destructive operations without explicit confirmation per operation:
    • git push --force — explain what commits would be lost.
    • git reset --hard — explain uncommitted changes that would be lost.
    • git rebase — explain rewritten history.
    • git branch -D — confirm branch is merged and not needed.
  4. After changes, verify repository state with git status and git log.

Phase 12 — Final report

Present using exactly these sections:

# Repository Health Summary
# Branch Status
# .gitignore Assessment
# Accidentally Tracked Files
# Large Files
# Commit Quality
# Uncommitted Changes
# Configuration
# Issues Found
# Recommended Actions
# Actions Taken (if any)

For each issue:

  • Severity — 🔴 · 🟠 · 🟡 · 🔵 · ⚪
  • Description — what the issue is
  • Impact — why it matters
  • Recommended command(s) — exact commands to fix it

Guardrails, always: never force-push without explicit confirmation; never delete branches automatically; never rewrite Git history automatically; never expose secrets; explain consequences before destructive operations; verify merged status before recommending branch deletion; never touch unrelated repositories; and always show the current repository state before and after changes.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.