borghei/Claude-Skills / engineering/git-guardrails
git-guardrails
VerifiedInstall a hook that blocks destructive git commands before an AI agent runs them. Use when an agent force-pushed or ran reset --hard, when adding git safety hooks, or when protecting main from agent pushes.
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 13.9 KB |
| assets/git_guardrails_hook.pyexecutable | script | 17.2 KB |
| assets/pre-pushexecutable | script | 2.5 KB |
| assets/pre-rebaseexecutable | script | 1.2 KB |
| assets/sample_command_corpus.json | config | 8.5 KB |
| assets/sample_guardrail_policy.json | config | 236 B |
| references/hook-mechanics.md | markdown | 7.4 KB |
| references/rule-catalog.md | markdown | 9.3 KB |
| scripts/guardrail_test.pyexecutable | script | 8.9 KB |
| scripts/install_guardrails.pyexecutable | script | 10.3 KB |
assets/pre-rebase
View on GitHub#!/usr/bin/env bash
# git-guardrails pre-rebase hook (plain git, works without Claude Code).
#
# git calls this with: $1 = upstream, $2 = branch being rebased (empty means
# the current branch). Rebasing a protected branch rewrites history other
# people have pulled, so it is refused. Exit 0 continues, exit 1 aborts.
# Protected branches come from `git config --get-all guardrails.protected`.
set -euo pipefail
branch="${2:-}"
if [ -z "$branch" ]; then
branch="$(git symbolic-ref --short -q HEAD || true)"
fi
[ -z "$branch" ] && exit 0 # detached HEAD: nothing shared to protect
protected_patterns=()
while IFS= read -r pattern; do
[ -n "$pattern" ] && protected_patterns+=("$pattern")
done < <(git config --get-all guardrails.protected || true)
if [ "${#protected_patterns[@]}" -eq 0 ]; then
protected_patterns=("main" "master" "develop" "production" "release/*")
fi
for pattern in "${protected_patterns[@]}"; do
# shellcheck disable=SC2053
if [[ "$branch" == $pattern ]]; then
printf 'git-guardrails: refusing to rebase protected branch %s\n' "$branch" >&2
printf ' Rebase your feature branch onto it instead: git rebase %s\n' "$branch" >&2
exit 1
fi
done
exit 0
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |