Feature Request: File-Based Prompts for Ralph Wiggum Plugin
Feature Request: File-Based Prompts for Ralph Wiggum Plugin
Summary
Add support for reading complex multi-line prompts from files in the ralph-wiggum plugin, eliminating Bash parsing issues with structured instructions.
Problem
The current ralph-wiggum:ralph-loop implementation accepts prompts only as CLI arguments. This breaks with complex multi-line prompts due to Bash parsing limitations:
Current behavior:
# Simple prompt - Works ✅
/ralph-loop "Test framework parameter H1"
# Complex multi-line prompt - Fails ❌
/ralph-loop "Test 6 hypotheses (H11-H15, H20).
MEMORY CONTEXT:
- Ken Cheng style: MANDATORY (120)
- Concrete 80% minimum (117)
Each iteration:
1. Generate post
2. Evaluate with 3 personas
..."
# Error: Bash parse error - cannot handle newlines, special chars
Impact:
- Complex Ralph loops require careful escaping (error-prone)
- Multi-line structured instructions fail
- Copy-paste from files breaks formatting
- Limits Ralph's usability for sophisticated tasks
Proposed Solution
Add fallback: If no CLI arguments provided, read from state/ralph_current_prompt.txt:
# In setup-ralph-loop.sh, after parsing CLI arguments:
# If no prompt from args, try to read from file
if [[ -z "$PROMPT" ]]; then
# Check for saved Ralph Loop files
if [[ -f "state/ralph_current_prompt.txt" ]]; then
echo "📄 Reading prompt from state/ralph_current_prompt.txt..." >&2
PROMPT=$(cat state/ralph_current_prompt.txt)
# Also read config if available
if [[ -f "state/ralph_current_config.json" ]]; then
echo "📄 Reading config from state/ralph_current_config.json..." >&2
# Extract max_iterations if not already set
if [[ $MAX_ITERATIONS -eq 0 ]]; then
MAX_ITERATIONS=$(grep -o '"max_iterations":[[:space:]]*[0-9]*' state/ralph_current_config.json | grep -o '[0-9]*' || echo "0")
fi
# Extract completion_promise if not already set
if [[ "$COMPLETION_PROMISE" == "null" ]]; then
COMPLETION_PROMISE=$(grep -o '"completion_promise":[[:space:]]*"[^"]*"' state/ralph_current_config.json | sed 's/.*"completion_promise":[[:space:]]*"\([^"]*\)".*/\1/' || echo "null")
fi
echo "✅ Config loaded: max_iterations=$MAX_ITERATIONS, completion_promise=$COMPLETION_PROMISE" >&2
fi
fi
fi
Location to patch: setup-ralph-loop.sh, after line PROMPT="${PROMPT_PARTS[*]}" (~line 113)
Benefits
[1] Complex Prompts Work Seamlessly
# Create prompt file
echo "Complex multi-line prompt with:
- Memory context
- Structured instructions
- Special characters: \$, \", \`
- JSON snippets
- Code examples" > state/ralph_current_prompt.txt
# Run Ralph (auto-reads file!)
/ralph-loop
[2] Version Control Friendly
- Prompts can be versioned in Git
- Easy to review/edit in text editor
- Reusable templates
[3] Workflow Integration
Skills like ralph-builder can now:
- Generate complex Ralph prompts programmatically
- Save to
state/ralph_current_prompt.txt - Call
/ralph-loop(no CLI escaping needed!)
[4] Better UX
# Old way (error-prone):
/ralph-loop "Escape \"quotes\" and \$vars and \`backticks\`..."
# New way (just works):
# 1. Save prompt to file
# 2. /ralph-loop
Use Cases
Framework Optimization
# state/ralph_current_prompt.txt
Goal: Test 6 framework hypotheses (H11-H15, H20)
MEMORY CONTEXT (Phase 1):
- Ken Cheng MANDATORY (120)
- Concrete 80% minimum (117)
Each iteration:
1. Generate blog post
2. Spawn 3 parallel Task agents:
→ Evaluate as Alex CMO (0-50)
→ Evaluate as Victor CEO (0-50)
→ Evaluate as Mike Sales (0-50)
3. Aggregate scores
<promise>FRAMEWORK_OPTIMIZATION_COMPLETE</promise>
# Run
/ralph-loop # Auto-reads file!
Spec Execution (Multi-Phase)
# Orchestrator spawns Task agents per phase
# Each phase = fresh context (no bloat!)
Goal: Execute Spec 0076 autonomously
Each iteration (1 per phase):
1. Read plan.md → Find next incomplete phase
2. Spawn Task agent for Phase X:
→ Fresh context (0k → 40k → done)
3. Wait for <promise>PHASE_X_COMPLETE</promise>
4. Next phase
<promise>ALL_PHASES_COMPLETE</promise>
Backward Compatibility
✅ Fully backward compatible:
- CLI arguments still work as before
- File-reading is fallback only (when no CLI args)
- No breaking changes to existing workflows
Test:
# Old way still works
/ralph-loop "Simple prompt" ✅
# New way (auto-detects file)
/ralph-loop ✅ (reads from state/ralph_current_prompt.txt if exists)
Implementation Notes
Error Handling
Updated error message when no prompt found:
if [[ -z "$PROMPT" ]]; then
echo "❌ Error: No prompt provided" >&2
echo "" >&2
echo " Option 1 - Command line:" >&2
echo " /ralph-loop Build a REST API for todos" >&2
echo "" >&2
echo " Option 2 - From file (auto-detected):" >&2
echo " Create state/ralph_current_prompt.txt with your prompt" >&2
echo " Optionally: state/ralph_current_config.json with config" >&2
echo " Then just: /ralph-loop (no arguments needed!)" >&2
exit 1
fi
Config File Format
Optional state/ralph_current_config.json:
{
"max_iterations": 50,
"completion_promise": "TASK_COMPLETE",
"generated_at": "2025-12-30T15:00:00Z",
"generated_by": "ralph-builder v1.3",
"mission": "Framework optimization Phase 2"
}
Testing
Tested on:
- WSL2 Ubuntu (Linux 6.6.87.2-microsoft-standard-WSL2)
- Claude Code CLI
- ralph-wiggum plugin versions:
6d3752c000e2andunknown
Test cases:
- ✅ Simple CLI prompt (backward compat)
- ✅ Multi-line file prompt (new feature)
- ✅ File + config.json (auto-load config)
- ✅ No prompt at all (clear error message)
Additional Context
This enhancement enables autonomous multi-session execution patterns:
- Ralph orchestrator spawns Task agents per phase/task
- Each agent gets fresh context (no bloat!)
- Memory handoff via JSON files
- Scales to complex multi-phase workflows
Real-world impact:
- Spec execution: 180k tokens (single session) → 5-10k tokens (orchestrator) + fresh agents
- Framework testing: Sequential evaluations → Parallel Task agents (3x faster)
- Quality: No context degradation from bloat
Related Work
Skills leveraging this feature:
ralph-builder- Framework optimization loopsspec-executor- Multi-phase Spec executionralph-hypothesis-generator- Generates complex Ralph prompts
References
- Claude Code: https://github.com/anthropics/claude-code
- Ralph Wiggum technique: https://docs.anthropic.com/claude/docs/ralph-wiggum
---
Would love to see this enhancement merged to enable more sophisticated autonomous workflows! 🚀
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗