---
description: Run Ralph Loop - autonomous AI iteration until tests pass
---

# Ralph Loop Workflow

Ralph Loop chạy AI agent liên tục đến khi test pass hoặc max iterations.

## Prerequisites

1. **Antigravity For Loop Extension**: Install từ https://github.com/ImL1s/antigravity_for_loop
2. **Enable CDP**: Run Antigravity với `--remote-debugging-port=9000`

## Quick Start (GUI - Recommended)

1. Click **"For Loop"** trong status bar (bottom)
2. Select **"Start Ralph Loop..."**
3. Enter task description
4. Select completion condition:
   - **Tests Pass** - stop khi test exit 0
   - **AI Self-Judgment** - stop khi AI output "DONE"
5. Set max iterations (default: 10)
6. Go!

## Keyboard Shortcuts

| Shortcut | Action |
|----------|--------|
| `Cmd+Alt+Shift+L` | Open Ralph menu |
| `Cmd+Alt+Shift+A` | Toggle auto-accept |
| `Cmd+Alt+Shift+C` | Copy continuation prompt |

## Manual Loop (Alternative)

Nếu extension không hoạt động:

// turbo-all
```
1. Review RALPH_TASK.md
2. Chat with AI: "Work on the unchecked items in RALPH_TASK.md"
3. Run tests: cd backend && pytest
4. If tests fail, continue iterating
5. If tests pass, check off completed items
6. Repeat until all done
```

## Create New Task

File: `RALPH_TASK.md`

```markdown
task: "Your task description here"
test_command: "npm test"  # or "pytest", "cargo test", etc.
---

# Task: [Title]

## Success Criteria
- [ ] Criterion 1
- [ ] Criterion 2
```

## Windows Setup

```powershell
.\run_ralph_windows.ps1 -MaxIterations 50
```

## Tips

- **Always git commit** before starting a Ralph loop
- Set reasonable **maxIterations** (10-50)
- Use **AI Self-Judgment** for open-ended refactoring tasks
- Use **Tests Pass** for bug fixes with clear test coverage
