Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

git-guardrails-claude-code

БесплатноЗапускает вложенные скриптыНе проверен

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…

akillnessот akillness★ 63 звезды на GitHub

Об этом скилле

Git Guardrails for Claude Code

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.

This skill is imported from mattpocock/skills (MIT) and is model-invoked upstream.

When to use this skill

  • 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.

Instructions

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 with --hard
  • git clean -f / git clean -fd
  • git branch -D
  • git 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 or all projects?

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: <project-root>/hooks/block-dangerous-git.sh
  • Global: <user-hooks-dir>/block-dangerous-git.sh

Make it executable with chmod +x.

3. Add hook to settings

Register the command hook via /hooks (or your Claude Code hook configuration) for the selected scope:

Project:

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

Global:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Bash",
        "hooks": [
          {
            "type": "command",
            "command": "<user-hooks-dir>/block-dangerous-git.sh"
          }
        ]
      }
    ]
  }
}

If a hook configuration already exists, merge the hook into the existing PreToolUse array rather than overwriting other hooks.

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.

Examples

  • Apply this skill to one narrow scope first, confirm the output matches the shape described above, then widen to the full task.
  • When a step needs a fact from the repository or the environment, look it up instead of asking the user for it.

Best practices

  • Keep the upstream procedure intact; record deviations explicitly instead of silently improvising.
  • Stop and hand control back to the user at every decision point this skill marks as theirs.
  • Prefer small reversible changes, and state assumptions rather than burying them.

References

  • Upstream skill: mattpocock/skills (git-guardrails-claude-code, commit 3cca18b, MIT)
  • Script: scripts/block-dangerous-git.sh
  • Project standards: skill-standardization
Полный SKILL.md на GitHub

Установить git-guardrails-claude-code в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Read
Grep
Glob
Bash
Write
Edit

Вложенные файлы

scripts/block-dangerous-git.sh

FAQ

Что делает скилл git-guardrails-claude-code?

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.

Как установить скилл git-guardrails-claude-code?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл git-guardrails-claude-code запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить git-guardrails-claude-code с