👁️
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve stop hooks

+53 -2
+25
.claude/hooks/stop-test.sh
··· 1 + #!/usr/bin/env bash 2 + set -e 3 + 4 + input=$(cat) 5 + if [ "$(echo "$input" | jq -r '.stop_hook_active')" = "true" ]; then 6 + exit 0 7 + fi 8 + 9 + output=$(npm run test -- --changed 2>&1) && exit 0 10 + 11 + # Get the failure summary (last 30 lines usually has the good stuff) 12 + errors=$(echo "$output" | tail -30) 13 + 14 + # Escape for JSON 15 + escaped=$(echo "$errors" | jq -Rs .) 16 + # Remove surrounding quotes that jq adds 17 + escaped=${escaped:1:-1} 18 + 19 + cat <<EOF 20 + { 21 + "decision": "block", 22 + "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." 23 + } 24 + EOF 25 + exit 2
+25
.claude/hooks/stop-typecheck.sh
··· 1 + #!/usr/bin/env bash 2 + set -e 3 + 4 + input=$(cat) 5 + if [ "$(echo "$input" | jq -r '.stop_hook_active')" = "true" ]; then 6 + exit 0 7 + fi 8 + 9 + output=$(npm run typecheck:faster 2>&1) && exit 0 10 + 11 + # Extract just the error lines (skip npm boilerplate) 12 + errors=$(echo "$output" | grep -E "error TS[0-9]+:" | head -15) 13 + 14 + # Escape for JSON 15 + escaped=$(echo "$errors" | jq -Rs .) 16 + # Remove surrounding quotes that jq adds 17 + escaped=${escaped:1:-1} 18 + 19 + cat <<EOF 20 + { 21 + "decision": "block", 22 + "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." 23 + } 24 + EOF 25 + exit 2
+2 -2
.claude/settings.json
··· 16 16 "hooks": [ 17 17 { 18 18 "type": "command", 19 - "command": "npm run typecheck:faster 1>&2 || exit 2" 19 + "command": ".claude/hooks/stop-typecheck.sh" 20 20 }, 21 21 { 22 22 "type": "command", 23 - "command": "npm run test -- --changed 1>&2 || exit 2" 23 + "command": ".claude/hooks/stop-test.sh" 24 24 } 25 25 ] 26 26 }
+1
CLAUDE.md
··· 155 155 - **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`. 156 156 157 157 ### Code Standards 158 + - **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 158 159 - **This is a TypeScript project** - ALL code (including scripts) must use TypeScript with proper types 159 160 - **Use `nix-shell -p <package>` for missing commands** - If a command isn't in PATH, use nix-shell to get it temporarily 160 161 - **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