bundles/github/skills/git-safety/SKILL.md
Guards day-to-day git work in an existing repository: blocks secrets from entering a commit, gates destructive git operations before they run, installs ignore rules and pre-commit hooks, and drives the rotate-first response when a credential has already leaked.
npx skillsauth add shipshitdev/library git-safetyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Two guards, one repository you already work in every day:
Both are recurring. They run at commit time and at push time, on every branch, forever. A one-time audit of a whole repository before it goes public is a different moment — see Related.
Inputs:
scan, guard, prevent, clean, or fullclean: the leaked path or secret string, and the refs it touchesOutputs:
Creates/Modifies:
scan and guard: no file changesprevent: .gitignore, .env.example, and hook filesclean: rewritten git history, only after explicit confirmationExternal Side Effects:
clean modeConfirmation Required:
reset --hard, clean -fdx, or branch/tag deletionDelegates To:
open-source-checker before publishing a private repositorysecurity-audit for broader application-security reviewRemoving a secret from git history does not make it safe. Once pushed:
Rotate the credential at its source before touching history. History rewriting is cleanup, never containment. The bound: the old value is rejected by the issuing system.
| Mode | Moment | Ends when |
|------|--------|-----------|
| scan | Before committing | Every staged file and added line is cleared or flagged |
| guard | Before a destructive command | Blast radius stated, backup made, operator confirmed |
| prevent | Once per repo, then on drift | Ignore rules and hook block a known-bad test commit |
| clean | After a confirmed leak, post-rotation | Secret absent from every ref, collaborators notified |
| full | New repo onboarding | scan → prevent complete |
scan — staged guardScope is the working tree and the staged diff, not history.
# Files about to be committed
git diff --cached --name-only
# Sensitive filenames among them
git diff --cached --name-only | grep -iE '(^|/)\.env($|\.)|\.(pem|key|p12|pfx|secret)$|credentials|service-account|id_rsa|id_ed25519|\.npmrc$|kubeconfig'
# Secret-shaped values in added lines only
git diff --cached -U0 | grep -E '^\+' | grep -iE '(api[_-]?key|secret[_-]?key|client[_-]?secret|access[_-]?token|auth[_-]?token|password)[^a-z]{0,4}[=:][^=:]{8,}'
# Untracked files sitting in the tree that must never be added
git status --porcelain --untracked-files=all | grep -E '^\?\?' | grep -iE '\.env|\.pem$|\.key$|credentials|secrets\.'
Verdict per finding: block (real credential), allow (placeholder, fixture, or example), or ask when the value cannot be classified from the diff alone. Report the file and line for each block. Ends when every staged path carries a verdict.
guard — destructive operation gateAny of these rewrites or discards work that git cannot recover for a collaborator:
| Command | Discards |
|---------|----------|
| git push --force / --force-with-lease | Remote commits others may hold |
| git filter-repo, bfg | Every commit hash in the repository |
| git reset --hard | Uncommitted work in the tree and index |
| git clean -fdx | Untracked files, including local .env |
| git checkout -- <path> | Uncommitted edits to that path |
| git branch -D, git push origin --delete | Unmerged commits on that ref |
| git rebase on a pushed branch | Published commits under collaborators |
Before running one:
git clone --mirror . ../repo-backup-$(date +%Y%m%d) for any
history rewrite; git stash -u before a reset --hard or clean -fdx.--force-with-lease over --force,
git revert over reset --hard on a pushed branch, git stash over
checkout --.Ends when the operator confirms against a stated blast radius, or the reversible alternative is used instead.
prevent — make the guard automaticAdd the ignore rules, write the pre-commit hook, and create .env.example.
Patterns, the full hook script, and git secrets setup are in
references/full-guide.md.
Ends when a deliberate test commit of a dummy .env is rejected by the hook.
clean — rewrite history after a leakRuns only after rotation is confirmed, and only inside the guard gate above.
git clone --mirror . ../repo-backup-$(date +%Y%m%d)
git filter-repo --path .env --invert-paths
git push origin --force --all && git push origin --force --tags
Verify:
git log --all --full-history -- .env # empty
git log -p --all -S '<rotated-value>' # empty
Ends when both verifications return empty and every collaborator has re-cloned.
A credential is in a pushed commit:
clean to strip it from history.guard gate.prevent so the same file cannot be staged again.open-source-checker — the one-time audit before a private repository is
published: license and attribution, secrets across the entire history,
internal hostnames and employee references. Run it once, at the publish
decision; run git-safety at every commit thereafter.security-audit — application-level vulnerability review, not git state.Full sensitive-file patterns, the complete pre-commit hook script, .gitignore
template, git secrets setup, BFG alternative, and platform notes:
references/full-guide.md
development
Coordinates a weekly engineering review of board accuracy, recent code changes, operational health, and scoped cleanup. Use for a recurring repository health review or a review of the last several days.
testing
Audits project board configuration and prepares explicitly requested setup, copy, or normalization changes while preserving the existing workflow and provider boundaries. Use when inspecting a board's fields, columns, scope, or configuration.
testing
Reconciles a project board with current work and delivery evidence, reports incomplete coverage and metadata gaps, and applies only approved provider-supported field changes. Use when auditing board drift, reviewing blocked work, or assessing upcoming delivery.
development
Walk through how a subsystem works. Use for "how does X work", code walkthroughs before changing something, and placement or ownership questions. Explains architecture, runtime flow, and onboarding mental models. Can critique architecture. Use why for motivation.