Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/snarktank/ralph/llms.txt

Use this file to discover all available pages before exploring further.

Custom Workflows

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.

Customizing the Prompt

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.

Location

scripts/ralph/
├── ralph.sh          # The loop script
├── prompt.md         # Amp instructions (copy and customize)
└── CLAUDE.md         # Claude Code instructions (copy and customize)

What to Customize

Add your project’s specific commands:
## Quality Checks

Before marking a story complete, run:
- npm run typecheck
- npm run lint
- npm run test
- npm run build

ALL checks must pass before committing.

Example: E-commerce Project

Here’s a complete example of a customized prompt.md for an e-commerce site:
# Ralph Iteration Prompt - ShopApp

You are Ralph, an autonomous coding agent working on ShopApp, an e-commerce platform.

## Your Job

1. Read `prd.json` and find the highest priority story where `passes: false`
2. Read `progress.txt` for context from previous iterations
3. Implement that ONE story completely
4. Run quality checks (below)
5. Commit if checks pass
6. 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 Checks

Before 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 Updates

After completing a story, update relevant AGENTS.md files with:
- New patterns discovered
- Important gotchas encountered
- Useful context for future iterations

## Output Format

After completing the story:

Project-Specific Examples

1

SaaS Application

Key customizations:
  • Multi-tenancy patterns (tenant isolation)
  • Subscription/billing checks before operations
  • Feature flags for different plan tiers
  • Audit logging for compliance
### 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 Check Variations

Maximum safety for production systems:
## 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.
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.
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.

Browser Verification Patterns

For UI-heavy projects, customize dev-browser usage:
## Browser Verification

For stories with UI changes, use dev-browser skill to:

1. Start dev server: `npm run dev`
2. Navigate to changed page
3. Interact with new UI elements
4. Verify visual appearance matches requirements
5. Test responsive behavior (mobile/desktop)
6. Screenshot before marking complete

Include verification steps in commit message.

Team Workflow Integration

Have Ralph create PRs instead of direct commits:
## Completion Process

After 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 description

Output PR URL and mark as COMPLETE.

Testing Your Customizations

After customizing, test with a small PRD:
{
  "project": "Test",
  "branchName": "ralph/test-customization",
  "description": "Test custom Ralph setup",
  "userStories": [
    {
      "id": "US-001",
      "title": "Add test endpoint",
      "description": "As a developer, I want to verify Ralph runs correctly.",
      "acceptanceCriteria": [
        "Add /api/test route that returns {status: 'ok'}",
        "Typecheck passes",
        "Tests pass"
      ],
      "priority": 1,
      "passes": false,
      "notes": ""
    }
  ]
}
Run Ralph and verify:
  • Custom quality checks run
  • Project conventions are followed
  • Completion process works as expected
Start with small customizations and iterate. Add conventions as you discover patterns that should be encoded.

Build docs developers (and LLMs) love