Agent skill

Git Guardrails Claude Code

by vinvcn in vinvcn/mattpocock-skills-zh-CN

设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

MITAuto-check passedAI & LLM Engineering

Install Git Guardrails Claude Code

skills CLI
$ npx skills add vinvcn/mattpocock-skills-zh-CN --skill git-guardrails-claude-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install vinvcn/mattpocock-skills-zh-CN git-guardrails-claude-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/vinvcn/mattpocock-skills-zh-CN.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/misc/git-guardrails-claude-code .claude/skills/git-guardrails-claude-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
git-guardrails-claude-code
GitHub stars
4.7k
Token cost
~474 tokens
SKILL.md length
111 words
Files
3 (incl. scripts)
Skills in repo
33
Repo updated
First seen
Licence
MIT

At a glance

设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

  • Works in 5 steps: Ask scope → Copy the hook script → Add hook to settings → …
  • Tasks that involve Git workflow
  • SKILL.md covers What Gets Blocked and Steps
  • Runs Shell scripts from its folder; calls git

What it does

Git Guardrails Claude Code is an agent skill from vinvcn/mattpocock-skills-zh-CN. 设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

Its SKILL.md is about 470 tokens, which your agent loads only when the skill is triggered. The skill folder holds 4 other files, including scripts (for example `agents/openai.yaml` and `scripts/block-dangerous-git.sh`).

It sits in AI & LLM Engineering, covering Git workflow, Hooks and plugins and LLM guardrails. It works with Git. The repository describes itself as: 这是 mattpocock/skills 的简体中文本地化版本。 The licence is MIT.

When your agent uses it

  • Tasks that involve Git workflow
  • Tasks that involve Hooks and plugins
  • Tasks that involve LLM guardrails

Example prompts

  • “/git-guardrails-claude-code”

Requirements

  • A Bash shell

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Ask scope
  2. Copy the hook script
  3. Add hook to settings
  4. Ask about customization
  5. Verify

What it can do on your machine

Read from SKILL.md and the folder at commit 3f92a83. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships 1 file in scripts/ (Shell), which the agent can run.

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Git Guardrails Claude Code loads about 474 tokens when it runs. Until then it costs about 46 tokens; SKILL.md has 111 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~46
When it runs · the whole SKILL.md, loaded when a task matches
~474

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); the scripts in this folder are not scanned.

SKILL.md

The full file from vinvcn/mattpocock-skills-zh-CN at commit 3f92a83, republished under its MIT licence (© vinvcn). 111 words, ~474 tokens.

Download SKILL.mdSave it as .claude/skills/git-guardrails-claude-code/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
git-guardrails-claude-code
description
设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。

Setup Git Guardrails

设置一个 PreToolUse hook,在 Claude 执行危险 git commands 前拦截并阻止它们。

What Gets Blocked

  • git push(包括 --force 在内的所有 variants)
  • git reset --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git checkout . / git restore .

被阻止时,Claude 会看到一条 message,说明它无权访问这些 commands。

Steps

1. Ask scope

询问用户:只为当前 project 安装(.claude/settings.json),还是为所有 projects 安装(~/.claude/settings.json)?

2. Copy the hook script

bundled script 位于:scripts/block-dangerous-git.sh

根据 scope 复制到目标位置:

  • Project: .claude/hooks/block-dangerous-git.sh
  • Global: ~/.claude/hooks/block-dangerous-git.sh

用 chmod +x 让它可执行。

3. Add hook to settings

添加到对应 settings file:

Project (.claude/settings.json):

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
          }
        ]
      }
    ]
  }
}

Global (~/.claude/settings.json):

json
{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "~/.claude/hooks/block-dangerous-git.sh"
          }
        ]
      }
    ]
  }
}

如果 settings file 已存在,把 hook merge 到现有 hooks.PreToolUse array 中,不要覆盖其他 settings。

4. Ask about customization

询问用户是否要在 blocked list 中添加或移除 patterns。相应编辑复制后的 script。

5. Verify

运行快速测试:

bash
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>

应以 code 2 退出,并向 stderr 打印 BLOCKED message。

© vinvcn, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files (scripts) in skills/misc/git-guardrails-claude-code of vinvcn/mattpocock-skills-zh-CN.

  • SKILL.md
  • agents/openai.yaml
  • scripts/block-dangerous-git.sh

Open the folder on GitHubat commit 3f92a83

Compare with similar skills

Git Guardrails Claude Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Git Guardrails Claude Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Git Guardrails Claude Code this skillvinvcn/mattpocock-skills-zh-CN4.7k—~474Automated safety check: PassMIT
Git Guardrails Claude Codefossasia/eventyay-interpretation1.6k13 repos~578Automated safety check: PassApache-2.0
Git Guardrails Claude Codedevcxl/mattpocock-skills-zh4371 repos~420Automated safety check: PassMIT
GuardHouseofmvps/ultraship123—~790Automated safety check: NotesMIT
Careful Mode Command Guardrailsgarrytan/gstack136k—~931Automated safety check: NotesMIT
Git WorkflowsTencentCloudBase/CloudBase-AI-Toolkit1.1k—~3kAutomated safety check: PassMIT

Similar skills

  • Git Guardrails Claude Code

    fossasia/eventyay-interpretation

    Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute.

    1.6k GitHub starsUsed in 13 repos~578 tokens
    AI & LLM EngineeringAuto-check passed
  • Git Guardrails Claude Code

    devcxl/mattpocock-skills-zh

    设置 Claude Code 钩子,在危险 Git 命令(push、reset --hard、clean、branch -D 等)执行前将其拦截。当用户想要防止破坏性 Git 操作、添加 Git 安全钩子或在 Claude Code 中阻止 git push/reset 时使用。

    437 GitHub starsUsed in 1 repo~420 tokens
    AI & LLM EngineeringAuto-check passed
  • Guard

    Houseofmvps/ultraship

    Safety guardrails — blocks destructive commands (rm -rf, DROP TABLE, force-push, git reset --hard) and optionally restricts file edits to a specific directory.

    123 GitHub stars~790 tokensUpdated 3 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Checks each shell command for destructive patterns such as recursive deletes, force pushes and dropped tables, and asks before letting them run.

    136k GitHub stars~931 tokensUpdated today
    SecurityAuto-check: notes
  • Git Workflows

    TencentCloudBase/CloudBase-AI-Toolkit

    Reusable git delivery workflows derived from local slash commands (commit, push, PR, release notes, GitHub Actions failure triage with worktree-based fixes, and isolating your own changes from a…

    1.1k GitHub stars~3k tokensUpdated today
    DevelopmentAuto-check passed
  • Phx Recall

    oliver-kriska/claude-elixir-phoenix

    Recall prior work from past sessions — how a bug was fixed, what was decided, where a pattern lives.

    565 GitHub stars~869 tokensUpdated 2 days ago
    AI & LLM EngineeringAuto-check passed

More from vinvcn/mattpocock-skills-zh-CN

All 33 skills in this repo
  • Codebase Design

    vinvcn/mattpocock-skills-zh-CN

    用于设计深模块的共享词汇。适用于用户想设计或改进模块接口、寻找深化机会、决定 seam 放在哪里、让代码更容易测试或更适合 AI 导航,或其他技能需要深模块词汇时。

    4.7k GitHub stars~1.1k tokensUpdated 9 days ago
    Auto-check passed
  • Diagnosing Bugs

    vinvcn/mattpocock-skills-zh-CN

    面向棘手缺陷和性能回退的诊断循环。适用于用户说 “diagnose” / “debug this”,或报告某些东西 broken、throwing、failing、slow 时。

    4.7k GitHub stars~1.4k tokensUpdated 9 days ago
    Auto-check passed
  • Domain Modeling

    vinvcn/mattpocock-skills-zh-CN

    构建并打磨项目的领域模型。适用于讨论 codebase 术语、编写或编辑 CONTEXT.md,或记录或编辑 ADR. An agent skill from vinvcn/mattpocock-skills-zh-CN.

    4.7k GitHub stars~505 tokensUpdated 9 days ago
    Auto-check passed
  • Migrate To Shoehorn

    vinvcn/mattpocock-skills-zh-CN

    将测试文件从 as 类型断言迁移到 @total-typescript/shoehorn。适用于用户提到 shoehorn、想替换测试中的 as,或需要局部测试数据时。

    4.7k GitHub stars~619 tokensUpdated 9 days ago
    Auto-check passed
  • PR

    vinvcn/mattpocock-skills-zh-CN

    用于撰写 PR 正文。适用于用户要求起草、改写或改进 PR 正文,或希望 PR 更便于审阅时. An agent skill from vinvcn/mattpocock-skills-zh-CN.

    4.7k GitHub stars~737 tokensUpdated 9 days ago
    Auto-check passed
  • Scaffold Exercises

    vinvcn/mattpocock-skills-zh-CN

    创建包含章节、题目、答案和讲解的练习目录结构,并确保通过 linting。适用于用户想 scaffold exercises、创建 exercise stubs,或设置新的课程章节时。

    4.7k GitHub stars~767 tokensUpdated 9 days ago
    Auto-check passed

Works with

Questions about Git Guardrails Claude Code

What does Git Guardrails Claude Code do?

设置 Claude Code hooks,在危险 git commands(push、reset --hard、clean、branch -D 等)执行前阻止它们。适用于用户想防止破坏性 git 操作、添加 git safety hooks,或在 Claude Code 中阻止 git push/reset 时。. Git Guardrails Claude Code is an agent skill from vinvcn/mattpocock-skills-zh-CN.

When should I use Git Guardrails Claude Code?

Git Guardrails Claude Code fits situations like: tasks that involve Git workflow; tasks that involve Hooks and plugins; tasks that involve LLM guardrails.

How do I install Git Guardrails Claude Code in Claude Code?

Run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill git-guardrails-claude-code -a claude-code`. Or copy the skill folder (skills/misc/git-guardrails-claude-code in vinvcn/mattpocock-skills-zh-CN) into .claude/skills/git-guardrails-claude-code in your project. Claude Code loads it when a task matches its description.

How do I install Git Guardrails Claude Code in Codex?

Run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill git-guardrails-claude-code -a codex`. Or copy the skill folder (skills/misc/git-guardrails-claude-code in vinvcn/mattpocock-skills-zh-CN) into .agents/skills/git-guardrails-claude-code in your project. Codex loads it when a task matches its description.

Can I use Git Guardrails Claude Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add vinvcn/mattpocock-skills-zh-CN --skill git-guardrails-claude-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/git-guardrails-claude-code, .gemini/skills/git-guardrails-claude-code, .github/skills/git-guardrails-claude-code and .opencode/skills/git-guardrails-claude-code in your project.

What does Git Guardrails Claude Code need to run?

Going by SKILL.md and its folder, Git Guardrails Claude Code needs a shell for the scripts in its folder and the command-line tools its instructions call (git). Our summary lists: A Bash shell.

Does Git Guardrails Claude Code access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Git Guardrails Claude Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. The check reads SKILL.md only: the scripts in the folder are not scanned, so read them before running anything.

What licence does Git Guardrails Claude Code use?

Git Guardrails Claude Code is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Git Guardrails Claude Code use?

About 474 tokens (SKILL.md is roughly 1.9k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Git Guardrails Claude Code?

Skills that share tags, products or a category with Git Guardrails Claude Code: Git Guardrails Claude Code (fossasia/eventyay-interpretation, 1.6k stars), Git Guardrails Claude Code (devcxl/mattpocock-skills-zh, 437 stars), Guard (Houseofmvps/ultraship, 123 stars) and Careful Mode Command Guardrails (garrytan/gstack, 136k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Git Guardrails Claude Code?

vinvcn (a GitHub user) maintains it in vinvcn/mattpocock-skills-zh-CN, which has 4,657 GitHub stars. The repository holds 33 skills in this directory. The repository was last updated on September 28, 2026.

Source: vinvcn/mattpocock-skills-zh-CN on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.