ralph-init

A command that sets up a RALPH loop, an approach where an agent repeats small tasks and saves its progress in project files and Git history.

In plain words
What is it for?
Use it to create the .ralph/ files and runner script needed to plan, repeat, monitor, and record an automated development task.
Why use it?
It turns a large piece of work into a tracked specification, task list, instructions, progress log, and machine-readable status file.

Command for Claude Code

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/pproenca/agent-tui/ralph-init
Clone the repo
git clone --depth 1 https://github.com/pproenca/agent-tui

Made for: Claude Code.

Per session 21 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,350 The whole file, excluding the scripts and references it only reads on demand.
Security scan B 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00021 $0.03350
Opus 5 $0.00010 $0.01675
Sonnet 5 $0.00004 $0.00670
Haiku 4.5 $0.00002 $0.00335

Measured 3d ago against content hash d23d449a54df, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade B, and why

ralph-init scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Asks the agent to reveal its instructionsmediumSystem prompt leakage

Directions to print, repeat or translate the system prompt extract configuration the operator did not intend to expose.

# .ralph/ralph-loop.sh --dry-run # Show prompt without running
.claude/commands/ralph-init.md · 459 lines

How it starts

The opening of the file, as written. The whole thing — 459 lines — stays where its author put it; the contents beside it link to each section on GitHub.

RALPH Loop Initialization

Create a complete RALPH (Repetitive Autonomous Loop with Persistent History) setup in .ralph/ directory.

What is RALPH?

RALPH is an autonomous AI agent pattern where progress persists in files and git history, not the LLM context. Each iteration gets fresh context, picks up from files, implements one task, commits, and repeats until done.

Core Principle

Files are memory. Progress lives in:

  • SPEC.md - The PRD/requirements (what to build)
  • TODO.md - Prioritized task checklist (what's left)
  • PROMPT.md - Instructions for each iteration (how to work)
  • progress.txt - Learnings log (what was discovered)
  • status.json - Machine-readable state (for monitoring)
  • Git history - What's been done

Interactive Setup Flow

Ask these questions using AskUserQuestion tool:

1. Task Identity

  • Task name: Short identifier (e.g., "workspace-migration", "auth-feature")
  • Description: One-line summary of what RALPH will accomplish

2. Specification Details

  • Goal: What is the end state? (Be specific and measurable)
  • Phases: Break work into 2-5 phases (each phase = group of related tasks)
  • Success criteria: How do we know it's done? (tests pass, builds succeed, etc.)

3. Task Breakdown

For each phase, ask:

  • What are the individual tasks? (Each should fit in one context window)
  • What order should they execute?
  • What verification command confirms each task?

4. Context

  • Plan file path: Optional reference to an existing plan (e.g., ~/.claude/plans/my-plan.md)
  • Import mappings: Any before/after mappings for refactoring tasks

File Generation

After collecting answers, generate these files:

.ralph/SPEC.md

# [Task Name] Specification

## Goal
[One paragraph describing the end state]

## Success Criteria
- [ ] [Measurable criterion 1]
- [ ] [Measurable criterion 2]
- [ ] Final verification: `[command]` passes

## Phases

### Phase 1: [Name]
[Description of this phase's purpose]

### Phase 2: [Name]
[Description]

[... more phases]

## Context
[Any import mappings, dependencies, constraints]

## Out of Scope
- [What this RALPH loop will NOT do]

Read the full file on GitHub · 459 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3d ago First seen · 459 lines · 21 tokens per session scan B d23d449a54df

Subscribe to this mod's changes

ralph-init is a command published in the GitHub repository pproenca/agent-tui (114 stars, last pushed 4d ago), licensed MIT. It adds 21 tokens to every session and 3,350 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it B with 1 finding (asks the agent to reveal its instructions). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.