git-safety
Prevents accidental data loss from destructive git operations.
Invoke as: /git-safety
Trigger: git push, force push, git reset, git clean, any destructive git operation.
These commands require explicit user permission before running:
| Command | Risk |
|---|---|
git push --force / -f |
Overwrites remote history |
git push --force-with-lease |
Overwrites remote history |
git reset --hard |
Discards all uncommitted changes |
git clean -fd |
Permanently deletes untracked files |
git checkout -- . |
Discards all working tree changes |
Safe alternatives
Section titled “Safe alternatives”Instead of git reset --hard: use git stash to save changes, then git stash pop to restore.
Instead of force push: use git pull --rebase then a normal push. If histories are intentionally diverged, ask the user how to proceed.
Instead of git clean -fd: use git stash --include-untracked or review with git status first.
Standard workflow
Section titled “Standard workflow”git pullbefore making changesgit checkout -b <type>/<description>to create a branchgit add <specific-files>— nevergit add -Acarelesslygit commit -s(DCO required)git pull --rebaseagain before pushgit push -u origin <branch>— no force flags- Open a PR — never push directly to the default branch