An autonomous AI agent loop that runs GitHub Copilot CLI repeatedly until all PRD items are complete. Each iteration is a fresh Copilot instance with clean context. Memory persists via git history, progress.txt, and prd.json.
Based on Geoffrey Huntley's Ralph pattern and adapted from Ryan Carson's Amp implementation.
- GitHub Copilot CLI installed and authenticated (
npm install -g @github/copilot) - Active Copilot subscription (Pro, Pro+, Business, or Enterprise)
jqinstalled (apt-get install jqon Linux,brew install jqon macOS)- A git repository (Ralph commits progress and uses git history for memory)
Copy files to your project, then run:
# In your project directory
cp /path/to/copilot-ralph/ralph.sh ./
cp /path/to/copilot-ralph/prompt.md ./
cp /path/to/copilot-ralph/prd.json.example ./prd.json
# Edit prd.json with your user stories
./ralph.shRalph runs in the current directory and commits to the current git repo.
Create a prd.json file with your user stories:
{
"projectName": "Landing Page",
"branchName": "ralph/landing-page",
"userStories": [
{
"id": "US-001",
"title": "Create hero section",
"priority": 1,
"description": "Build hero with headline and CTA",
"acceptanceCriteria": ["Full viewport height", "CTA scrolls to signup"],
"passes": false
}
]
}See prd.json.example for a complete example.
./ralph.sh [max_iterations]Default is 10 iterations. Each iteration:
- Picks the highest priority story where
passes: false - Implements that single story
- Runs quality checks
- Commits if checks pass
- Marks story as
passes: true - Appends learnings to
progress.txt - Repeats until all stories pass
┌─────────────────────────────────────────────────────────────┐
│ │
│ prd.json ─────┬───────── progress.txt ─────── git history │
│ │ │
│ ▼ │
│ copilot -p "$PROMPT" --allow-all-tools │
│ │ │
│ ▼ │
│ Check for <promise>COMPLETE</promise> │
│ │ │
│ ┌──────┴──────┐ │
│ ▼ ▼ │
│ Complete Continue │
│ Exit 0 Next iteration │
│ │
└─────────────────────────────────────────────────────────────┘
| File | Purpose |
|---|---|
ralph.sh |
Bash loop that spawns Copilot CLI instances |
prompt.md |
Instructions for each iteration |
prd.json |
Your user stories (create from example) |
progress.txt |
Learnings from previous iterations (auto-created) |
skills/prd/SKILL.md |
PRD generator skill for creating prd.json |
Each iteration spawns a new Copilot CLI instance. Memory persists only via:
- Git history
progress.txtprd.json
Stories should be small enough to complete in one context window.
Good: Add a form component, Create an API endpoint, Add validation
Too big: Build the dashboard, Add authentication, Refactor the API
When all stories have passes: true, Ralph outputs <promise>COMPLETE</promise> and exits.
GitHub Copilot CLI uses Claude Sonnet 4.5 by default.
Available models: Claude Sonnet 4.5, Claude Sonnet 4, GPT-5
# Change model via environment variable
export COPILOT_MODEL=gpt-5
./ralph.sh# Check story status
cat prd.json | jq '.userStories[] | {id, title, passes}'
# View learnings
cat progress.txt
# Check commits
git log --oneline -10Use the PRD skill to generate prd.json files through a guided process:
# Ask Copilot to generate a PRD
copilot "Generate a PRD for a user authentication system"The skill will:
- Ask 3-5 clarifying questions with A/B/C/D options
- Generate a properly structured
prd.json - Create small, implementable user stories with verifiable acceptance criteria
See skills/prd/SKILL.md for the full specification.
Edit prompt.md to add:
- Project-specific quality check commands
- Codebase conventions
- Common gotchas for your stack