git-guardrails-claude-code
设置 Claude Code hooks,在危险 git commands(push, reset --hard, clean, branch -D 等)执行前阻止它们。Use when user wants to prevent destructive git operations, add git safety…
Skill by pop1414
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/pop1414-git-guardrails-claude-code
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Use cases: agent-building
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Shell scripts
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/git-guardrails-claude-code
What's inside
- Skill name
git-guardrails-claude-code- Description
- 设置 Claude Code hooks,在危险 git commands(push, reset --hard, clean, branch -D 等)执行前阻止它们。Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
- License
- MIT
- Instructions
- 92 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (2)
- SKILL.md
- block-dangerous-git.sh · scripts/
SKILL.md (first lines)
# 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](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。From pop1414/ai-native-doc-system, MIT.
More from pop1414/ai-native-doc-system
- 0.479score
diagnose
pop1414
面向棘手 bug、性能回退和 BMad story execution failures 的纪律化 diagnosis loop。Reproduce → minimise → hypothesise → instrument → fix → regression-test.
SkillCFreshness: CClaude Code +9 - 0.474score
caveman
pop1414
超压缩 communication mode。Cuts token usage ~75% by dropping filler, articles, and pleasantries while keeping full technical accuracy.
SkillCFreshness: CClaude Code +9 - 0.474score
to-plan
pop1414
Converts a feature PRD, spec, BMad epics/stories, release goal, or conversation context into an execution plan at `docs/plans/<plan>.md` or…
SkillCFreshness: CClaude Code +9 - 0.474score
to-prd
pop1414
将当前 conversation context 或 BMad PRD 输出转成 `docs/features/<feature>/PRD.md`,并接入 AI-native 文档链。Use when user wants to create a PRD, write product requirements…
SkillCFreshness: CClaude Code +9 - 0.474score
to-spec
pop1414
Converts a feature PRD, plan, BMad architecture/epics/stories output, or conversation context into `docs/features/<feature>/SPEC.md` with functional behavior…
SkillCFreshness: CClaude Code +9 - 0.474score
write-a-skill
pop1414
创建结构正确、支持 progressive disclosure 并带 bundled resources 的新 agent skills。Use when user wants to create, write, or build a new skill.
SkillCFreshness: CClaude Code +9 - 0.474score
grill-with-docs
pop1414
Grilling session that challenges a plan against the existing domain model, feature docs, and documented decisions, then updates CONTEXT.md and ADRs as…
SkillCFreshness: CClaude Code +9 - 0.474score
improve-codebase-architecture
pop1414
根据 CONTEXT.md 中的 domain language 和 docs/adr/ 中的 decisions,寻找 codebase 的 deepening opportunities。Use when the user wants to improve architecture, find…
SkillCFreshness: CClaude Code +9 - 0.474score
migrate-to-shoehorn
pop1414
将 test files 从 `as` type assertions 迁移到 @total-typescript/shoehorn。Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.
SkillCFreshness: CClaude Code +9 - 0.474score
scaffold-exercises
pop1414
创建包含 sections、problems、solutions 和 explainers 的 exercise directory structures,并确保通过 linting。Use when user wants to scaffold exercises, create exercise stubs…
SkillCFreshness: CClaude Code +9 - 0.474score
setup-ai-document-system
pop1414
Sets up repo-local adapters and `docs/agents/` configuration so engineering skills share one issue tracker, triage vocabulary, domain layout, AI-native…
SkillCFreshness: CClaude Code +9 - 0.474score
setup-pre-commit
pop1414
在当前 repo 设置 Husky pre-commit hooks,集成 lint-staged (Prettier)、type checking 和 tests。Use when user wants to add pre-commit hooks, set up Husky, configure…
SkillCFreshness: CClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Jun 1, 2026 (5 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/pop1414/ai-native-doc-system
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from pop1414
- 0.479score
diagnose
pop1414
面向棘手 bug、性能回退和 BMad story execution failures 的纪律化 diagnosis loop。Reproduce → minimise → hypothesise → instrument → fix → regression-test.
SkillCFreshness: CClaude Code +9 - 0.474score
caveman
pop1414
超压缩 communication mode。Cuts token usage ~75% by dropping filler, articles, and pleasantries while keeping full technical accuracy.
SkillCFreshness: CClaude Code +9 - 0.474score
migrate-to-shoehorn
pop1414
将 test files 从 `as` type assertions 迁移到 @total-typescript/shoehorn。Use when user mentions shoehorn, wants to replace `as` in tests, or needs partial test data.
SkillCFreshness: CClaude Code +9 - 0.474score
grill-with-docs
pop1414
Grilling session that challenges a plan against the existing domain model, feature docs, and documented decisions, then updates CONTEXT.md and ADRs as…
SkillCFreshness: CClaude Code +9 - 0.474score
improve-codebase-architecture
pop1414
根据 CONTEXT.md 中的 domain language 和 docs/adr/ 中的 decisions,寻找 codebase 的 deepening opportunities。Use when the user wants to improve architecture, find…
SkillCFreshness: CClaude Code +9 - 0.474score
scaffold-exercises
pop1414
创建包含 sections、problems、solutions 和 explainers 的 exercise directory structures,并确保通过 linting。Use when user wants to scaffold exercises, create exercise stubs…
SkillCFreshness: CClaude Code +9
Cite this page
git-guardrails-claude-code skill. Agent Mart. https://agentmart.dev/skills/pop1414-git-guardrails-claude-code (last updated 2026-10-24)