ralph-loop
Generate copy-paste bash scripts for Ralph Wiggum/AI agent loops (Codex, Claude Code, OpenCode, Goose). Use when asked for a “Ralph loop”, “Ralph Wiggum loop”, or an AI loop to plan/build code via PROMPT.md + AGENTS.md, SPECS, and IMPLEMENTATION_PLAN.md, including PLANNING vs BUILDING modes, backpressure, sandboxing, and completion conditions.
What this skill does
# Ralph Loop
## Overview
Generate a ready-to-run bash script that runs an AI coding CLI in a loop. Align with the Ralph playbook flow:
1) **Define requirements** → JTBD → topics of concern → `specs/*.md`
2) **PLANNING loop** → create/update `IMPLEMENTATION_PLAN.md` (no implementation)
3) **BUILDING loop** → implement tasks, run tests (backpressure), update plan, commit
The loop persists context via `PROMPT.md` + `AGENTS.md` (loaded every iteration) plus the on-disk plan/specs.
## Workflow
### 1) Collect inputs (ask if missing)
- **Goal / JTBD** (what outcome is needed)
- CLI (`codex`, `claude-code`, `opencode`, `goose`, other)
- **Mode**: `PLANNING`, `BUILDING`, or `BOTH`
- **Completion condition**
- Promise phrase (string to detect), **or**
- Test/command to run each iteration, **or**
- Plan sentinel (e.g., a line `STATUS: COMPLETE` in `IMPLEMENTATION_PLAN.md`)
- Max iterations
- Sandbox choice (`none` | `docker` | other) + **security posture**
- **Backpressure commands** (tests/lints/build) to embed in `AGENTS.md`
- **Auto‑approve flags** (ask explicitly)
- Codex: `--full-auto`
- Claude Code: `--dangerously-skip-permissions`
### 2) Phase 1 — Requirements → specs
If the user wants “full Ralph” (or unclear requirements), do this before the loop:
- Break the JTBD into **topics of concern** (1 topic = 1 spec file).
- For each topic, draft `specs/<topic>.md`.
- Use subagents to load URLs or existing docs into context for spec quality.
- Keep specs short and testable.
### 3) Phase 2/3 — PROMPT.md + AGENTS.md
- **Context loaded each iteration:** `PROMPT.md` + `AGENTS.md`.
- `AGENTS.md` should include:
- project test commands (backpressure)
- build/run instructions
- any operational learnings
- `PROMPT.md` should reference:
- `specs/*.md`
- `IMPLEMENTATION_PLAN.md`
- any relevant project files/dirs
### 4) Two prompt templates (PLANNING vs BUILDING)
Create **two prompts** and swap `PROMPT.md` based on mode.
**PLANNING prompt (no implementation):**
```
You are running a Ralph PLANNING loop for: <JTBD/GOAL>.
Read specs/* and the current codebase. Do a gap analysis and update IMPLEMENTATION_PLAN.md only.
Rules:
- Do NOT implement.
- Do NOT commit.
- Prioritize tasks and keep plan concise.
- If requirements are unclear, write clarifying questions into the plan.
Completion:
If the plan is complete, add line: STATUS: COMPLETE
```
**BUILDING prompt:**
```
You are running a Ralph BUILDING loop for: <JTBD/GOAL>.
Context:
- specs/*
- IMPLEMENTATION_PLAN.md
- AGENTS.md (tests/backpressure)
Tasks:
1) Pick the most important task from IMPLEMENTATION_PLAN.md.
2) Investigate relevant code (don’t assume missing).
3) Implement.
4) Run the backpressure commands from AGENTS.md.
5) Update IMPLEMENTATION_PLAN.md (mark done + notes).
6) Update AGENTS.md if you learned new operational details.
7) Commit with a clear message.
Completion:
If all tasks are done, add line: STATUS: COMPLETE
```
### 5) Build the per‑iteration command
- Codex: `codex exec <FLAGS> "$(cat PROMPT.md)"`
- Requires git repo.
- Claude Code: `claude <FLAGS> "$(cat PROMPT.md)"`
- OpenCode: `opencode run "$(cat PROMPT.md)"`
- Goose: `goose run "$(cat PROMPT.md)"` (ask if they want the Goose recipe)
If the CLI is unknown, ask for the exact command to run each iteration.
### 6) Output a copy‑paste script
Provide **either** a minimal loop or a controlled loop with max iters + stop conditions.
**Minimal loop (Geoff style):**
```bash
while :; do cat PROMPT.md | claude ; done
```
**Controlled loop (recommended):**
```bash
#!/usr/bin/env bash
set -euo pipefail
PROMISE='...'
MAX_ITERS=...
CLI_FLAGS="..." # optional
PLAN_SENTINEL='STATUS: COMPLETE'
TEST_CMD='...' # optional
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
echo "❌ Run this inside a git repo."
exit 1
fi
touch PROMPT.md AGENTS.md IMPLEMENTATION_PLAN.md
LOG_FILE=".ralph/ralph.log"
mkdir -p .ralph
CLI_CMD="..." # e.g. "codex exec" or "claude"
for i in $(seq 1 "$MAX_ITERS"); do
echo -e "\n=== Ralph iteration $i/$MAX_ITERS ===" | tee -a "$LOG_FILE"
$CLI_CMD $CLI_FLAGS "$(cat PROMPT.md)" | tee -a "$LOG_FILE"
if [[ -n "${TEST_CMD}" ]]; then
echo "Running tests: $TEST_CMD" | tee -a "$LOG_FILE"
bash -lc "$TEST_CMD" | tee -a "$LOG_FILE"
fi
if grep -Fq "$PROMISE" "$LOG_FILE" || grep -Fq "$PLAN_SENTINEL" IMPLEMENTATION_PLAN.md; then
echo "✅ Completion detected. Stopping." | tee -a "$LOG_FILE"
exit 0
fi
done
echo "❌ Max iterations reached without completion." | tee -a "$LOG_FILE"
exit 1
```
## Safety/Sandbox Guidance (must mention)
- Running with `--dangerously-skip-permissions` or `--full-auto` implies **trust + risk**.
- Recommend a **sandbox** (docker/e2b/fly) with minimal credentials and restricted network.
- Escape hatches: `Ctrl+C` to stop; `git reset --hard` to revert.
## Guardrails
- If requirements are unclear, insist on specs before BUILDING.
- If the plan looks stale/wrong, regenerate it (PLANNING loop).
- If backpressure commands are missing, ask for them and add to `AGENTS.md`.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.