loop

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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:

  1. Reads the prompt file (default: PROMPT.md)
  2. Runs the AI tool with the prompt
  3. Checks output for a completion signal
  4. 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

func Cmd() *cobra.Command

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL