본문으로 건너뛰기
cccskills
무료GitHub에 공개

git-guardrails-claude-code

Set up Claude Code git safety guardrails that block dangerous git commands before execution. Use when the user asks to prevent git push, hard reset, git clean, destructive checkout/restore, or branch deletion from Claude Code hooks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(2)

  • SKILL.md4.3 KB
  • references/block-dangerous-git.sh.md1.8 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

git-guardrails-claude-code

Guide a user through installing a Claude Code PreToolUse hook that blocks dangerous git commands before they execute.

This Agent Forge port is guidance-first: do not install hooks, edit .claude/settings.json, edit ~/.claude/settings.json, or create executable hook files unless the user explicitly asks for installation in the current task.

What gets blocked

The reference hook blocks commands matching these patterns:

  • git push, including force-push variants
  • git reset --hard
  • git clean -f and git clean -fd
  • git branch -D
  • git checkout .
  • git restore .
  • Short forms that still contain push --force or reset --hard

When a command is blocked, the hook exits with code 2 and prints a message explaining which dangerous pattern matched.

Workflow

1. Confirm scope

Ask the user where they want the guardrail installed:

  • Project only: .claude/settings.json with the hook script under .claude/hooks/block-dangerous-git.sh
  • Global: ~/.claude/settings.json with the hook script under ~/.claude/hooks/block-dangerous-git.sh

If the user only asks for advice or review, provide the guidance and stop before editing files.

2. Review the reference hook

Use the bundled reference as the source for the script content:

references/block-dangerous-git.sh.md

Keep it as documentation unless installation is explicitly requested. If installing, copy the shell script content from the reference into the selected hook path and make that copied file executable.

chmod +x .claude/hooks/block-dangerous-git.sh

For global installs, use the global hook path instead:

chmod +x ~/.claude/hooks/block-dangerous-git.sh

3. Merge hook settings

Add a PreToolUse hook for the Bash tool. If the settings file already exists, merge into the existing JSON and preserve all unrelated settings and hooks.

Project-scoped hook:

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

Global hook:

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

Do not replace an existing hooks.PreToolUse array. Append the new command hook only if an equivalent command is not already present.

4. Customize intentionally

Ask whether the user wants to add or remove blocked patterns before installation. Keep the defaults unless the user chooses a different policy.

Common customizations:

  • Allow ordinary git push but keep blocking git push --force.
  • Add git checkout -- . or repo-specific destructive commands.
  • Add explanatory text that matches the team's git policy.

Document any customization in the response so future agents understand the local policy.

5. Verify with sample JSON

Test the installed or candidate script by piping Claude Code hook JSON into it:

echo '{"tool_input":{"command":"git push origin main"}}' | .claude/hooks/block-dangerous-git.sh

Expected result:

  • Exit code: 2
  • Stderr includes BLOCKED
  • Message includes the matched pattern, such as git push

Also test an allowed command:

echo '{"tool_input":{"command":"git status --short"}}' | .claude/hooks/block-dangerous-git.sh

Expected result:

  • Exit code: 0
  • No block message

Agent Forge safety notes

  • Preserve non-interactive shell behavior; never run commands that wait for input.
  • Do not run a real dangerous git command to test the hook.
  • Do not install this hook as part of a porting or documentation task.
  • Do not overwrite settings files. Parse and merge JSON when installation is requested.
  • Keep project-specific installs in the target project, not in this harness, unless the user explicitly chooses this repository as the target.

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

add-bead

무료

Capture free-text work as a tracked Beads issue. Use when the user runs /add-bead or wants to quickly file a Beads issue.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

add-repo

무료

Register a new sub-repo in the knowledge base.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

Add focused Bun unit tests for mission-critical behavior and edge cases — not blanket coverage.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

ask

무료

Answer questions about the codebase from knowledge files. Use when the user runs /ask or asks a domain/knowledge question about the repos.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

Meta-skill for creating Agent Forge skills under .claude/skills/ with SKILL.md, optional references/ and scripts/, and Bun scaffolds. Use when the user wants to add or author a skill, scaffold a new skill folder, or align skill docs with harness conventions (JSON script output, Beads for tasks).

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

Choose Beads issue priority (P0–P4, numeric, or named) from urgency, impact, and risk when creating or triaging work.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

jupes/agent-forge-harness22026년 10월 19일 업데이트

jupes의 스킬 모두 보기

이 스킬의 문제 신고