git-guardrails-claude-code
하는 일
Claude Code에 특정 git 명령의 실행을 막는 안전 검사를 추가합니다. 코드 저장소가 실수로 손상되는 것을 막고 싶은 사람을 위한 스킬입니다.
사용하는 경우
- ✓에이전트가 실수로 코드를 push하지 않도록 막고 싶을 때.
- ✓git reset --hard 같은 파괴적인 명령을 차단하고 싶을 때.
- ✓이 안전 규칙을 한 프로젝트에 적용할지 모든 프로젝트에 적용할지 정하고 싶을 때.
스킬 링크
https://github.com/mattpocock/skills/blob/main/skills/misc/git-guardrails-claude-code/SKILL.md복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.
사용 방법
가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.
바로 붙여넣을 수 있는 메시지
Claude Code, Codex, Cursor용입니다. 프로젝트 폴더에서 실행하면 스킬이 설치됩니다.
SKILL.md를 다운로드해 에이전트의 스킬 폴더에 넣으세요.
AI에게 요청하는 예시
“Claude Code가 실수로 제 git 저장소에 push하거나 reset하지 못하도록 안전 훅을 설정해 주세요.”
매주 새 스킬 5개. 읽는 데 1분.
작동 방식
에이전트는 훅 스크립트를 프로젝트나 홈 설정에 복사하고 설정 파일에 연결합니다. 차단된 명령이 시도되면 훅이 그것을 막고, 에이전트에게 그 명령을 실행할 권한이 없다고 알립니다.
기술 내용 (원본 SKILL.md)
작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.
Setup Git Guardrails
Sets up a PreToolUse hook that intercepts and blocks dangerous git commands before Claude executes them.
What Gets Blocked
git push(all variants including--force)git reset --hardgit clean -f/git clean -fdgit branch -Dgit checkout ./git restore .
When blocked, Claude sees a message telling it that it does not have authority to access these commands.
Steps
1. Ask scope
Ask the user: install for this project only (.claude/settings.json) or all projects (~/.claude/settings.json)?
2. Copy the hook script
The bundled script is at: scripts/block-dangerous-git.sh
Copy it to the target location based on scope:
- Project:
.claude/hooks/block-dangerous-git.sh - Global:
~/.claude/hooks/block-dangerous-git.sh
Make it executable with chmod +x.
3. Add hook to settings
Add to the appropriate settings file:
Project (.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "\"$CLAUDE_PROJECT_DIR\"/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
Global (~/.claude/settings.json):
{
"hooks": {
"PreToolUse": [
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "~/.claude/hooks/block-dangerous-git.sh"
}
]
}
]
}
}
If the settings file already exists, merge the hook into the existing hooks.PreToolUse array. Don't overwrite other settings.
4. Ask about customization
Ask if user wants to add or remove any patterns from the blocked list. Edit the copied script accordingly.
5. Verify
Run a quick test:
echo '{"tool_input":{"command":"git push origin main"}}' | <path-to-script>
Should exit with code 2 and print a BLOCKED message to stderr.
자주 묻는 질문
어떤 git 명령이 차단되나요?
모든 형태의 push, git reset --hard, git clean -f, git branch -D, 그리고 모든 파일에 대한 checkout이나 restore가 차단됩니다.
규칙이 적용되는 범위를 고를 수 있나요?
예. 스킬은 이 프로젝트에만 설치할지 모든 프로젝트에 설치할지 묻습니다.
명령이 차단되면 무슨 일이 일어나나요?
Claude는 그 명령에 접근할 권한이 없다는 메시지를 봅니다.
상세 정보
작성자의 원본 설명
Set up Claude Code hooks to block dangerous git commands (push, reset --hard, clean, branch -D, etc.) before they execute. Use when user wants to prevent destructive git operations, add git safety hooks, or block git push/reset in Claude Code.
repo: mattpocock/skills
인기도
- GitHub 스타
- 310k
- 순위
- #120
- 라이선스
- MIT
- 업데이트
- 2026. 11. 1.
댓글
- …
이 저장소의 다른 스킬
ask-matt
310k에이전트가 아이디어에서 배포된 코드까지 이어지는 코딩 스킬 모음의 안내자가 되어, 상황에 맞는 스킬을 찾아 주도록 돕습니다.
code-review
310k마지막 기준점 이후 바뀐 내용을 저장소의 코딩 표준과 원래 명세에 나란히 비교해, 병합 전에 검토하도록 돕습니다.
domain-modeling
310k팀이 쓰는 용어를 담은 공유 프로젝트 용어집을 만들고, 중요한 설계 결정을 기록해 코드가 같은 단어를 쓰도록 돕습니다.
implement-spec
310k완성된 명세와 그 티켓을 작동하는 코드로 바꾸고, 티켓을 순서대로 처리한 뒤 하나의 브랜치에 모아 줍니다.
비슷한 스킬
openclaw-update
394k에이전트가 설치 방식에 맞는 방법을 골라 기존 OpenClaw Gateway를 업데이트하고, 세션이 계속 작동하도록 돕습니다.
diagnose-gateway
394k에이전트가 설정, 채널, 포트를 확인해 OpenClaw Gateway가 왜 실패하는지 찾되, 아무것도 바꾸지 않도록 돕습니다.
crabbox-apps
394k에이전트가 임시 클라우드 머신에서 앱을 열고 실행한 뒤, 그 화면을 채팅의 측면 패널에 보여 주도록 돕습니다.