File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed
Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -1195,6 +1195,20 @@ IMPORTANT: The commit message must NOT contain the literal string \".humanize\"
11951195 load_and_render_safe " $TEMPLATE_DIR " " block/git-add-humanize.md" " $fallback "
11961196}
11971197
1198+ # Standard message for blocking direct execution of hook scripts
1199+ # Usage: stop_hook_direct_execution_blocked_message
1200+ stop_hook_direct_execution_blocked_message () {
1201+ local fallback=" # Direct Execution of Hook Scripts Blocked
1202+
1203+ You are attempting to directly execute a hook script via Bash. This is not allowed during an active loop.
1204+
1205+ Hook scripts are managed by the hooks system and are triggered automatically at the appropriate time. You should NOT execute them manually.
1206+
1207+ Simply complete your work and end your response. The hooks system will handle the rest automatically."
1208+
1209+ load_and_render_safe " $TEMPLATE_DIR " " block/stop-hook-direct-execution.md" " $fallback "
1210+ }
1211+
11981212# Check if a shell command attempts to modify a file matching the given pattern
11991213# Usage: command_modifies_file "$command_lower" "goal-tracker\.md"
12001214# Returns 0 if the command tries to modify the file, 1 otherwise
Original file line number Diff line number Diff line change @@ -69,6 +69,18 @@ if [[ -z "$ACTIVE_LOOP_DIR" ]] && [[ -z "$ACTIVE_PR_LOOP_DIR" ]]; then
6969 exit 0
7070fi
7171
72+ # ========================================
73+ # Block Direct Execution of Hook Scripts
74+ # ========================================
75+ # Prevents Claude from manually running stop hook or stop gate scripts.
76+ # These scripts should only be invoked by the hooks system, not via Bash.
77+
78+ BLOCKED_HOOK_SCRIPTS=" (loop-codex-stop-hook\.sh|pr-loop-stop-hook\.sh|rlcr-stop-gate\.sh)"
79+ if echo " $COMMAND_LOWER " | grep -qE " $BLOCKED_HOOK_SCRIPTS " ; then
80+ stop_hook_direct_execution_blocked_message >&2
81+ exit 2
82+ fi
83+
7284# ========================================
7385# RLCR Loop Specific Checks
7486# ========================================
Original file line number Diff line number Diff line change 1+ # Direct Execution of Hook Scripts Blocked
2+
3+ You are attempting to directly execute a hook script via Bash. This is not allowed during an active loop.
4+
5+ Hook scripts are managed by the hooks system and are triggered automatically at the appropriate time. You should NOT execute them manually.
6+
7+ Simply complete your work and end your response. The hooks system will handle the rest automatically.
You can’t perform that action at this time.
0 commit comments