SuperAPI AI Directory

ralph-loop

Agents & models

View repository

Updated 10-15 21:38

About this skill

Ralph Loop

An autonomous iterative development loop based on Geoffrey Huntley's Ralph technique.

Core Principle: Repeatedly execute the same task, but each iteration looks at the previous results (files, change history) and improves incrementally.


Invocation Format

/ralph-loop <작업 설명> [--max-iterations N] [--completion-promise "완료 문구"]

Example:

/ralph-loop "할 일 관리 REST API 구현해줘" --max-iterations 5
/ralph-loop "auth 버그 고쳐줘" --completion-promise "FIXED" --max-iterations 10
/ralph-loop "코드 리팩토링해줘" --max-iterations 3

Default:

  • --max-iterations: 5
  • --completion-promise: None (runs until max-iterations)

Storage Structure

[프로젝트 루트]/.ralph/
  ├── PROMPT.md       ← 작업 목표 (고수준)
  ├── fix_plan.md     ← 구체적 작업 목록 (체크리스트)
  ├── AGENT.md        ← 빌드/테스트 명령어
  └── logs/
      └── iteration-N.md   ← 이터레이션별 진행 기록

Execution Flow

Phase 0: Argument Parsing

When the skill is invoked, extract the following from the user input:

  1. Task description (<작업 설명>): The core goal of the task to perform
  2. max-iterations (--max-iterations N): Maximum number of iterations. Defaults to 5 if absent
  3. completion-promise (--completion-promise "문구"): Completion signal phrase. If absent, runs only until max-iterations

If the arguments are ambiguous, confirm with AskUserQuestion.


Phase 1: Setup

.ralph/ Create the directory and make the files below.

.ralph/PROMPT.md creation

# Ralph Loop - 작업 목표

## 작업 설명
[사용자가 입력한 작업 설명 그대로]

## 완료 조건
[--completion-promise가 있으면: "아래 문구를 출력하면 완료: <promise>문구</promise>"]
[없으면: "max-iterations 도달 시 완료"]

## 규칙
- 매 이터레이션 시작 시 .ralph/fix_plan.md를 읽고 미완료 항목을 확인한다
- 작업 후 .ralph/fix_plan.md에서 완료된 항목을 체크한다
- 이터레이션 결과를 .ralph/logs/iteration-N.md에 기록한다
- 완료 신호는 <promise>문구</promise> 형식으로 출력한다

.ralph/fix_plan.md creation

Analyze the task description and break it down into concrete subtasks:

# Fix Plan

## 상태: 진행중
## 마지막 업데이트: [현재 날짜]

## 작업 목록

- [ ] [하위 작업 1]
- [ ] [하위 작업 2]
- [ ] [하위 작업 3]
...

## 완료 기록
(완료된 항목이 여기로 이동)

.ralph/AGENT.md creation

# Agent Instructions

이 프로젝트에서 사용할 주요 명령어:
- 빌드: [감지된 빌드 명령, 없으면 "N/A"]
- 테스트: [감지된 테스트 명령, 없으면 "N/A"]
- 실행: [감지된 실행 명령, 없으면 "N/A"]

.ralph/logs/ Also create the directory.

After setup is complete, report to the user:

🔄 Ralph Loop 시작!

작업: [작업 설명]
최대 이터레이션: N회
완료 조건: [문구 or "N회 완료 후"]

.ralph/ 구조 생성 완료.
이터레이션 1 시작...

Phase 2: Iteration Loop

current_iteration = 1Starting from, repeat the following.

Execute each iteration

Execute the iteration with a Task agent:

Task(
  description="Ralph Loop 이터레이션 N",
  prompt="""
당신은 Ralph Loop의 이터레이션 N을 실행하는 에이전트입니다.

## 작업 목표
[PROMPT.md 내용]

## 현재 상태
[fix_plan.md 내용]

## 이전 이터레이션 요약
[iteration-(N-1).md 내용, 없으면 "첫 번째 이터레이션"]

## 지시사항

1. fix_plan.md에서 미완료 항목을 확인한다
2. 가장 중요한 미완료 항목부터 작업한다
3. 실제로 파일을 수정/생성하며 작업한다
4. 작업 완료 후 fix_plan.md에서 해당 항목을 [x]로 표시한다
5. .ralph/logs/iteration-N.md에 이터레이션 기록을 남긴다:
   - 이번에 한 작업
   - 완료된 항목
   - 남은 항목
   - 전체 진행률 (%)
   - [completion-promise가 있을 경우] 완료 조건 달성 여부

[completion-promise가 있을 경우]
완료 조건("문구")이 달성되면 반드시 다음 형식으로 출력하라:
<promise>문구</promise>

모든 작업이 완료되었다면 iteration 기록 마지막에 EXIT_SIGNAL: true를 추가하라.
"""
)

Check completion conditions

Check the agent output and iteration-N.md:

  1. If there is a completion-promise: If the agent output contains <promise>문구</promise>→ end loop
  2. fix_plan.md fully complete: If all items are [x]→ end loop
  3. EXIT_SIGNAL: true: If present in the iteration record → end loop
  4. max-iterations reached: current_iteration >= max_iterations → end loop

If none of the above conditions apply, current_iteration += 1 then run the next iteration.


Phase 3: Completion Report

After the loop ends, output the final report:

✅ Ralph Loop 완료!

작업: [작업 설명]
총 이터레이션: N회
종료 이유: [완료 조건 달성 / 전체 태스크 완료 / max-iterations 도달]

## 진행 요약
[각 이터레이션별 한 줄 요약]

## 최종 fix_plan.md 상태
[완료된 항목들]
[미완료 항목들 (있다면)]

## 생성/수정된 파일
[변경된 파일 목록]

다음 단계: [미완료 항목이 있다면 제안, 없다면 "모든 작업 완료"]

How to Abort

If the user aborts during the loop:

  1. Terminate after the current iteration completes
  2. Save the current state to fix_plan.md
  3. Output an abort report

/cancel-ralph or /ralph-cancel Handle the same way when called.


Cautions

  • Each iteration runs as an independent Task agent (context is shared through the previous iteration's files)
  • .ralph/ If the directory already exists, take over the existing fix_plan.md and continue
  • Recommended max-iterations values depending on the nature of the task: simple implementation 3-5 times, complex refactoring 5-10 times, bug fixing 3-7 times