Validation (Backpressure)
The --validate flag enables backpressure validation, running tests/lint/build after each iteration to catch issues early.
How It Works
┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ AI codes │ ──▶ │ Validate │ ──▶ │ Pass? │
└─────────────┘ └─────────────┘ └─────────────┘
│
┌──────────────────────────┤
│ │
▼ ▼
┌─────────────┐ ┌─────────────┐
│ Fix issues │ │ Commit │
└─────────────┘ └─────────────┘
- AI implements a task
- Validation commands run
- If failed → AI gets error output and fixes issues
- If passed → Changes are committed (if
--commit) - Loop continues
Enable Validation
ralph-starter run "add feature" --validate
Validation Commands
ralph-starter looks for validation commands in two places:
1. AGENTS.md
### Validation Commands
- test: npm test
- lint: npm run lint
- build: npm run build
- typecheck: npm run typecheck
2. package.json (Fallback)
{
"scripts": {
"test": "jest",
"lint": "eslint src/",
"build": "tsc && vite build",
"typecheck": "tsc --noEmit"
}
}
Command Detection
ralph-starter automatically detects:
| Command | Detected From |
|---|---|
test | AGENTS.md or package.json test script |
lint | AGENTS.md or package.json lint script |
build | AGENTS.md or package.json build script |
typecheck | AGENTS.md or package.json typecheck script |
Validation Order
Commands run in order:
test- Run testslint- Check code stylebuild- Build project
If any command fails, validation stops and the AI receives the error output.
Error Feedback
When validation fails, the AI receives:
## Validation Failed
### npm run test
FAIL src/components/Dashboard.test.tsx ● Dashboard › renders habits Expected: 3 Received: 0
Please fix the above issues before continuing.
The AI then attempts to fix the issues before continuing.
Examples
With Commit
# Validate and commit if passed
ralph-starter run "add tests" --validate --commit
Full Automation
# Auto mode with validation and commit
ralph-starter run --auto --validate --commit
Maximum Iterations
# Limit iterations to prevent infinite fix loops
ralph-starter run --validate --max-iterations 20
Custom Validation
In AGENTS.md
### Validation Commands
- test: npm test -- --coverage --watchAll=false
- lint: npm run lint -- --max-warnings 0
- build: npm run build
- e2e: npm run test:e2e
Multiple Commands
You can specify multiple validation steps:
### Validation Commands
- typecheck: npm run typecheck
- lint: npm run lint
- test: npm test
- build: npm run build
Timeout
Each validation command has a 5-minute timeout. Long-running tests may need adjustment.
Skipping Validation
For quick iterations without validation:
ralph-starter run "quick fix" --commit
Tips
- Start with validation - Catches issues early
- Fast tests - Use watch mode disabled for CI-like behavior
- Strict lint - Use
--max-warnings 0for strict linting - Build always - Include build to catch TypeScript errors