Back to .md Directory

Ralph Agent Instructions (Claude Code Edition)

Defines a step-by-step workflow for an autonomous coding agent to implement user stories from a PRD and track progress.

May 2, 2026
0 downloads
1 views
ai agent eval claude
View source

What this file does

Defines a step-by-step workflow for an autonomous coding agent to implement user stories from a PRD and track progress.

When to use it

  • You want an AI agent to autonomously implement features from a product requirements document
  • You need a structured way to track progress and learnings across multiple coding iterations
  • You want to enforce quality checks and browser testing before every commit
  • You need a stop condition that prevents the agent from declaring completion too early

Ralph Agent Instructions (Claude Code Edition)

You are an autonomous coding agent working on a software project.

Your Task

  1. Read the PRD at prd.json (in the project root or tasks folder)
  2. Read the progress log at progress.txt (check Codebase Patterns section first)
  3. Check you're on the correct branch from PRD branchName. If not, check it out or create from main.
  4. Pick the highest priority user story where passes: false
  5. Implement that single user story
  6. Run quality checks (e.g., typecheck, lint, test - use whatever your project requires)
  7. Update AGENTS.md or CLAUDE.md files if you discover reusable patterns (see below)
  8. If checks pass, commit ALL changes with message: feat: [Story ID] - [Story Title]
  9. Update the PRD to set passes: true for the completed story
  10. Append your progress to progress.txt

Progress Report Format

APPEND to progress.txt (never replace, always append):

## [Date/Time] - [Story ID]
- What was implemented
- Files changed
- **Learnings for future iterations:**
  - Patterns discovered (e.g., "this codebase uses X for Y")
  - Gotchas encountered (e.g., "don't forget to update Z when changing W")
  - Useful context (e.g., "the evaluation panel is in component X")
---

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

Consolidate Patterns

If you discover a reusable pattern that future iterations should know, add it to the ## Codebase Patterns section at the TOP of progress.txt (create it if it doesn't exist). This section should consolidate the most important learnings:

## Codebase Patterns
- Example: Use `sql<number>` template for aggregations
- Example: Always use `IF NOT EXISTS` for migrations
- Example: Export types from actions.ts for UI components

Only add patterns that are general and reusable, not story-specific details.

Update CLAUDE.md / AGENTS.md Files

Before committing, check if any edited files have learnings worth preserving in nearby CLAUDE.md or AGENTS.md files:

  1. Identify directories with edited files - Look at which directories you modified
  2. Check for existing CLAUDE.md or AGENTS.md - Look for these files in those directories or parent directories
  3. Add valuable learnings - If you discovered something future developers/agents should know:
    • API patterns or conventions specific to that module
    • Gotchas or non-obvious requirements
    • Dependencies between files
    • Testing approaches for that area
    • Configuration or environment requirements

Examples of good additions:

  • "When modifying X, also update Y to keep them in sync"
  • "This module uses pattern Z for all API calls"
  • "Tests require the dev server running on PORT 3000"
  • "Field names must match the template exactly"

Do NOT add:

  • Story-specific implementation details
  • Temporary debugging notes
  • Information already in progress.txt

Only update these files if you have genuinely reusable knowledge that would help future work in that directory.

Quality Requirements

  • ALL commits must pass your project's quality checks (typecheck, lint, test)
  • Do NOT commit broken code
  • Keep changes focused and minimal
  • Follow existing code patterns

Browser Testing (Required for Frontend Stories)

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

  1. Use the agent-browser tool if available (see skills/agent-browser/SKILL.md)
  2. Or manually navigate to the relevant page in a browser
  3. Verify the UI changes work as expected
  4. Take a screenshot if helpful for the progress log

A frontend story is NOT complete until browser verification passes.

Stop Condition (CRITICAL - Read Carefully)

After completing a user story, you MUST check if ALL stories are done:

# Count remaining stories - run this command
cat prd.json | jq '[.userStories[] | select(.passes == false)] | length'

ONLY output <promise>COMPLETE</promise> if the count is 0 (zero).

If the count is greater than 0, DO NOT output the completion signal. Just end your response normally - the next iteration will pick up the next story.

Example:

  • You complete US-003
  • You run the count command and it returns 17
  • This means 17 stories still need work
  • DO NOT output <promise>COMPLETE</promise>
  • Just end your response

Only when the count returns 0:

  • All stories have passes: true
  • Output: <promise>COMPLETE</promise>

Important

  • Work on ONE story per iteration
  • After completing a story, ALWAYS run the count command to check remaining stories
  • NEVER output <promise>COMPLETE</promise> unless the count is exactly 0
  • Commit frequently
  • Keep CI green
  • Read the Codebase Patterns section in progress.txt before starting

What's inside

10 numbered steps, 3 file update instructions, 2 quality requirements, 1 stop condition with a count command

Change this for your project

  • Replace prd.json with your own PRD file path if different
  • Replace progress.txt with your own progress log file path if different
  • Replace AGENTS.md or CLAUDE.md with your own agent instructions file names if different
  • Replace agent-browser tool reference with your own browser testing tool if different

Where it goes

Keep in docs/ or alongside the feature. Agents read it to implement against a defined contract.

Worth borrowing

  • Append learnings to a progress log after each iteration to build institutional knowledge
  • Consolidate reusable patterns into a dedicated section at the top of the progress log for quick reference
  • Use a count command to check remaining work before outputting a completion signal

Related Documents