name: ralph
description: "Generate Claude Code, Gemini CLI, or Grok CLI automation loop commands. Asks questions about your requirements and outputs a ready-to-run command for PowerShell, Windows CMD, or Bash/Linux."
allowed-tools:
Generate optimized loop commands for automating Claude Code, Gemini CLI, or Grok CLI with PROMPT.md.
Use AskUserQuestion:
Store the choice for later.
Use AskUserQuestion based on AI tool choice:
If Claude Code selected:
If Gemini CLI selected:
If Grok CLI selected:
Store the choice for later.
Use AskUserQuestion:
Store the choice for later.
Use AskUserQuestion:
Use AskUserQuestion:
Use AskUserQuestion:
Use AskUserQuestion:
Based on selected features, ask for values:
If fixed iterations selected:
If time limit selected:
If delay selected:
If file monitoring selected:
Build the appropriate command based on:
IMPORTANT - Command Syntax:
For Claude Code (PowerShell/Bash):
Use claude-code (NOT claude -p) to accept piped input. The -p flag requires an argument, not pipe.
Get-Content PROMPT.md -Raw | claude-code --dangerously-skip-permissionsGet-Content PROMPT.md -Raw | claude-code --model haiku --dangerously-skip-permissionsGet-Content PROMPT.md -Raw | claude-code --model sonnet --dangerously-skip-permissionsGet-Content PROMPT.md -Raw | claude-code --model opus --dangerously-skip-permissionsFor Claude Code (Bash):
cat PROMPT.md | claude-code --dangerously-skip-permissionscat PROMPT.md | claude-code --model haiku --dangerously-skip-permissionsFor Gemini CLI (PowerShell):
Gemini CLI accepts stdin piping.
Get-Content PROMPT.md -Raw | gemini --yoloGet-Content PROMPT.md -Raw | gemini --model gemini-3-flash --yoloGet-Content PROMPT.md -Raw | gemini --model gemini-3-pro --yoloGet-Content PROMPT.md -Raw | gemini --model gemini-2.5-flash --yoloGet-Content PROMPT.md -Raw | gemini --model gemini-2.5-pro --yoloFor Grok CLI (PowerShell):
Get-Content PROMPT.md -Raw | grok-auto (uses default model from GROK_MODEL env var, auto-approves permissions)Get-Content PROMPT.md -Raw | grok-auto -m grok-code-fast-1Get-Content PROMPT.md -Raw | grok-auto -m grok-4-latestGet-Content PROMPT.md -Raw | grok-auto -m grok-betaIMPORTANT - Placeholder Replacement:
For Claude Code: Replace [AI_COMMAND_WITH_PROMPT] with the FULL command including the prompt argument:
claude -p (Get-Content PROMPT.md -Raw) --dangerously-skip-permissionsclaude -p (Get-Content PROMPT.md -Raw) --model haiku --dangerously-skip-permissionsFor Gemini CLI: Replace [AI_COMMAND_WITH_PROMPT] with piped command:
Get-Content PROMPT.md -Raw | gemini --yoloGet-Content PROMPT.md -Raw | gemini --model gemini-3-flash --yoloFor Grok CLI: Replace [AI_COMMAND_WITH_PROMPT] with piped command:
Get-Content PROMPT.md -Raw | grok-autoGet-Content PROMPT.md -Raw | grok-auto -m grok-4-latestCRITICAL: Claude Code requires the prompt as a command-line argument. Piping does NOT work with claude -p.
PowerShell - Simple Fixed:
for ($i=1; $i -le N; $i++) { $start = Get-Date; Write-Host "`n=== Run $i/N ===" -ForegroundColor Cyan; [AI_COMMAND_WITH_PROMPT]; $duration = ((Get-Date) - $start).TotalSeconds; Write-Host "⏱️ Time: $([math]::Round($duration, 2))s" -ForegroundColor Magenta }
PowerShell - Simple Fixed + Delay:
for ($i=1; $i -le N; $i++) { $start = Get-Date; Write-Host "`n=== Run $i/N ===" -ForegroundColor Cyan; [AI_COMMAND_WITH_PROMPT]; $duration = ((Get-Date) - $start).TotalSeconds; Write-Host "⏱️ Time: $([math]::Round($duration, 2))s" -ForegroundColor Magenta; if ($i -lt N) { Write-Host "⏸️ Waiting X seconds..." -ForegroundColor Yellow; Start-Sleep -Seconds X } }
PowerShell - Simple Infinite + Delay:
$i=1; while ($true) { $start = Get-Date; Write-Host "`n=== Run $i ===" -ForegroundColor Cyan; [AI_COMMAND_WITH_PROMPT]; $duration = ((Get-Date) - $start).TotalSeconds; Write-Host "⏱️ Time: $([math]::Round($duration, 2))s" -ForegroundColor Magenta; Write-Host "⏸️ Waiting X seconds..." -ForegroundColor Yellow; Start-Sleep -Seconds X; $i++ }
PowerShell - Advanced Full Control:
$end = (Get-Date).AddMinutes(M); for ($i=1; $i -le N -and (Get-Date) -lt $end -and -not (Test-Path STOP.txt); $i++) { $start = Get-Date; Write-Host "`n[$(Get-Date -Format 'HH:mm:ss')] Run $i" -ForegroundColor Cyan; [AI_COMMAND_WITH_PROMPT]; $duration = ((Get-Date) - $start).TotalSeconds; Write-Host "⏱️ Time: $([math]::Round($duration, 2))s" -ForegroundColor Magenta; if ($i -lt N) { Write-Host "⏸️ Waiting X seconds..." -ForegroundColor Yellow; Start-Sleep -Seconds X } }; Write-Host "`n✅ Complete!" -ForegroundColor Green
CMD - Simple Fixed:
for /L %i in (1,1,N) do @(echo. & echo === Run %i === & type PROMPT.md | [AI_COMMAND])
Note: CMD has limited capabilities. For time tracking, recommend PowerShell.
CMD - Simple Infinite + Delay:
for /L %i in (1,0,2) do @(echo. & echo === Run %i === & type PROMPT.md | [AI_COMMAND] & timeout /t X /nobreak > nul)
CMD - Advanced:
for /L %i in (1,1,N) do @(if exist STOP.txt exit & echo. & echo [%time%] Run %i & type PROMPT.md | [AI_COMMAND] & timeout /t X /nobreak > nul)
Note: For time tracking, use PowerShell (see RalphPowerShellComands.md).
Bash - Simple Fixed:
for i in {1..N}; do echo -e "\n=== Run $i/N ==="; start=$(date +%s); cat PROMPT.md | [AI_COMMAND]; dur=$(($(date +%s) - start)); echo "⏱️ Time: ${dur}s"; done
Bash - Simple Fixed + Delay:
for i in {1..N}; do echo -e "\n=== Run $i/N ==="; start=$(date +%s); cat PROMPT.md | [AI_COMMAND]; dur=$(($(date +%s) - start)); echo "⏱️ Time: ${dur}s"; [ $i -lt N ] && { echo "⏸️ Waiting X seconds..."; sleep X; }; done
Bash - Simple Infinite + Delay:
i=1; while :; do echo -e "\n=== Run $i ==="; start=$(date +%s); cat PROMPT.md | [AI_COMMAND]; dur=$(($(date +%s) - start)); echo "⏱️ Time: ${dur}s"; echo "⏸️ Waiting X seconds..."; sleep X; ((i++)); done
Bash - Advanced:
end=$(($(date +%s) + M*60)); for i in {1..N}; do [ $(date +%s) -ge $end ] && break; [ -f STOP.txt ] && break; echo -e "\n[$(date +%H:%M:%S)] Run $i"; start=$(date +%s); cat PROMPT.md | [AI_COMMAND]; dur=$(($(date +%s) - start)); echo "⏱️ Time: ${dur}s"; [ $i -lt N ] && { echo "⏸️ Waiting X seconds..."; sleep X; }; done; echo -e "\n✅ Complete!"
Create a timestamped filename in the format: ralphcommand-YYYY-MM-DD-HHMMSS.md
Example: ralphcommand-2026-01-14-233045.md
Use the Write tool to create this file in the current directory with:
File structure:
# Ralph Command
Generated: [timestamp]
Shell: [PowerShell/CMD/Bash]
## Command
[THE ACTUAL COMMAND]
## How to run
1. Make sure you have a PROMPT.md file in this directory
2. Copy the command above
3. Paste into your [PowerShell/CMD/Bash] terminal
4. Press Enter
## How to stop
- Press Ctrl+C at any time
[- OR create STOP.txt: `echo $null > STOP.txt` / `touch STOP.txt`] (if stop file enabled)
## What it does
Runs [claude/gemini/grok] with PROMPT.md as input [N times / for M minutes / until stopped].
[Pauses X seconds between runs.]
[Shows timestamp and run number.]
[Displays execution time for each run.]
After creating the file, tell the user the exact filename created:
✅ Created ralphcommand-YYYY-MM-DD-HHMMSS.md in your current directory!
The file contains your command ready to run. Just open it and copy the command.
For more variations and explanations, see:
- RalphPowerShellComands.md - Full PowerShell reference
- RalphWindowsCommands.md - Full CMD reference
- RalphLinuxCommands.md - Full Bash reference
- RalphGemini.md - Full Gemini CLI guide
- RalphGrok.md - Full Grok CLI guide
claude -p (Get-Content PROMPT.md -Raw) --dangerously-skip-permissions. Piping does NOT work with claude -p.Get-Content PROMPT.md -Raw | gemini --yolo or Get-Content PROMPT.md -Raw | grok-auto.--model flagclaude -p (Get-Content PROMPT.md -Raw) --dangerously-skip-permissionsclaude -p (Get-Content PROMPT.md -Raw) --model --dangerously-skip-permissions haiku, sonnet, opusGet-Content PROMPT.md -Raw | gemini --yoloGet-Content PROMPT.md -Raw | gemini --model --yolo gemini-3-flash, gemini-3-pro, gemini-2.5-flash, gemini-2.5-pro-p flag is deprecated in Geminigrok-auto PowerShell function which calls xAI API directly (perfect for automation)Get-Content PROMPT.md -Raw | grok-auto (no -m flag, uses GROK_MODEL env var if set)Get-Content PROMPT.md -Raw | grok-auto -m grok-code-fast-1, grok-4-latest, grok-beta, grok-4grok-auto is a PowerShell function that calls the xAI API directly (no CLI needed)Get-Date (PowerShell) or date +%s (Bash)ralphcommand-YYYY-MM-DD-HHMMSS.md[AI_COMMAND_WITH_PROMPT] with the full claude command including prompt argument[AI_COMMAND] with the command after the pipe共 1 个版本