···11+#!/usr/bin/env bash
22+set -e
33+44+input=$(cat)
55+if [ "$(echo "$input" | jq -r '.stop_hook_active')" = "true" ]; then
66+ exit 0
77+fi
88+99+output=$(npm run test -- --changed 2>&1) && exit 0
1010+1111+# Get the failure summary (last 30 lines usually has the good stuff)
1212+errors=$(echo "$output" | tail -30)
1313+1414+# Escape for JSON
1515+escaped=$(echo "$errors" | jq -Rs .)
1616+# Remove surrounding quotes that jq adds
1717+escaped=${escaped:1:-1}
1818+1919+cat <<EOF
2020+{
2121+ "decision": "block",
2222+ "reason": "${escaped}\n\n[Stop Hook] Tests failed. Assess whether these failures are related to changes you made this session - if not, mention them to the user and stop."
2323+}
2424+EOF
2525+exit 2
+25
.claude/hooks/stop-typecheck.sh
···11+#!/usr/bin/env bash
22+set -e
33+44+input=$(cat)
55+if [ "$(echo "$input" | jq -r '.stop_hook_active')" = "true" ]; then
66+ exit 0
77+fi
88+99+output=$(npm run typecheck:faster 2>&1) && exit 0
1010+1111+# Extract just the error lines (skip npm boilerplate)
1212+errors=$(echo "$output" | grep -E "error TS[0-9]+:" | head -15)
1313+1414+# Escape for JSON
1515+escaped=$(echo "$errors" | jq -Rs .)
1616+# Remove surrounding quotes that jq adds
1717+escaped=${escaped:1:-1}
1818+1919+cat <<EOF
2020+{
2121+ "decision": "block",
2222+ "reason": "${escaped}\n\n[Stop Hook] Typecheck failed. Assess whether these errors are related to changes you made this session - if not, mention them to the user and stop."
2323+}
2424+EOF
2525+exit 2
···155155- **Use "mana value" (mv) not "CMC"** - Scryfall still uses `cmc` in their API, but the official MTG terminology changed in 2021. Use `mv` or `manavalue` in code, comments, and UI. The search parser accepts both but prefer `mv`.
156156157157### Code Standards
158158+- **Stay focused on your current task** - If a global check (typecheck, lint) reports errors in files you haven't modified in this session, don't automatically fix them—mention them and let the user decide. Errors in files you did modify are your responsibility to fix. When in doubt, ask
158159- **This is a TypeScript project** - ALL code (including scripts) must use TypeScript with proper types
159160- **Use `nix-shell -p <package>` for missing commands** - If a command isn't in PATH, use nix-shell to get it temporarily
160161- **Prefer functional style over exceptions** - Avoid throwing errors for control flow. Use type predicates, Option/Result patterns, and early returns instead. Throwing is like GOTO—it breaks local reasoning and makes code harder to follow