スキル一覧に戻る
stars-end

git-safety-guard

by stars-end

Global DX Skills

0🍴 0📅 2026年1月25日
GitHubで見るManusで実行

SKILL.md


name: git-safety-guard description: | Installs a Git safety guard hook for Claude Code to prevent destructive Git and filesystem commands. Blocks accidental data loss from commands like 'git checkout --', 'git reset --hard', 'git clean -f', 'git push --force', and 'rm -rf'. Use this skill to set up safety rails globally (Claude hook) and per-repo (git hooks) without dirtying repos. tags: [git, safety, setup, hooks, protection] allowed-tools:

  • Bash(git-safety-guard/install.sh:*)

Git Safety Guard

Installs a PreToolUse hook that intercepts and blocks destructive Bash commands.

Usage

Protects the agent across all projects.

git-safety-guard/install.sh --global

2. Install Per-Project

Protects only the current project.

git-safety-guard/install.sh

Note: per-project install only links .git/hooks/* (it does not write .claude/ files into the repo).

What It Blocks

Command PatternWhy It's Dangerous
git checkout -- <files>Discards uncommitted changes permanently
git restore <files>Same as checkout -- (newer syntax)
git reset --hardDestroys all uncommitted changes
git reset --mergeCan lose uncommitted changes
git clean -fRemoves untracked files permanently
git push --forceDestroys remote history
git push -fSame as --force
git branch -DForce-deletes branch without merge check
rm -rf (non-temp paths)Recursive file deletion (except /tmp, /var/tmp, $TMPDIR)
git stash dropPermanently deletes stashed changes
git stash clearDeletes ALL stashed changes

Safety Mechanism

The Claude hook is a Python script (git_safety_guard.py) registered in ~/.claude/settings.json. It runs before every Bash command execution. If a command matches a destructive pattern:

  1. The command is BLOCKED (never runs).
  2. The agent receives a "permissionDecision: deny" response with an explanation.

The repo hooks (pre-push / pre-commit / post-checkout / post-merge) are linked into .git/hooks/ so they do not affect repo cleanliness.

CI-lite Pre-push

The pre-push hook is warn-only by default to avoid blocking pushes due to missing local tooling. To enforce make ci-lite when available, set DX_CI_LITE_STRICT=1 in your shell before pushing.

Important Notes

  • Restart Required: You must restart the agent/session for the hook to take effect after installation.
  • Overrides: If a destructive command is truly needed, the user must run it manually or the agent must ask for explicit permission (though the hook will still block it if the agent tries to run it directly; the agent must guide the user to run it).

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です