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
8 changes: 4 additions & 4 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 Amp repeatedly until all PRD items are complete. Each iteration is a fresh Amp instance with clean context.
Ralph-tabnine is an autonomous AI agent loop that runs Tabnine CLI repeatedly until all PRD items are complete. Each iteration is a fresh Tabnine CLI instance with clean context.

## Commands

Expand All @@ -19,8 +19,8 @@ cd flowchart && npm run build

## Key Files

- `ralph.sh` - The bash loop that spawns fresh Amp instances
- `prompt.md` - Instructions given to each Amp instance
- `ralph.sh` - The bash loop that spawns fresh Tabnine CLI instances
- `prompt.md` - Instructions given to each Tabnine CLI instance
- `prd.json.example` - Example PRD format
- `flowchart/` - Interactive React Flow diagram explaining how Ralph works

Expand All @@ -37,7 +37,7 @@ npm run dev

## Patterns

- Each iteration spawns a fresh Amp instance with clean context
- Each iteration spawns a fresh Tabnine CLI instance 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
61 changes: 16 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

![Ralph](ralph.webp)

Ralph is an autonomous AI agent loop that runs [Amp](https://ampcode.com) repeatedly until all PRD items are complete. Each iteration is a fresh Amp instance with clean context. Memory persists via git history, `progress.txt`, and `prd.json`.
Ralph is an autonomous AI agent loop that runs [Tabnine CLI](https://github.com/codota/tabnine-cli/) repeatedly until all PRD items are complete. Each iteration is a fresh Tabnine CLI 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/).
Tabnine CLI is a Gemini-based AI coding assistant that provides similar capabilities to Anthropic's Claude.

[Read my in-depth article on how I use Ralph](https://x.com/ryancarson/status/2008548371712135632)
Based on [Geoffrey Huntley's Ralph pattern](https://ghuntley.com/ralph/).

## Prerequisites

- [Amp CLI](https://ampcode.com) installed and authenticated
- [Tabnine CLI](https://github.com/codota/tabnine-cli/) installed and authenticated
- `jq` installed (`brew install jq` on macOS)
- A git repository for your project

## Setup

### Option 1: Copy to your project
### Copy to your project

Copy the ralph files into your project:

Expand All @@ -28,46 +28,17 @@ cp /path/to/ralph/prompt.md scripts/ralph/
chmod +x scripts/ralph/ralph.sh
```

### Option 2: Install skills globally

Copy the skills to your Amp config for use across all projects:

```bash
cp -r skills/prd ~/.config/amp/skills/
cp -r skills/ralph ~/.config/amp/skills/
```

### Configure Amp auto-handoff (recommended)

Add to `~/.config/amp/settings.json`:

```json
{
"amp.experimental.autoHandoff": { "context": 90 }
}
```

This enables automatic handoff when context fills up, allowing Ralph to handle large stories that exceed a single context window.

## Workflow

### 1. Create a PRD

Use the PRD skill to generate a detailed requirements document:
Create a detailed requirements document manually or with assistance from Tabnine CLI. See `skills/prd/SKILL.md` for guidelines on creating effective PRDs.

```
Load the prd skill and create a PRD for [your feature description]
```

Answer the clarifying questions. The skill saves output to `tasks/prd-[feature-name].md`.
Save the PRD as `tasks/prd-[feature-name].md`.

### 2. Convert PRD to Ralph format

Use the Ralph skill to convert the markdown PRD to JSON:

```
Load the ralph skill and convert tasks/prd-[feature-name].md to prd.json
```
Convert the markdown PRD to JSON format using the guidelines in `skills/ralph/SKILL.md`. You can ask Tabnine CLI to help with this conversion.

This creates `prd.json` with user stories structured for autonomous execution.

Expand All @@ -93,13 +64,13 @@ Ralph will:

| File | Purpose |
|------|---------|
| `ralph.sh` | The bash loop that spawns fresh Amp instances |
| `prompt.md` | Instructions given to each Amp instance |
| `ralph.sh` | The bash loop that spawns fresh Tabnine CLI instances |
| `prompt.md` | Instructions given to each Tabnine CLI instance |
| `prd.json` | User stories with `passes` status (the task list) |
| `prd.json.example` | Example PRD format for reference |
| `progress.txt` | Append-only learnings for future iterations |
| `skills/prd/` | Skill for generating PRDs |
| `skills/ralph/` | Skill for converting PRDs to JSON |
| `skills/prd/` | Guidelines for creating PRDs |
| `skills/ralph/` | Guidelines for converting PRDs to JSON |
| `flowchart/` | Interactive visualization of how Ralph works |

## Flowchart
Expand All @@ -120,7 +91,7 @@ npm run dev

### Each Iteration = Fresh Context

Each iteration spawns a **new Amp instance** with clean context. The only memory between iterations is:
Each iteration spawns a **new Tabnine CLI instance** 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 All @@ -142,7 +113,7 @@ Too big (split these):

### AGENTS.md Updates Are Critical

After each iteration, Ralph updates the relevant `AGENTS.md` files with learnings. This is key because Amp automatically reads these files, so future iterations (and future human developers) benefit from discovered patterns, gotchas, and conventions.
After each iteration, Ralph updates the relevant `AGENTS.md` files with learnings. These files provide context for future iterations and human developers about discovered patterns, gotchas, and conventions.

Examples of what to add to AGENTS.md:
- Patterns discovered ("this codebase uses X for Y")
Expand All @@ -158,7 +129,7 @@ Ralph only works if there are feedback loops:

### Browser Verification for UI Stories

Frontend stories must include "Verify in browser using dev-browser skill" in acceptance criteria. Ralph will use the dev-browser skill to navigate to the page, interact with the UI, and confirm changes work.
Frontend stories should include manual browser verification in acceptance criteria. After Ralph implements UI changes, verify the changes work as expected in the browser.

### Stop Condition

Expand Down Expand Up @@ -193,4 +164,4 @@ Ralph automatically archives previous runs when you start a new feature (differe
## References

- [Geoffrey Huntley's Ralph article](https://ghuntley.com/ralph/)
- [Amp documentation](https://ampcode.com/manual)
- [Tabnine CLI](https://github.com/codota/tabnine-cli/)
77 changes: 12 additions & 65 deletions flowchart/README.md
Original file line number Diff line number Diff line change
@@ -1,73 +1,20 @@
# React + TypeScript + Vite
# Ralph Flowchart

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Interactive visualization showing how Ralph works with Tabnine CLI.

Currently, two official plugins are available:
Built with React Flow for presentations - click through to reveal each step with animations.

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
## Development

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```bash
npm install
npm run dev
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
## Build

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x'
import reactDom from 'eslint-plugin-react-dom'

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
])
```bash
npm run build
```

The build output goes to `dist/` and is deployed to GitHub Pages.
2 changes: 1 addition & 1 deletion flowchart/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>How Ralph Works with Amp</title>
<title>How Ralph Works with Tabnine CLI</title>
</head>
<body>
<div id="root"></div>
Expand Down
4 changes: 2 additions & 2 deletions flowchart/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const allSteps: { id: string; label: string; description: string; phase: Phase }
{ id: '2', label: 'Convert to prd.json', description: 'Break into small user stories', phase: 'setup' },
{ id: '3', label: 'Run ralph.sh', description: 'Starts the autonomous loop', phase: 'setup' },
// Loop phase
{ id: '4', label: 'Amp picks a story', description: 'Finds next passes: false', phase: 'loop' },
{ id: '4', label: 'Tabnine CLI picks a story', description: 'Finds next passes: false', phase: 'loop' },
{ id: '5', label: 'Implements it', description: 'Writes code, runs tests', phase: 'loop' },
{ id: '6', label: 'Commits changes', description: 'If tests pass', phase: 'loop' },
{ id: '7', label: 'Updates prd.json', description: 'Sets passes: true', phase: 'loop' },
Expand Down Expand Up @@ -325,7 +325,7 @@ function App() {
return (
<div className="app-container">
<div className="header">
<h1>How Ralph Works with Amp</h1>
<h1>How Ralph Works with Tabnine CLI</h1>
<p>Autonomous AI agent loop for completing PRDs</p>
</div>
<div className="flow-container">
Expand Down
6 changes: 3 additions & 3 deletions prd.json.example
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"Each task card shows colored priority badge (red=high, yellow=medium, gray=low)",
"Priority visible without hovering or clicking",
"Typecheck passes",
"Verify in browser using dev-browser skill"
"Verify in browser"
],
"priority": 2,
"passes": false,
Expand All @@ -39,7 +39,7 @@
"Shows current priority as selected",
"Saves immediately on selection change",
"Typecheck passes",
"Verify in browser using dev-browser skill"
"Verify in browser"
],
"priority": 3,
"passes": false,
Expand All @@ -54,7 +54,7 @@
"Filter persists in URL params",
"Empty state message when no tasks match filter",
"Typecheck passes",
"Verify in browser using dev-browser skill"
"Verify in browser"
],
"priority": 4,
"passes": false,
Expand Down
12 changes: 2 additions & 10 deletions prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ You are an autonomous coding agent working on a software project.
APPEND to progress.txt (never replace, always append):
```
## [Date/Time] - [Story ID]
Thread: https://ampcode.com/threads/$AMP_CURRENT_THREAD_ID
- What was implemented
- Files changed
- **Learnings for future iterations:**
Expand All @@ -30,8 +29,6 @@ Thread: https://ampcode.com/threads/$AMP_CURRENT_THREAD_ID
---
```

Include the thread URL so future iterations can use the `read_thread` tool to reference previous work if needed.

The learnings section is critical - it helps future iterations avoid repeating mistakes and understand the codebase better.

## Consolidate Patterns
Expand Down Expand Up @@ -82,14 +79,9 @@ Only update AGENTS.md if you have **genuinely reusable knowledge** that would he

## Browser Testing (Required for Frontend Stories)

For any story that changes UI, you MUST verify it works in the browser:

1. Load the `dev-browser` skill
2. Navigate to the relevant page
3. Verify the UI changes work as expected
4. Take a screenshot if helpful for the progress log
For any story that changes UI, you should manually verify it works in the browser after implementation. Document verification results in the progress log.

A frontend story is NOT complete until browser verification passes.
A frontend story is NOT complete until verification passes.

## Stop Condition

Expand Down
4 changes: 2 additions & 2 deletions ralph.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ for i in $(seq 1 $MAX_ITERATIONS); do
echo " Ralph Iteration $i of $MAX_ITERATIONS"
echo "═══════════════════════════════════════════════════════"

# Run amp with the ralph prompt
OUTPUT=$(cat "$SCRIPT_DIR/prompt.md" | amp --dangerously-allow-all 2>&1 | tee /dev/stderr) || true
# Run tabnine with the ralph prompt
OUTPUT=$(cat "$SCRIPT_DIR/prompt.md" | tabnine --yolo 2>&1 | tee /dev/stderr) || true

# Check for completion signal
if echo "$OUTPUT" | grep -q "<promise>COMPLETE</promise>"; then
Expand Down
8 changes: 4 additions & 4 deletions skills/prd/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Each story should be small enough to implement in one focused session.

**Important:**
- Acceptance criteria must be verifiable, not vague. "Works correctly" is bad. "Button shows confirmation dialog before deleting" is good.
- **For any story with UI changes:** Always include "Verify in browser using dev-browser skill" as acceptance criteria. This ensures visual verification of frontend work.
- **For any story with UI changes:** Always include "Verify in browser" as acceptance criteria. This ensures visual verification of frontend work.

### 4. Functional Requirements
Numbered list of specific functionalities:
Expand Down Expand Up @@ -172,7 +172,7 @@ Add priority levels to tasks so users can focus on what matters most. Tasks can
- [ ] Each task card shows colored priority badge (red=high, yellow=medium, gray=low)
- [ ] Priority visible without hovering or clicking
- [ ] Typecheck passes
- [ ] Verify in browser using dev-browser skill
- [ ] Verify in browser

### US-003: Add priority selector to task edit
**Description:** As a user, I want to change a task's priority when editing it.
Expand All @@ -182,7 +182,7 @@ Add priority levels to tasks so users can focus on what matters most. Tasks can
- [ ] Shows current priority as selected
- [ ] Saves immediately on selection change
- [ ] Typecheck passes
- [ ] Verify in browser using dev-browser skill
- [ ] Verify in browser

### US-004: Filter tasks by priority
**Description:** As a user, I want to filter the task list to see only high-priority items when I'm focused.
Expand All @@ -192,7 +192,7 @@ Add priority levels to tasks so users can focus on what matters most. Tasks can
- [ ] Filter persists in URL params
- [ ] Empty state message when no tasks match filter
- [ ] Typecheck passes
- [ ] Verify in browser using dev-browser skill
- [ ] Verify in browser

## Functional Requirements

Expand Down
Loading