git-safety-guardrails
Skill3 starsChanged 3 months agoMITView on GitHub
Git safety guardrails for AI agents. Read before ANY git operation. Ensures GPG signing is never disabled, editors never launch interactively, and prompts are suppressed. Triggers on any git commit, rebase, merge, or tag operation.
- Deletes or force-pushes
- Commits and pushes
In this repository86 other files it gives its agents.
- AGENTS.mdAGENTS.md
- adrSkill
- adzic-bddSkill
- agent-md-refactorSkill
- agent-muxSkill
- agent-role-impersonatorSkill
- agilquest-reservationsSkill
- ai-text-humanizerSkill
- architecture-decision-recordsSkill
- ast-grepSkill
- atacSkill
- aws-cliSkill
- bart-adversarial-reviewerSkill
- bddSkill
- branch-doctorSkill
- c4-architectureSkill
- c4Skill
- claude-sub-agentSkill
- codemap-config-setupSkill
- codemap-exploreSkill
- codemap-handoffSkill
- codemap-hub-safetySkill
- codemapSkill
- commitSkill
- copilot-sub-agentSkill
- daily-standupSkill
- daily-statusSkill
- debugSkill
- design-thinkingSkill
- doctorSkill
- docx-word-processorSkill
- farley-tddSkill
- forensicsSkill
- gemini-sub-agentSkill
- git-commit-formatterSkill
- git-forensicsSkill
- github-actions-permissionsSkill
- github-cliSkill
- git-repo-discoverySkill
- harness-idpSkill
- humanizeSkill
- iteration-plannerSkill
- jira-issue-managerSkill
- justfile-assistantSkill
- kiro-sub-agentSkill
- lessons-learnedSkill
- lessonsSkill
- lisa-planning-agentSkill
- lovejoy-release-agentSkill
- lsp-code-analysisSkill
- macro-to-microSkill
- marge-product-agentSkill
- meeting-notesSkill
- mermaid-diagram-generatorSkill
- modern-cli-overridesSkill
- native-web-searchSkill
- obsidian-notetakerSkill
- outlook-headlessSkill
- pdf-document-processorSkill
- pi-sub-agentSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 8 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
0
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
- Distinctive: line 14
Check signing is configured:
- Distinctive: line 20
If the GPG key is locked (commit fails with "no secret key"), unlock it:
- Distinctive: line 27
Do NOT work around a locked key by disabling signing.
- Distinctive: line 73
When squash-merging a PR, GitHub squashes all commits on the branch that are not on the base branch — including any inherited history if …
- Distinctive: line 87
If the branch was accidentally cut from a feature branch instead of main, the squash will swallow everything:
- Distinctive: line 98
If a branch was cut from the wrong base and already has commits, cherry-pick the meaningful commits onto a fresh branch from main:
- Distinctive: line 115
If a squash swallowed too much and landed on main:
- Distinctive: line 129
Always force-push main with care — coordinate with the team first.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 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
Git — Agent Safety Guardrails
Before any git operation
1. GPG signing must stay enabled
Never run git config commit.gpgsign false or --no-gpg-sign.
Check signing is configured:
git config --get commit.gpgsign # must be "true"
git config --get user.signingkey # must be non-emptyIf the GPG key is locked (commit fails with "no secret key"), unlock it:
export GPG_TTY=$(tty)
echo "test" | gpg --batch --pinentry-mode loopback -o /dev/null --sign - \
|| echo "⚠️ GPG key locked — ask user to unlock with: gpg --sign /dev/null"Do NOT work around a locked key by disabling signing. Stop and ask.
2. Prevent interactive editors
Set these before any rebase, merge, or commit that might launch an editor:
export GIT_EDITOR=true
export GIT_SEQUENCE_EDITOR=true
export EDITOR=true
export VISUAL=truetrue is the no-op binary — it exits 0 without launching anything.
For interactive rebase, always prepare the todo file and pipe it:
GIT_SEQUENCE_EDITOR="sed -i 's/^pick \(HASH\)/edit \1/'" git rebase -i HEAD~33. Suppress prompts
export GIT_TERMINAL_PROMPT=0
export GIT_ASK_YESNO=false4. Pager safety
export GIT_PAGER=cat # or leave as delta if configuredQuick pre-flight
Copy-paste before a git-heavy session:
export GPG_TTY=$(tty)
export GIT_EDITOR=true GIT_SEQUENCE_EDITOR=true EDITOR=true VISUAL=true
export GIT_TERMINAL_PROMPT=0 GIT_ASK_YESNO=falseSquash merge gotcha: check the branch base before merging
When squash-merging a PR, GitHub squashes all commits on the branch that are not on the base branch — including any inherited history if the branch was cut from the wrong point.
Before every squash merge, verify the diff is only what you intend:
# Three-dot diff = only what this branch uniquely adds
git diff origin/main...HEAD --stat
# Count of commits that will be squashed
git log --oneline origin/main..HEAD | wc -lIf the branch was accidentally cut from a feature branch instead of main,
the squash will swallow everything:
# WRONG — feature-branch cut from another feature branch
git checkout -b ci/my-change some-feature-branch # ← inherits 30 commits
# RIGHT — always cut from the actual base
git checkout -b ci/my-change origin/mainIf a branch was cut from the wrong base and already has commits, cherry-pick
the meaningful commits onto a fresh branch from main:
# Identify the commits that actually matter
git log --oneline origin/main..HEAD # these are the commits to cherry-pick
# Create clean branch from correct base
git checkout -b ci/my-change-clean origin/main
git cherry-pick <sha1> <sha2> # only the real work
# Verify
git diff origin/main...HEAD --stat # should be minimal and correctReverting a bad squash merge from main
If a squash swallowed too much and landed on main:
# Identify the bad commit
git log --oneline origin/main -3
# Reset locally
git checkout main && git pull
git reset --hard <sha-before-bad-commit>
# Force push (confirm no one else has pulled the bad state)
git push origin main --forceAlways force-push main with care — coordinate with the team first.
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.

