git-guardrails-claude-code
在 Claude Code 中阻止高风险 Git 命令
AI 编码会话可能会意外运行破坏性的 git 命令。此 skill 会安装一个 Claude Code hook,在高风险 git 操作执行前阻止它们。
使用我的智能体安装
将此请求复制给你的智能体,其中包含权威 Skill 页面和清单。
Review the Skillstore skill "git-guardrails-claude-code" from https://skillstore.io/skills/mattpocock-git-guardrails-claude-code.md and its manifest at https://skillstore.io/api/skills/mattpocock-git-guardrails-claude-code/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智能体仍应展示其计划,并按安全策略请求必要确认。
Agent 可读资源
当 AI Agent、爬虫或脚本需要干净上下文,而不是读取完整页面时,请使用这些链接。
测试它
正在使用“git-guardrails-claude-code”。 Set up git guardrails for this project only.
预期结果:
助手会请求确认,将 hook 复制到项目 .claude 目录,更新项目设置,并验证 git push 已被阻止。
正在使用“git-guardrails-claude-code”。 Add protection against git reset --hard and git clean -fd.
预期结果:
助手会确认拒绝列表包含这两个命令,并使用安全的示例输入测试 hook。
正在使用“git-guardrails-claude-code”。 Install this for all my Claude Code projects.
预期结果:
助手会说明全局作用域,在获得批准后更新用户 Claude 设置,并保持现有 hook 条目不变。
安全审计
安全The static findings are false positives caused by Markdown command examples, expected Claude Code configuration paths, and a defensive local hook script. The script parses hook input and blocks dangerous git patterns; it does not execute the captured command or access sensitive files. No prompt injection, data exfiltration, or malicious intent was found.
风险因素
⚙️ 外部命令 (20)
分享与引用此报告
分享版本化评估报告、中性徽章、嵌入卡片和引用。Skillstore 只报告证据,不判断该 Skill 是否安全。
复制报告链接
https://skillstore.io/skills/mattpocock-git-guardrails-claude-code/audits/6?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/mattpocock-git-guardrails-claude-code?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/mattpocock-git-guardrails-claude-code?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/mattpocock-git-guardrails-claude-code/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/mattpocock-git-guardrails-claude-code.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>学术引用 (APA · BibTeX · CFF)
APA 引用
mattpocock. (2026). git-guardrails-claude-code security audit report (audit version 6) [Author version unspecified]. Skillstore. https://skillstore.io/skills/mattpocock-git-guardrails-claude-code/audits/6BibTeX 引用
@techreport{mattpocock-mattpocock-git-guardrails-claude-code-2026,
author = {mattpocock},
title = {git-guardrails-claude-code security audit report (audit version 6)},
institution = {Skillstore},
year = {2026},
number = {6},
url = {https://skillstore.io/skills/mattpocock-git-guardrails-claude-code/audits/6},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "git-guardrails-claude-code security audit report (audit version 6)"
version: "unspecified"
type: report
authors:
- name: "mattpocock"
date-released: "2026-07-09"
url: "https://skillstore.io/skills/mattpocock-git-guardrails-claude-code/audits/6"
identifiers:
- type: other
value: "skillstore:mattpocock-git-guardrails-claude-code:audit:6"
description: "Skillstore immutable audit report identifier"
Skillstore 评分
评分依据 证据置信度: 中你能构建什么
保护个人项目免受意外 git push 影响
安装项目级防护栏,使 Claude Code 无法在没有用户干预的情况下执行 push、hard reset 或 clean 文件。
为团队标准化 AI 编码安全
共享可重复的 hook 设置,在辅助开发会话期间阻止破坏性的 git 命令。
为频繁 AI 编码添加全局安全默认设置
当用户希望在所有项目中使用相同的 git 保护时,配置全局 Claude Code hook。
试试这些提示
仅为此项目设置 git 防护栏。更改设置前先询问,然后安装并测试 hook。
为 Claude Code 全局安装 git 防护栏。保留所有现有设置,并验证 git push 已被阻止。
审查当前的 git 防护栏模式,并为我们还应阻止的任何破坏性 git 命令添加规则。
检查我的 Claude Code git 防护栏 hook 是否正确安装,是否保留现有 hooks,并是否阻止预期命令。
最佳实践
- 除非你明确希望每个仓库都使用相同规则,否则请选择项目作用域。
- 添加此配置时保留现有 Claude Code hooks。
- 安装后以及更改被阻止模式后,运行验证测试。
避免
- 添加 hook 时不要覆盖现有 settings 文件。
- 不要假设此 hook 可以替代分支保护或代码审查。
- 未测试合法 git 工作流前,不要添加过宽泛的模式。
常见问题
此 skill 会阻止什么?
它会自行运行 git 命令吗?
我可以只为一个项目安装它吗?
我可以全局安装它吗?
我可以更改被阻止的命令吗?
此 hook 需要什么依赖?
开发者详情
作者
mattpocock许可证
MIT
Skillstore 修订
r1
版本提示
作者未声明版本。
引用
1ffa7643651792ccb4bd3b15d924d2c97edff755
维护新鲜度
2026/7/18
使用量
3 次下载 · 0 次浏览
文件结构