Files
claude-foundations/hooks/require-plan-file.sh
Paul O'Reilly e94417b896 Add best practices, hooks, memory files, and scripts from recent sessions
Includes: spec-driven and test-driven development best practices,
reproduce-before-fixing debugging workflow, require-plan-file hook,
find-project-root script, session logs, memory files for decisions/
gotchas/process-lessons, and updates to existing best practice topics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-17 09:47:47 +13:00

19 lines
694 B
Bash
Executable File

#!/bin/bash
# Blocks ExitPlanMode unless a *-PLAN.md file exists in the current working directory.
# Fired via PreToolUse hook on ExitPlanMode.
# Input: JSON on stdin with session context including "cwd".
INPUT=$(cat)
CWD=$(echo "$INPUT" | python3 -c "import sys, json; print(json.load(sys.stdin).get('cwd', ''))" 2>/dev/null)
if [ -z "$CWD" ]; then
exit 0 # Can't determine cwd, allow through
fi
if ls "$CWD"/*-PLAN.md 2>/dev/null | grep -q .; then
exit 0 # Plan file exists, allow exit
fi
echo "No PLAN.md file found in $CWD. Before exiting plan mode, write the complete plan to a file named [MILESTONE]-[PURPOSE]-PLAN.md in the project root (e.g. M2-auth-PLAN.md)." >&2
exit 2