Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Overview

Ralph is an autonomous AI agent loop that runs AI coding tools (Amp or Claude Code) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context.
Ralph is an autonomous AI agent loop that runs AI coding tools (Amp, Claude Code, or GitHub Copilot) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context.

## Commands

Expand All @@ -18,13 +18,16 @@ cd flowchart && npm run build

# Run Ralph with Claude Code
./ralph.sh --tool claude [max_iterations]

# Run Ralph with GitHub Copilot
./ralph.sh --tool copilot [max_iterations]
```

## Key Files

- `ralph.sh` - The bash loop that spawns fresh AI instances (supports `--tool amp` or `--tool claude`)
- `prompt.md` - Instructions given to each AMP instance
- `CLAUDE.md` - Instructions given to each Claude Code instance
- `ralph.sh` - The bash loop that spawns fresh AI instances (supports `--tool amp`, `--tool claude`, or `--tool copilot`)
- `prompt.md` - Instructions given to each Amp and GitHub Copilot instance
- `CLAUDE.md` - Instructions given to each Claude Code instance
- `prd.json.example` - Example PRD format
- `flowchart/` - Interactive React Flow diagram explaining how Ralph works

Expand All @@ -41,7 +44,7 @@ npm run dev

## Patterns

- Each iteration spawns a fresh AI instance (Amp or Claude Code) with clean context
- Each iteration spawns a fresh AI instance (Amp, Claude Code, or GitHub Copilot) with clean context
- Memory persists via git history, `progress.txt`, and `prd.json`
- Stories should be small enough to complete in one context window
- Always update AGENTS.md with discovered patterns for future iterations
21 changes: 13 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

![Ralph](ralph.webp)

Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com) or [Claude Code](https://docs.anthropic.com/en/docs/claude-code)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`.
Ralph is an autonomous AI agent loop that runs AI coding tools ([Amp](https://ampcode.com), [Claude Code](https://docs.anthropic.com/en/docs/claude-code), or [GitHub Copilot](https://github.com/features/copilot)) repeatedly until all PRD items are complete. Each iteration is a fresh instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`.

Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/).

Expand All @@ -13,6 +13,7 @@ Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/).
- One of the following AI coding tools installed and authenticated:
- [Amp CLI](https://ampcode.com) (default)
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) (`npm install -g @anthropic-ai/claude-code`)
- [GitHub Copilot CLI](https://docs.github.com/en/copilot) - Requires VS Code with [Copilot Chat extension](https://marketplace.visualstudio.com/items?itemName=GitHub.copilot-chat) installed; the CLI binary is bundled at `~/.vscode/extensions/github.copilot-chat-*/copilotCli/copilot` (note: this is different from the `gh copilot` extension)
- `jq` installed (`brew install jq` on macOS)
- A git repository for your project

Expand All @@ -28,9 +29,9 @@ mkdir -p scripts/ralph
cp /path/to/ralph/ralph.sh scripts/ralph/

# Copy the prompt template for your AI tool of choice:
cp /path/to/ralph/prompt.md scripts/ralph/prompt.md # For Amp
cp /path/to/ralph/prompt.md scripts/ralph/prompt.md # For Amp and GitHub Copilot
# OR
cp /path/to/ralph/CLAUDE.md scripts/ralph/CLAUDE.md # For Claude Code
cp /path/to/ralph/CLAUDE.md scripts/ralph/CLAUDE.md # For Claude Code

chmod +x scripts/ralph/ralph.sh
```
Expand Down Expand Up @@ -115,9 +116,12 @@ This creates `prd.json` with user stories structured for autonomous execution.

# Using Claude Code
./scripts/ralph/ralph.sh --tool claude [max_iterations]

# Using GitHub Copilot
./scripts/ralph/ralph.sh --tool copilot [max_iterations]
```

Default is 10 iterations. Use `--tool amp` or `--tool claude` to select your AI coding tool.
Default is 10 iterations. Use `--tool amp`, `--tool claude`, or `--tool copilot` to select your AI coding tool.

Ralph will:
1. Create a feature branch (from PRD `branchName`)
Expand All @@ -133,8 +137,8 @@ Ralph will:

| File | Purpose |
|------|---------|
| `ralph.sh` | The bash loop that spawns fresh AI instances (supports `--tool amp` or `--tool claude`) |
| `prompt.md` | Prompt template for Amp |
| `ralph.sh` | The bash loop that spawns fresh AI instances (supports `--tool amp`, `--tool claude`, or `--tool copilot`) |
| `prompt.md` | Prompt template for Amp and GitHub Copilot |
| `CLAUDE.md` | Prompt template for Claude Code |
| `prd.json` | User stories with `passes` status (the task list) |
| `prd.json.example` | Example PRD format for reference |
Expand Down Expand Up @@ -162,7 +166,7 @@ npm run dev

### Each Iteration = Fresh Context

Each iteration spawns a **new AI instance** (Amp or Claude Code) with clean context. The only memory between iterations is:
Each iteration spawns a **new AI instance** (Amp, Claude Code, or GitHub Copilot) with clean context. The only memory between iterations is:
- Git history (commits from previous iterations)
- `progress.txt` (learnings and context)
- `prd.json` (which stories are done)
Expand Down Expand Up @@ -223,7 +227,7 @@ git log --oneline -10

## Customizing the Prompt

After copying `prompt.md` (for Amp) or `CLAUDE.md` (for Claude Code) to your project, customize it for your project:
After copying `prompt.md` (for Amp and GitHub Copilot) or `CLAUDE.md` (for Claude Code) to your project, customize it for your project:
- Add project-specific quality check commands
- Include codebase conventions
- Add common gotchas for your stack
Expand All @@ -237,3 +241,4 @@ Ralph automatically archives previous runs when you start a new feature (differe
- [Geoffrey Huntley's Ralph article](https://ghuntley.com/ralph/)
- [Amp documentation](https://ampcode.com/manual)
- [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code)
- [GitHub Copilot documentation](https://docs.github.com/en/copilot)
9 changes: 6 additions & 3 deletions ralph.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# Ralph Wiggum - Long-running AI agent loop
# Usage: ./ralph.sh [--tool amp|claude] [max_iterations]
# Usage: ./ralph.sh [--tool amp|claude|copilot] [max_iterations]

set -e

Expand Down Expand Up @@ -29,8 +29,8 @@ while [[ $# -gt 0 ]]; do
done

# Validate tool choice
if [[ "$TOOL" != "amp" && "$TOOL" != "claude" ]]; then
echo "Error: Invalid tool '$TOOL'. Must be 'amp' or 'claude'."
if [[ "$TOOL" != "amp" && "$TOOL" != "claude" && "$TOOL" != "copilot" ]]; then
echo "Error: Invalid tool '$TOOL'. Must be 'amp', 'claude', or 'copilot'."
exit 1
fi
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
Expand Down Expand Up @@ -90,6 +90,9 @@ for i in $(seq 1 $MAX_ITERATIONS); do
# Run the selected tool with the ralph prompt
if [[ "$TOOL" == "amp" ]]; then
OUTPUT=$(cat "$SCRIPT_DIR/prompt.md" | amp --dangerously-allow-all 2>&1 | tee /dev/stderr) || true
elif [[ "$TOOL" == "copilot" ]]; then
PROMPT_CONTENT=$(cat "$SCRIPT_DIR/prompt.md" | sed "s|Read the PRD at \`prd.json\` (in the same directory as this file)|Read the PRD at \`$PRD_FILE\`|" | sed "s|Read the progress log at \`progress.txt\`|Read the progress log at \`$PROGRESS_FILE\`|" | sed "s|APPEND to progress.txt|APPEND to $PROGRESS_FILE|")
OUTPUT=$(copilot -i "$PROMPT_CONTENT" --yolo --no-ask-user 2>&1 | tee /dev/stderr) || true
else
# Claude Code: use --dangerously-skip-permissions for autonomous operation, --print for output
OUTPUT=$(claude --dangerously-skip-permissions --print < "$SCRIPT_DIR/CLAUDE.md" 2>&1 | tee /dev/stderr) || true
Expand Down