Skills for Real Engineers. Straight from my .agents directory.
git-guardrails-claude-code
Agent skill fromvinvcn/mattpocock-skills-zh-CN
设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。
How to install git-guardrails-claude-code
npx skills add vinvcn/mattpocock-skills-zh-CN# or add only this skill to Claude Code: copy the folder
skills/misc/git-guardrails-claude-code/
# into
~/.claude/skills/git-guardrails-claude-code/ (all projects)
.claude/skills/git-guardrails-claude-code/ (one project)
1# 设置 Git Guardrails23设置一个 PreToolUse hook,在 Claude 执行危险 git commands 前拦截并阻止它们。45## 会被阻止的命令67- `git push`(包括 `--force` 在内的所有 variants)8- `git reset --hard`9- `git clean -f` / `git clean -fd`10- `git branch -D`11- `git checkout .` / `git restore .`1213被阻止时,Claude 会看到一条 message,说明它无权访问这些 commands。1415## 步骤1617### 1. 询问安装范围1819询问用户:只为**当前 project** 安装(`.claude/settings.json`),还是为**所有 projects** 安装(`~/.claude/settings.json`)?2021### 2. 复制 hook 脚本2223bundled script 位于:[scripts/block-dangerous-git.sh](scripts/block-dangerous-git.sh)2425根据 scope 复制到目标位置:2627- **Project**: `.claude/hooks/block-dangerous-git.sh`28- **Global**: `~/.claude/hooks/block-dangerous-git.sh`2930用 `chmod +x` 让它可执行。3132### 3. 把 hook 加入 settings3334添加到对应 settings file:3536**Project** (`.claude/settings.json`):3738```json39{40 "hooks": {41 "PreToolUse": [42 {43 "matcher": "Bash",44 "hooks": [45 {46 "type": "command",47 "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"48 }49 ]50 }51 ]52 }53}54```5556**Global** (`~/.claude/settings.json`):5758```json59{60 "hooks": {61 "PreToolUse": [62 {63 "matcher": "Bash",64 "hooks": [65 {66 "type": "command",67 "command": "~/.claude/hooks/block-dangerous-git.sh"68 }69 ]70 }71 ]72 }73}74```7576如果 settings file 已存在,把 hook merge 到现有 `hooks.PreToolUse` array 中,不要覆盖其他 settings。7778### 4. 询问是否定制7980询问用户是否要在 blocked list 中添加或移除 patterns。相应编辑复制后的 script。8182### 5. 验证8384运行快速测试:85…
Excerpt shown under the repository's MIT license.
More skills in mattpocock-skills-zh-CN
Similar skill repositories
An agentic skills framework & software development methodology that works.
A single CLAUDE.md file to improve Claude Code behavior, derived from Andrej Karpathy's observations on LLM coding pitfalls.
Public repository for Agent Skills
Makes your AI agent think like the laziest senior dev in the room. The best code is the code you never wrote.
Persistent Context Across Sessions for Every Agent – Captures everything your agent does during sessions, compresses it with AI, and injects relevant context back into future sessions. Works with Claude Code, OpenClaw, Codex, Gemini, Hermes, Copilot, OpenCode + More
