spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

fix(ralph-wiggum): move multi-line bash from command to setup script (#16320)Browse files
Fixes #12170

The ralph-wiggum slash commands had multi-line bash scripts in their
```! blocks. Claude Code's security check blocks commands with
newlines to prevent command injection, causing the error:

  "Command contains newlines that could separate multiple commands"

Changes:

ralph-loop.md:
- Remove multi-line bash from code block
- Keep single-line call to setup script
- Keep scoped allowed-tools for security

cancel-ralph.md:
- Replace multi-line bash with step-by-step instructions
- Tighten allowed-tools to specific file paths

setup-ralph-loop.sh:
- Add completion promise display logic (moved from ralph-loop.md)
- Uses COMPLETION_PROMISE variable directly instead of reading from file
Anthony Morris authored on Jan 5, 2026 · GitHub committed on Jan 5, 2026 parent d213a74 · commit 5c92b97cc42a
3 changed files+35 -46compared with d213a74
Mplugins/ralph-wiggum/commands/cancel-ralph.md
Mplugins/ralph-wiggum/commands/ralph-loop.md
Mplugins/ralph-wiggum/scripts/setup-ralph-loop.sh
@@ -1,26 +1,18 @@
11 ---
22 description: "Cancel active Ralph Wiggum loop"
3-allowed-tools: ["Bash"]
3+allowed-tools: ["Bash(test -f .claude/ralph-loop.local.md:*)", "Bash(rm .claude/ralph-loop.local.md)", "Read(.claude/ralph-loop.local.md)"]
44 hide-from-slash-command-tool: "true"
55 ---
66
77 # Cancel Ralph
88
9-```!
10-if [[ -f .claude/ralph-loop.local.md ]]; then
11- ITERATION=$(grep '^iteration:' .claude/ralph-loop.local.md | sed 's/iteration: *//')
12- echo "FOUND_LOOP=true"
13- echo "ITERATION=$ITERATION"
14-else
15- echo "FOUND_LOOP=false"
16-fi
17-```
9+To cancel the Ralph loop:
1810
19-Check the output above:
11+1. Check if `.claude/ralph-loop.local.md` exists using Bash: `test -f .claude/ralph-loop.local.md && echo "EXISTS" || echo "NOT_FOUND"`
2012
21-1. **If FOUND_LOOP=false**:
22- - Say "No active Ralph loop found."
13+2. **If NOT_FOUND**: Say "No active Ralph loop found."
2314
24-2. **If FOUND_LOOP=true**:
25- - Use Bash: `rm .claude/ralph-loop.local.md`
26- - Report: "Cancelled Ralph loop (was at iteration N)" where N is the ITERATION value from above.
15+3. **If EXISTS**:
16+ - Read `.claude/ralph-loop.local.md` to get the current iteration number from the `iteration:` field
17+ - Remove the file using Bash: `rm .claude/ralph-loop.local.md`
18+ - Report: "Cancelled Ralph loop (was at iteration N)" where N is the iteration value
@@ -11,36 +11,6 @@
1111
1212 ```!
1313 "${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS
14-
15-# Extract and display completion promise if set
16-if [ -f .claude/ralph-loop.local.md ]; then
17- PROMISE=$(grep '^completion_promise:' .claude/ralph-loop.local.md | sed 's/completion_promise: *//' | sed 's/^"\(.*\)"$/\1/')
18- if [ -n "$PROMISE" ] && [ "$PROMISE" != "null" ]; then
19- echo ""
20- echo "═══════════════════════════════════════════════════════════"
21- echo "CRITICAL - Ralph Loop Completion Promise"
22- echo "═══════════════════════════════════════════════════════════"
23- echo ""
24- echo "To complete this loop, output this EXACT text:"
25- echo " <promise>$PROMISE</promise>"
26- echo ""
27- echo "STRICT REQUIREMENTS (DO NOT VIOLATE):"
28- echo " ✓ Use <promise> XML tags EXACTLY as shown above"
29- echo " ✓ The statement MUST be completely and unequivocally TRUE"
30- echo " ✓ Do NOT output false statements to exit the loop"
31- echo " ✓ Do NOT lie even if you think you should exit"
32- echo ""
33- echo "IMPORTANT - Do not circumvent the loop:"
34- echo " Even if you believe you're stuck, the task is impossible,"
35- echo " or you've been running too long - you MUST NOT output a"
36- echo " false promise statement. The loop is designed to continue"
37- echo " until the promise is GENUINELY TRUE. Trust the process."
38- echo ""
39- echo " If the loop should stop, the promise statement will become"
40- echo " true naturally. Do not force it by lying."
41- echo "═══════════════════════════════════════════════════════════"
42- fi
43-fi
4414 ```
4515
4616 Please work on the task. When you try to exit, the Ralph loop will feed the SAME PROMPT back to you for the next iteration. You'll see your previous work in files and git history, allowing you to iterate and improve.
@@ -174,3 +174,30 @@
174174 echo ""
175175 echo "$PROMPT"
176176 fi
177+
178+# Display completion promise requirements if set
179+if [[ "$COMPLETION_PROMISE" != "null" ]]; then
180+ echo ""
181+ echo "═══════════════════════════════════════════════════════════"
182+ echo "CRITICAL - Ralph Loop Completion Promise"
183+ echo "═══════════════════════════════════════════════════════════"
184+ echo ""
185+ echo "To complete this loop, output this EXACT text:"
186+ echo " <promise>$COMPLETION_PROMISE</promise>"
187+ echo ""
188+ echo "STRICT REQUIREMENTS (DO NOT VIOLATE):"
189+ echo " ✓ Use <promise> XML tags EXACTLY as shown above"
190+ echo " ✓ The statement MUST be completely and unequivocally TRUE"
191+ echo " ✓ Do NOT output false statements to exit the loop"
192+ echo " ✓ Do NOT lie even if you think you should exit"
193+ echo ""
194+ echo "IMPORTANT - Do not circumvent the loop:"
195+ echo " Even if you believe you're stuck, the task is impossible,"
196+ echo " or you've been running too long - you MUST NOT output a"
197+ echo " false promise statement. The loop is designed to continue"
198+ echo " until the promise is GENUINELY TRUE. Trust the process."
199+ echo ""
200+ echo " If the loop should stop, the promise statement will become"
201+ echo " true naturally. Do not force it by lying."
202+ echo "═══════════════════════════════════════════════════════════"
203+fi