Documentation
¶
Overview ¶
Package loop provides the command for generating Ralph loop scripts.
A Ralph loop is an iterative development technique where an AI assistant runs repeatedly with the same prompt until a completion signal is detected. This enables autonomous development where the AI builds on its previous work across multiple iterations.
How It Works ¶
The generated script:
- Reads the prompt file (default: PROMPT.md)
- Runs the AI tool with the prompt
- Checks output for a completion signal
- Repeats until signal is detected or max iterations reached
Supported Tools ¶
The loop command generates scripts for different AI tools:
- claude: Claude Code CLI (default)
- aider: Aider AI pair programming tool
- generic: Template for custom tools
Completion Signal ¶
The completion signal (default: "SYSTEM_CONVERGED") indicates the AI has finished its work. The AI should output this signal when it determines that the task is complete. The loop script watches for this signal and exits when detected.
File Organization ¶
- loop.go: Command definition and flag handling
- run.go: Main loop script generation logic
- script.go: Shell script templates for each tool
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cmd ¶
Cmd returns the "ctx loop" command for generating Ralph loop scripts.
The command generates a shell script that runs an AI assistant in a loop until a completion signal is detected, enabling iterative development where the AI builds on previous work.
Flags:
- --prompt, -p: Prompt file to use (default "PROMPT.md")
- --tool, -t: AI tool - claude, aider, or generic (default "claude")
- --max-iterations, -n: Maximum iterations, 0 for unlimited (default 0)
- --completion, -c: Completion signal to detect (default "SYSTEM_CONVERGED")
- --output, -o: Output script filename (default "loop.sh")
Returns:
- *cobra.Command: Configured loop command with flags registered
Types ¶
This section is empty.