Skip to content

Commit e49c855

Browse files
feat(phase-3): pre-commit hooks (Option B — GitHub Actions unavailable)
GitHub Actions cannot run on this private repo under the current org plan. Adding pre-commit hooks as local enforcement until the repo goes public or the org plan is upgraded. - .githooks/pre-commit — runs on every `git commit` touching skills, evals, or schemas: 1. scripts/validate_skills.py (frontmatter, line count, routing refs, forbidden URLs, index.json paths) 2. evals.harness.validate_prompts (prompt YAML schema) 3. mock Layer 1 eval (all 6 skills must pass) 4. mock Layer 2 eval (all 6 skills must pass) Skips entirely if no relevant files are staged. - scripts/install-hooks.sh — one-time setup: sets core.hooksPath to .githooks and marks the hook executable. Run after cloning. - CONTRIBUTING.md — added install step to Quick start + note on automatic hook enforcement in PR checklist. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent dba6bb9 commit e49c855

3 files changed

Lines changed: 78 additions & 2 deletions

File tree

.githooks/pre-commit

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/usr/bin/env bash
2+
# Pre-commit hook: validate skill content + run mock evals.
3+
# Installed via: git config core.hooksPath .githooks
4+
# Or: scripts/install-hooks.sh
5+
#
6+
# Skips checks if no relevant files changed.
7+
8+
set -euo pipefail
9+
10+
REPO_ROOT="$(git rev-parse --show-toplevel)"
11+
cd "$REPO_ROOT"
12+
13+
# Detect which files are staged
14+
STAGED=$(git diff --cached --name-only)
15+
16+
SKILLS_CHANGED=$(echo "$STAGED" | grep -E \
17+
"^plugins/ping-identity/skills/|^plugins/ping-identity/references/index\.json|^shared/schemas/|^scripts/validate_skills\.py" \
18+
|| true)
19+
20+
EVALS_CHANGED=$(echo "$STAGED" | grep -E \
21+
"^evals/|^plugins/ping-identity/skills/" \
22+
|| true)
23+
24+
if [ -z "$SKILLS_CHANGED" ] && [ -z "$EVALS_CHANGED" ]; then
25+
exit 0
26+
fi
27+
28+
echo "🔍 Running pre-commit checks..."
29+
30+
# ── 1. Skill content validator ──────────────────────────────────────────────
31+
if [ -n "$SKILLS_CHANGED" ]; then
32+
echo " → Validating skill content..."
33+
if ! python3 scripts/validate_skills.py --root .; then
34+
echo ""
35+
echo "❌ Skill validation failed. Fix the errors above before committing."
36+
exit 1
37+
fi
38+
fi
39+
40+
# ── 2. Prompt YAML schema validator ─────────────────────────────────────────
41+
if [ -n "$EVALS_CHANGED" ]; then
42+
echo " → Validating eval prompt sets..."
43+
if ! python3 -m evals.harness.validate_prompts 2>&1 | grep -v "^SKIP"; then
44+
echo ""
45+
echo "❌ Eval prompt validation failed. Fix the errors above before committing."
46+
exit 1
47+
fi
48+
49+
echo " → Running Layer 1 mock eval..."
50+
if ! python3 -m evals.harness.run_eval --adapter mock --layer 1; then
51+
echo ""
52+
echo "❌ Layer 1 eval failed. All skills must pass before committing."
53+
exit 1
54+
fi
55+
56+
echo " → Running Layer 2 mock eval..."
57+
if ! python3 -m evals.harness.run_eval --adapter mock --layer 2; then
58+
echo ""
59+
echo "❌ Layer 2 eval failed. All skills must pass before committing."
60+
exit 1
61+
fi
62+
fi
63+
64+
echo "✅ All pre-commit checks passed."

CONTRIBUTING.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ This repo ships the 6 umbrella skills for the Ping Identity agent skills package
1010
git clone https://github.com/pingidentity/agent-plugins.git
1111
cd agent-plugins
1212

13-
# Validate everything
13+
# Install pre-commit hooks (run once after cloning)
14+
bash scripts/install-hooks.sh
15+
16+
# Validate everything manually
1417
python3 scripts/validate_skills.py --root .
1518

1619
# Run evals (mock, no API key needed)
@@ -28,7 +31,8 @@ All three commands must exit 0 before you open a PR.
2831

2932
## PR checklist
3033

31-
Before opening a PR, confirm every item:
34+
The pre-commit hook (`bash scripts/install-hooks.sh`) runs the first four checks automatically on every `git commit`. Confirm all items before opening a PR:
35+
3236

3337
- [ ] `python3 scripts/validate_skills.py --root .` exits 0
3438
- [ ] `python3 -m evals.harness.validate_prompts` exits 0

scripts/install-hooks.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
# Install shared Git hooks for this repo.
3+
# Run once after cloning: bash scripts/install-hooks.sh
4+
set -euo pipefail
5+
REPO_ROOT="$(git rev-parse --show-toplevel)"
6+
git -C "$REPO_ROOT" config core.hooksPath .githooks
7+
chmod +x "$REPO_ROOT/.githooks/pre-commit"
8+
echo "✅ Git hooks installed. Pre-commit checks will run on every commit."

0 commit comments

Comments
 (0)