Skip to content

feat: validation gates stop hook (#7) - #14

Merged
elynch303 merged 1 commit into
masterfrom
feature/#7-stop-hooks-validation-gates
Apr 15, 2026
Merged

feat: validation gates stop hook (#7)#14
elynch303 merged 1 commit into
masterfrom
feature/#7-stop-hooks-validation-gates

Conversation

@elynch303

Copy link
Copy Markdown
Owner

Closes #7

Changes

New: .claude/hooks/stop/validation_gates.py

  • Auto-detects stack from package.json, pyproject.toml, go.mod, Cargo.toml
  • Runs enabled gates in sequence: lint → security → typecheck → build (+ optional tests/e2e/ui)
  • Checks tool availability with which before running each gate — skips silently if not installed
  • Only activates when git status shows modified files — no noise on read-only sessions
  • Returns exit 2 with structured stderr on failures so Claude sees them and can invoke validation-gates agent to fix
  • Returns exit 0 if clean, no tools, no stack, or unexpected error — never crashes a session
  • stdlib only, under 500 lines

New: tests/hooks/test_validation_gates.py

  • 26 unit tests (stdlib unittest)
  • Covers: stack detection, gate enable/disable from config, clean exit when no tools, output format, exit codes

Modified: .claude/settings.json.example

  • Added stopGates config block with all keys and defaults
  • Hook registered in the Stop hooks array

Modified: README.md + scripts/install.sh

  • Validation Gates entry added to Safety Hooks table
  • Install note pointing users to stopGates config

Test plan

  • Session with modified files + ruff installed → lint failures surface to Claude
  • Session with no modified files → hook exits 0 silently
  • stopGates.lint: false in settings.json → lint gate skipped
  • No linter installed → gate skipped, exit 0
  • python -m unittest discover -s tests/ → 26 tests pass

🤖 Generated with Claude Dev Kit

Adds validation_gates.py stop hook that auto-detects project stack and
runs lint, security, typecheck, and build gates on session end. Returns
exit 2 with structured stderr on failures so Claude can invoke the
validation-gates agent to fix before finishing. Exit 0 if no modified
files, no tools installed, or project unrecognised.

Gate config via stopGates in settings.json (lint/security/typecheck/build
default on; tests/e2e/ui opt-in). Hook registered in settings.json.example.
26 unit tests covering detection, gate toggle, exit codes, and output format.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@elynch303
elynch303 merged commit 2ec7463 into master Apr 15, 2026
3 checks passed
@elynch303
elynch303 deleted the feature/#7-stop-hooks-validation-gates branch April 15, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: audit and improve stop hooks with validation gates

1 participant