#!/usr/bin/env bash # Tier 3 — when the agent tries to stop, check whether feature.manifest.ts # changes have matching test changes. If manifest moved without tests, # nudge the agent to continue (exit 2 forces continuation). set -euo pipefail input=$(cat) # Loop guard — Claude Code sets stop_hook_active when a Stop hook already # forced continuation; don't loop infinitely. already_stopped=$(printf '%s' "$input" | jq -r '.stop_hook_active // false') if [ "$already_stopped" = "true" ]; then exit 0 fi # Only run inside the repo if ! git rev-parse --git-dir >/dev/null 2>&1; then exit 0 fi manifest_changed=$(git diff --name-only HEAD 2>/dev/null | grep -E 'feature\.manifest\.ts$' || true) if [ -z "$manifest_changed" ]; then exit 0 fi tests_changed=$(git diff --name-only HEAD 2>/dev/null | grep -E '\.test\.(ts|tsx)$' || true) if [ -n "$tests_changed" ]; then exit 0 fi cat >&2 <