Claude-skill-registry global-hook-setup

Use when setting up global hooks for Claude Code enforcement. Load when ~/.claude/hooks/ is missing or incomplete, or when explicitly requested. Installs 7 project-agnostic hooks (state transitions, git hygiene, outcome tracking). Run once per machine.

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/global-hook-setup" ~/.claude/skills/majiayu000-claude-skill-registry-global-hook-setup && rm -rf "$T"
manifest: skills/data/global-hook-setup/SKILL.md
source content

Global Hook Setup

One-time setup for global Claude Code hooks. These hooks work across all projects.

Purpose

Installs 8 project-agnostic hooks that enforce DESIGN-v2 determinism:

  • State machine integrity
  • Git hygiene
  • Learning layer (outcome tracking)
  • Session checkpoints

When to Use

SituationAction
First time setupRun full setup
~/.claude/hooks/ missingRun full setup
After updating hooksRe-run setup
Manual verificationRun verify script

Quick Check

# Check if global hooks exist
ls ~/.claude/hooks/

Expected output:

verify-state-transition.py
require-commit-before-tested.py
require-outcome-update.py
link-feature-to-trace.py
markdownlint-fix.sh
remind-decision-trace.sh
session-end.sh
feature-commit.sh

Setup Steps

1. Install Hooks

~/.claude/skills/global-hook-setup/scripts/setup-global-hooks.sh

This creates:

  • ~/.claude/hooks/
    directory
  • 8 hook files
  • Executable permissions (chmod +x)

2. Verify Installation

~/.claude/skills/global-hook-setup/scripts/verify-global-hooks.sh

Hooks Installed

HookEventPurposeBlocks?
verify-state-transition.py
PreToolUseValid state transitions onlyYes
require-commit-before-tested.py
PreToolUseGit clean before testedYes
require-outcome-update.py
PreToolUseUpdate trace outcomeYes
link-feature-to-trace.py
PostToolUseAuto-link featuresNo
markdownlint-fix.sh
PostToolUseAuto-fix .md lintingNo
remind-decision-trace.sh
SessionEndRemind to log decisionsNo
session-end.sh
SessionEndCheckpoint commitNo
feature-commit.sh
CLI utilityFeature commit helperN/A

Note:

feature-commit.sh
is a CLI utility (not a hook). Use:
~/.claude/hooks/feature-commit.sh <feature-id> [message]

Settings.json Configuration

Setup script configures

~/.claude/settings.json
:

{
  "hooks": {
    "PreToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {"type": "command", "command": "python3 ~/.claude/hooks/verify-state-transition.py"},
          {"type": "command", "command": "python3 ~/.claude/hooks/require-commit-before-tested.py"},
          {"type": "command", "command": "python3 ~/.claude/hooks/require-outcome-update.py"}
        ]
      }
    ],
    "PostToolUse": [
      {
        "matcher": "Write|Edit",
        "hooks": [
          {"type": "command", "command": "python3 ~/.claude/hooks/link-feature-to-trace.py"},
          {"type": "command", "command": "/bin/bash ~/.claude/hooks/markdownlint-fix.sh"}
        ]
      }
    ],
    "SessionEnd": [
      {
        "hooks": [
          {"type": "command", "command": "/bin/bash ~/.claude/hooks/session-end.sh"},
          {"type": "command", "command": "/bin/bash ~/.claude/hooks/remind-decision-trace.sh"}
        ]
      }
    ]
  }
}

Exit Criteria (Code Verified)

# Directory exists
[ -d ~/.claude/hooks ]

# All hooks exist and executable
[ -x ~/.claude/hooks/verify-state-transition.py ]
[ -x ~/.claude/hooks/require-commit-before-tested.py ]
[ -x ~/.claude/hooks/require-outcome-update.py ]
[ -x ~/.claude/hooks/link-feature-to-trace.py ]
[ -x ~/.claude/hooks/markdownlint-fix.sh ]
[ -x ~/.claude/hooks/remind-decision-trace.sh ]
[ -x ~/.claude/hooks/session-end.sh ]
[ -x ~/.claude/hooks/feature-commit.sh ]

# Verify script passes
~/.claude/skills/global-hook-setup/scripts/verify-global-hooks.sh

Scripts

ScriptPurpose
setup-global-hooks.sh
Main setup (install + configure + validate)
configure-settings.py
Configure settings.json with hook entries
validate-settings.py
Validate hooks configured in settings.json
verify-global-hooks.sh
Verify hook files exist
install-hooks.sh
Copy from templates

Troubleshooting

ProblemSolution
Hooks not foundRe-run setup script
Permission deniedRun:
chmod +x ~/.claude/hooks/*
Verification failsCheck hook syntax, ensure python3 available
Already existsSetup is idempotent, safe to re-run

Next Steps

After global hooks: Set up project-specific hooks with

project-hook-setup
skill.