Skip to content

Conversation

@lurenss
Copy link

@lurenss lurenss commented Dec 29, 2025

Summary

Fix the ralph-wiggum plugin's /ralph-loop command which fails to execute due to Claude Code's security restrictions on multi-line bash commands.

Problem

When running /ralph-loop, users receive:

Error: Bash command permission check failed ... Command contains newlines that could separate multiple commands

This is because Claude Code blocks bash commands that contain newlines for security reasons (to prevent command chaining attacks).

Solution

Convert the multi-line bash command block in commands/ralph-loop.md to a single line using && operators to chain commands, which is allowed by Claude Code's security model.

Before (broken):

"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS

if [ -f .claude/ralph-loop.local.md ]; then
  # multiple lines...
fi

After (fixed):

"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS && if [ -f .claude/ralph-loop.local.md ]; then ...; fi

Test plan

  • Run /ralph-wiggum:ralph-loop "test task" --completion-promise "DONE"
  • Verify loop initializes correctly without the newline error
  • Verify completion promise instructions display correctly

🤖 Generated with Claude Code

The ralph-loop command fails with 'Command contains newlines that
could separate multiple commands' error because Claude Code's
security restrictions block multi-line bash commands.

This fix converts the bash block to a single line using && chaining
while preserving all functionality.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@TheNumberOne TheNumberOne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm. Also, it solves the problem I am running into lol

echo "═══════════════════════════════════════════════════════════"
fi
fi
"${CLAUDE_PLUGIN_ROOT}/scripts/setup-ralph-loop.sh" $ARGUMENTS && if [ -f .claude/ralph-loop.local.md ]; then PROMISE=$(grep '^completion_promise:' .claude/ralph-loop.local.md | sed 's/completion_promise: *//' | sed 's/^"\(.*\)"$/\1/'); if [ -n "$PROMISE" ] && [ "$PROMISE" != "null" ]; then echo "" && echo "═══════════════════════════════════════════════════════════" && echo "CRITICAL - Ralph Loop Completion Promise" && echo "═══════════════════════════════════════════════════════════" && echo "" && echo "To complete this loop, output this EXACT text:" && echo " <promise>$PROMISE</promise>" && echo "" && echo "STRICT REQUIREMENTS (DO NOT VIOLATE):" && echo " ✓ Use <promise> XML tags EXACTLY as shown above" && echo " ✓ The statement MUST be completely and unequivocally TRUE" && echo " ✓ Do NOT output false statements to exit the loop" && echo " ✓ Do NOT lie even if you think you should exit" && echo "" && echo "IMPORTANT - Do not circumvent the loop:" && echo " Even if you believe you're stuck, the task is impossible," && echo " or you've been running too long - you MUST NOT output a" && echo " false promise statement. The loop is designed to continue" && echo " until the promise is GENUINELY TRUE. Trust the process." && echo "" && echo " If the loop should stop, the promise statement will become" && echo " true naturally. Do not force it by lying." && echo "═══════════════════════════════════════════════════════════"; fi; fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would probably be better if this was moved to the setup-ralph-loop.sh script.

delikat added a commit to delikat/claude-code that referenced this pull request Dec 31, 2025
Remove ```! code blocks from command files that caused permission check
failures. Claude Code's security model rejects multi-line bash commands,
and the auto-execute syntax was being included in permission validation.

Changes:
- Extract multi-line bash from command files to external scripts
- Create scripts/cancel-ralph.sh for cancellation logic
- Move completion promise display to setup-ralph-loop.sh
- Scope allowed-tools to specific script paths for security
- Add bash prefix to hooks.json for Windows compatibility
- Use #!/usr/bin/env bash for portability across systems
- Use heredoc for static text to prevent variable interpolation bugs

Based on patterns from PRs anthropics#59, anthropics#58, anthropics#72, anthropics#89, anthropics#15845, anthropics#15731.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@amorriscode
Copy link
Contributor

Closing in favour of #16320

@amorriscode amorriscode closed this Jan 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants