Core plugin providing: - Skills: core CLI reference, PHP patterns, Go patterns - Commands: /core:remember for context persistence - Hooks: - PreToolUse: block dangerous commands (rm -rf, sed -i, grep -l |) - PreToolUse: enforce core CLI over raw go/php commands - PostToolUse: auto-format Go/PHP, check for debug statements - PostToolUse: warn about uncommitted work after git commit - PreCompact: save state to prevent amnesia after auto-compact - SessionStart: restore context from recent sessions (<3h) - MCP: core CLI server integration Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
27 lines
1 KiB
Bash
Executable file
27 lines
1 KiB
Bash
Executable file
#!/bin/bash
|
|
# Warn about debug statements left in code after edits
|
|
|
|
read -r input
|
|
FILE_PATH=$(echo "$input" | jq -r '.tool_input.file_path // empty')
|
|
|
|
if [[ -n "$FILE_PATH" && -f "$FILE_PATH" ]]; then
|
|
case "$FILE_PATH" in
|
|
*.go)
|
|
# Check for fmt.Println, log.Println debug statements
|
|
if grep -n "fmt\.Println\|log\.Println" "$FILE_PATH" 2>/dev/null | head -3 | grep -q .; then
|
|
echo "[Hook] WARNING: Debug prints found in $FILE_PATH" >&2
|
|
grep -n "fmt\.Println\|log\.Println" "$FILE_PATH" 2>/dev/null | head -3 >&2
|
|
fi
|
|
;;
|
|
*.php)
|
|
# Check for dd(), dump(), var_dump(), print_r()
|
|
if grep -n "dd(\|dump(\|var_dump(\|print_r(" "$FILE_PATH" 2>/dev/null | head -3 | grep -q .; then
|
|
echo "[Hook] WARNING: Debug statements found in $FILE_PATH" >&2
|
|
grep -n "dd(\|dump(\|var_dump(\|print_r(" "$FILE_PATH" 2>/dev/null | head -3 >&2
|
|
fi
|
|
;;
|
|
esac
|
|
fi
|
|
|
|
# Pass through the input
|
|
echo "$input"
|