Files
cline--cline/sdk/examples/hooks/PreToolUse_RequireReview.sh
2026-07-13 12:52:40 +08:00

20 lines
642 B
Bash
Executable File

#!/usr/bin/env bash
# Cline Hook: PreToolUse (Require Review)
# Pauses for review before writing to critical files
# Copy to ~/.cline/hooks/PreToolUse.sh and chmod +x
input=$(cat)
tool=$(echo "$input" | jq -r '.tool_call.name // ""')
file=$(echo "$input" | jq -r '.tool_call.input.filePath // ""')
# Require review for critical files
if [ "$tool" = "editor" ] || [ "$tool" = "write_file" ]; then
if [[ $file =~ (package\.json|tsconfig|\.env|secrets|config\.(ts|js)|\.cline) ]]; then
jq -n --arg file "$file" '{review: true, context: "This will modify a critical file: \($file)"}'
exit 0
fi
fi
# Allow everything else
echo '{}'