Ralph is designed to be customized for your specific project needs. This guide shows how to adapt Ralph for different tech stacks, quality checks, and team workflows.
Ralph uses prompt.md (for Amp) or CLAUDE.md (for Claude Code) as the instruction template for each iteration. This is where you encode your project’s conventions.
## Quality ChecksBefore marking a story complete, run:- npm run typecheck- npm run lint- npm run test- npm run buildALL checks must pass before committing.
Document your codebase patterns:
prompt.md
## Project Conventions### Database- Use Prisma for schema and migrations- Migration naming: YYYY-MM-DD-description.ts- Always add indexes for foreign keys### Components- Place in `components/` (not `app/components/`)- Use `"use client"` directive for interactive components- Export types from same file as component### Server Actions- Place in `app/actions/` directory- Always revalidate relevant paths after mutations- Return `{success: boolean, error?: string}` format### Styling- Use Tailwind utility classes- Component variants with class-variance-authority- No inline styles or CSS modules### State Management- Server state: React Query- Client state: Zustand stores in `lib/stores/`- URL state: searchParams for filters/pagination
Add framework-specific guidance:
prompt.md
## Tech Stack- **Framework:** Next.js 14 (App Router)- **Database:** PostgreSQL with Prisma ORM- **Auth:** NextAuth.js v5- **UI:** Tailwind CSS + shadcn/ui components- **Validation:** Zod schemas- **Testing:** Vitest + Testing Library## Important Gotchas- Server Components are default - add "use client" when needed- Dynamic routes must export generateStaticParams for static export- Prisma client is singleton - import from lib/prisma- Auth session available via await auth() in Server Components- Use server actions for mutations, not route handlers
Document frequently used patterns:
prompt.md
## Common Patterns### Adding a New Page1. Create `app/[route]/page.tsx`2. Add metadata export for SEO3. Update navigation in `components/Nav.tsx`4. Add to sitemap.ts if public### Adding a Database Table1. Update `prisma/schema.prisma`2. Run `npx prisma migrate dev --name description`3. Regenerate types: `npx prisma generate`4. Update AGENTS.md with new table info### Adding a Form1. Create Zod schema in `lib/schemas/`2. Create server action in `app/actions/`3. Use useFormState hook for client form4. Add loading state and error handling### Adding a Protected Route1. Check session at top of page: `const session = await auth()`2. Redirect if not authenticated3. Add role check if needed4. Add to middleware matcher if entire route is protected
Here’s a complete example of a customized prompt.md for an e-commerce site:
# Ralph Iteration Prompt - ShopAppYou are Ralph, an autonomous coding agent working on ShopApp, an e-commerce platform.## Your Job1. Read `prd.json` and find the highest priority story where `passes: false`2. Read `progress.txt` for context from previous iterations3. Implement that ONE story completely4. Run quality checks (below)5. Commit if checks pass6. Update `prd.json` to mark story as `passes: true`7. Append learnings to `progress.txt`8. Output `<promise>CONTINUE</promise>` or `<promise>COMPLETE</promise>`## Tech Stack- **Framework:** Next.js 14 (App Router)- **Database:** PostgreSQL + Prisma- **Payments:** Stripe- **Images:** Cloudinary- **Search:** Algolia- **Email:** Resend- **UI:** Tailwind + Custom components## Quality ChecksBefore marking complete, run ALL of these:- npm run typecheck (Must pass)- npm run lint (Must pass)- npm run test (Must pass)- npm run build (Must succeed)## Project Conventions### Products- Product data in `products` table with `product_variants` relationship- Always eager-load images (avoid N+1 queries)- Use `formatPrice()` helper for displaying prices- Inventory tracked in `inventory` table with SKU### Orders- Orders are immutable after creation (create audit records for changes)- Order status enum: pending | processing | shipped | delivered | cancelled- Always create Stripe PaymentIntent before order creation- Send email confirmation via Resend after successful order### Images- Upload to Cloudinary via server action- Store cloudinary_id and optimized URL in database- Use Next.js Image component with Cloudinary loader- Product images: 800x800px, webp format### Search- Product search powered by Algolia- Index updates via webhook after product mutations- Search component: `components/ProductSearch.tsx`- Facets: category, price range, rating, in_stock### Cart- Stored in localStorage for guests (max 30 days)- Stored in database for authenticated users- Merge guest cart to user cart on login- Use `useCart()` hook for cart operations## Common Gotchas- **Prices:** Store in cents (integer), never floats- **Stripe:** Use metadata field to link PaymentIntent to order- **Inventory:** Check stock before allowing add to cart- **Images:** Always provide alt text for accessibility- **Emails:** Use email templates from `emails/` directory## AGENTS.md UpdatesAfter completing a story, update relevant AGENTS.md files with:- New patterns discovered- Important gotchas encountered- Useful context for future iterations## Output FormatAfter completing the story:
### Multi-Tenancy- Every query MUST filter by tenantId- Use middleware to inject tenantId from session- Tenant data isolated at database level- Admin routes check isSuperAdmin flag
2
Mobile Backend API
Key customizations:
API versioning strategy
Rate limiting per endpoint
Response pagination standards
Authentication token refresh flow
### API Conventions- Version in URL: /api/v1/- Paginate with limit/offset params- Return meta: {total, page, hasMore}- Rate limit: 100 req/min per user
3
Data Pipeline
Key customizations:
ETL job patterns
Error handling and retry logic
Data validation schemas
Monitoring and alerting
### Pipeline Patterns- Jobs in jobs/ directory with .job.ts suffix- Use BullMQ for job queue- Retry failed jobs 3x with exponential backoff- Log to Datadog with job_name tag
4
Component Library
Key customizations:
Component API consistency
Storybook stories for each component
Accessibility requirements
Visual regression tests
### Component Standards- Export types alongside component- Props use ComponentProps pattern- Write Storybook story with variants- Test keyboard navigation- ARIA labels required for interactive elements
## Quality Checks (STRICT)ALL must pass before commit:1. **Type checking:** `npm run typecheck`2. **Linting:** `npm run lint` (no warnings)3. **Unit tests:** `npm run test` (100% of existing tests)4. **Integration tests:** `npm run test:integration`5. **E2E tests:** `npm run test:e2e` (for UI changes)6. **Security audit:** `npm audit` (no high/critical)7. **Build:** `npm run build` (must succeed)8. **Bundle size:** Check bundle doesn't grow >5%If ANY check fails, fix it before marking story complete.
Balanced (Startup)
Essential checks without slowing down:
## Quality Checks (BALANCED)Required before commit:1. **Type checking:** `npm run typecheck`2. **Linting:** `npm run lint`3. **Tests:** `npm run test` (for changed files)4. **Build:** `npm run build`If checks fail, fix before marking complete.
Minimal (Prototype)
Fast iteration for proof-of-concept:
## Quality Checks (MINIMAL)Before commit:1. **Type checking:** `npm run typecheck`2. **Build:** `npm run build`Fix type errors before committing. Other issues can be addressed later.
For UI-heavy projects, customize dev-browser usage:
## Browser VerificationFor stories with UI changes, use dev-browser skill to:1. Start dev server: `npm run dev`2. Navigate to changed page3. Interact with new UI elements4. Verify visual appearance matches requirements5. Test responsive behavior (mobile/desktop)6. Screenshot before marking completeInclude verification steps in commit message.
## Completion ProcessAfter all stories pass:1. Push branch: `git push -u origin $(git branch --show-current)`2. Create PR: `gh pr create --title "[Feature name]" --body "Completes: [list story IDs]"`3. Add reviewers: `gh pr edit --add-reviewer @team-dev`4. Link issues: Reference in PR descriptionOutput PR URL and mark as COMPLETE.
Connect Ralph to your issue tracker:
## Story CompletionAfter marking story as passes:1. Update Linear ticket status to "In Review"2. Comment with commit SHA3. Add "ralph" label to ticketUse Linear API command:linear-cli issue update [TICKET_ID] --status "In Review"
Send progress updates:
## Progress ReportingAfter each story completion, send Slack notification:curl -X POST $SLACK_WEBHOOK with:- Story ID and title- Commit link- Branch nameOnly send if SLACK_WEBHOOK env var is set.