mirror of
https://github.com/davila7/claude-code-templates.git
synced 2026-09-19 01:30:23 +08:00
fc83c2a9c4
* feat: add enterprise quality hooks and agents from pm-workspace Add 3 quality gate hooks and 2 specialized agents contributed from pm-workspace (https://github.com/gonzalezpazmonica/pm-workspace): Hooks (new category: quality-gates/): - tdd-gate: Enforces TDD — blocks editing production code without tests - plan-gate: Warns about implementing without an approved specification - scope-guard: Detects files modified outside the declared spec scope Agents: - sdd-spec-writer: Creates executable specifications for AI agents - commit-guardian: 10-check pre-commit verification protocol All components are generic (no Azure DevOps dependency), MIT licensed, and follow the project's component structure conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address all 12 cubic review issues on enterprise hooks and agents Fixes applied per cubic-dev-ai review: Hooks (JSON configs): - Add MultiEdit matcher to tdd-gate, plan-gate (was bypassing gate) - Use $CLAUDE_PROJECT_DIR for all hook paths (avoid CWD-dependent failures) tdd-gate.sh: - Narrow test file globs: use suffix-based patterns (*Test.ext, *.test.ext) instead of overly broad *test* substring match (P1 fix) - Improve test discovery: search nearby dirs first (same module), fallback to project-wide with -maxdepth 6 to limit latency on large repos plan-gate.sh: - Remove `set -euo pipefail` that caused unintentional blocking when find fails on non-existent dirs - Add `|| true` to find to prevent exit-on-error scope-guard.sh: - Fix spec selection: use -printf '%T@ %p' sorted by mtime (not path sort) with macOS fallback using xargs ls -t - Broaden declared-file regex: support longer extensions and @ in paths - Fix word-splitting: use while-read loop instead of unquoted for-in - Fix matching: use case-based suffix match instead of substring grep commit-guardian.md: - CHECK 3: Fix Python build command (per-file py_compile, not bare) - CHECK 3: Add Go and Rust build detection, add SKIP when no build system - CHECK 10: Change from WARN to BLOCK for malformed commit messages sdd-spec-writer.md: - Add explicit .spec.md naming convention requirement (quality gate hooks depend on this filename pattern for spec detection) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address cubic review round 2 — null-delimit macOS fallback, existence-only spec check - scope-guard.sh: use -print0/xargs -0 for macOS fallback to handle paths with spaces safely (cubic P2) - plan-gate.sh: replace full enumeration with find -print -quit for existence-only check, avoiding unnecessary latency in large repos (cubic P2) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
39 lines
1.3 KiB
Bash
39 lines
1.3 KiB
Bash
#!/bin/bash
|
|
# plan-gate.sh — Warning if implementing code without an approved spec
|
|
# Source: pm-workspace (https://github.com/gonzalezpazmonica/pm-workspace)
|
|
# License: MIT
|
|
#
|
|
# PreToolUse hook (Edit|MultiEdit|Write) that warns if source code is being
|
|
# edited without a recent specification file (.spec.md) in the project.
|
|
# Non-blocking: shows warning but allows the edit to proceed.
|
|
# NOTE: No 'set -euo pipefail' — this hook must NEVER block unintentionally.
|
|
|
|
# Only check source code files
|
|
FILE="${CLAUDE_TOOL_INPUT_FILE:-}"
|
|
[ -z "$FILE" ] && exit 0
|
|
|
|
case "$FILE" in
|
|
*.cs|*.ts|*.tsx|*.js|*.jsx|*.py|*.go|*.rs|*.php|*.rb|*.java|*.kt|*.swift|*.dart|*.vb|*.cbl) ;;
|
|
*) exit 0 ;;
|
|
esac
|
|
|
|
# Look for active spec in the project
|
|
PROJECT_DIR="${CLAUDE_PROJECT_DIR:-.}"
|
|
|
|
# Check for recent specs (last sprint = last 14 days)
|
|
# Only test existence — no need to enumerate all matches (avoids latency in large repos)
|
|
HAS_SPEC=0
|
|
if find "$PROJECT_DIR" -name "*.spec.md" -mtime -14 -type f -print -quit 2>/dev/null | grep -q .; then
|
|
HAS_SPEC=1
|
|
fi
|
|
|
|
if [ "$HAS_SPEC" -eq 0 ]; then
|
|
echo ""
|
|
echo "Plan Gate: No recent approved spec found (.spec.md modified in last 14 days)."
|
|
echo " Consider creating a specification before implementing."
|
|
echo " (Warning only — does not block the edit)"
|
|
echo ""
|
|
fi
|
|
|
|
exit 0
|