← ClaudeAtlas

hookslisted

Configures Claude Code hooks for a project. Use this skill at project initialisation time to write .claude/settings.json with pre-commit gates. Also use when the user asks to set up hooks, enforce commit standards, or add pre-commit checks. The hook blocks any git commit that fails ruff, ty, or pytest — no exceptions.
0jg/skills · ★ 0 · Code & Development · score 62
Install: claude install-skill 0jg/skills
# Hooks Skill ## Purpose Claude Code hooks fire on tool events and can block execution. This skill installs a single `PreToolUse` hook that intercepts every `git commit` and runs the full quality gate. If any check fails, the commit is refused and Claude Code reports the failure. No bad code reaches the repository. --- ## Installation (at project init time) Create `.claude/` if it does not exist: ```bash mkdir -p .claude ``` Write `.claude/settings.json`: ```json { "hooks": { "PreToolUse": [ { "matcher": "Bash", "hooks": [ { "type": "command", "command": "bash .claude/hooks/pre-commit-gate.sh \"$CLAUDE_TOOL_INPUT\"" } ] } ] } } ``` Write `.claude/hooks/pre-commit-gate.sh`: ```bash #!/usr/bin/env bash # Pre-commit gate — hard blocks git commit if checks fail. # Invoked by Claude Code PreToolUse hook on every Bash tool call. # Only activates when the command contains "git commit". # Detects Python (uv/pyproject.toml) and Rust (Cargo.toml) projects automatically. set -euo pipefail TOOL_INPUT="$1" # Only intercept git commit calls if ! echo "$TOOL_INPUT" | grep -q "git commit"; then exit 0 fi echo "=== Pre-commit gate ===" FAILED=0 # ── Python checks (if pyproject.toml present) ───────────────────────────────── if [ -f "pyproject.toml" ]; then echo "--- ruff check ---" if ! uv run ruff check . 2>&1; then echo "FAIL: ruff check" FAILED=1 fi echo "--- ruff f