Loading...
Loading...
Product Requirement Prompts (PRP) methodology for AI-assisted development with validation loops and autonomous execution
npx skill4agent add aradotso/ai-agent-skills prps-agentic-engineeringSkill by ara.so — AI Agent Skills collection.
# From your project root
git clone https://github.com/Wirasm/PRPs-agentic-eng.git /tmp/prp-temp
cp -r /tmp/prp-temp/.claude/commands/prp-core .claude/commands/
rm -rf /tmp/prp-tempgit clone https://github.com/Wirasm/PRPs-agentic-eng.git
cd PRPs-agentic-eng.claude/settings.local.json{
"hooks": {
"Stop": [
{
"hooks": [
{
"type": "command",
"command": ".claude/hooks/prp-ralph-stop.sh"
}
]
}
]
}
}.claude/hooks/prp-ralph-stop.sh#!/bin/bash
if [ -f .claude/prp-ralph.state.md ]; then
echo "Ralph loop still active - stopping"
exit 1
fi
exit 0chmod +x .claude/hooks/prp-ralph-stop.shyour-project/
├── .claude/
│ ├── commands/prp-core/ # PRP command files
│ ├── hooks/ # Stop hooks for Ralph
│ ├── PRPs/ # Generated artifacts
│ │ ├── prds/ # Product requirement docs
│ │ ├── plans/ # Implementation plans
│ │ │ └── completed/ # Archived plans
│ │ ├── reports/ # Implementation reports
│ │ ├── issues/ # Issue investigations
│ │ │ └── completed/ # Archived investigations
│ │ └── reviews/ # PR reviews
│ └── settings.local.json # Ralph hook configuration
├── PRPs/
│ ├── templates/ # PRP templates
│ │ ├── prp_base.md
│ │ ├── prp_story_task.md
│ │ └── prp_planning.md
│ └── ai_docs/ # Curated library docs
└── CLAUDE.md # Project guidelines/prp-prd/prp-prd "user authentication system with JWT".claude/PRPs/prds/user-auth-system.prd.md| # | Phase | Description | Status | Parallel | Depends | PRP Plan |
|---|-------|-------------|--------|----------|---------|----------|
| 1 | Auth | JWT tokens | pending | - | - | - |
| 2 | API | Auth endpoints | pending | - | 1 | - |
| 3 | UI | Login forms | pending | with 4 | 2 | - |
| 4 | Tests | Test suite | pending | with 3 | 2 | - |/prp-plan/prp-plan .claude/PRPs/prds/user-auth-system.prd.md/prp-plan "add pagination to the users API endpoint"# Implementation Plan: Feature Name
## Context
- Relevant files
- Dependencies
- Existing patterns
## Tasks
1. [ ] Task description
- Subtask details
- Files to modify
## Validation Commands
npm run type-check
npm run lint
npm test
npm run build
## Success Criteria
- [ ] All tests pass
- [ ] No type errors
- [ ] Follows existing patterns/prp-implement/prp-implement .claude/PRPs/plans/add-pagination.plan.mdcompleted/.claude/PRPs/reports/feature-name.report.md# Implementation Report: Feature Name
## Summary
Brief overview of changes
## Changes Made
- File modifications
- New files created
- Dependencies added
## Validation Results
✓ Type check passed
✓ Linting passed
✓ Tests passed (42 passing)
✓ Build successful
## Challenges & Solutions
- Challenge faced
- Solution applied
## Next Steps
- Suggested follow-ups/prp-issue-investigate/prp-issue-investigate 123.claude/PRPs/issues/issue-123-investigation.md# Issue Investigation: #123
## Issue Summary
[Auto-fetched from GitHub]
## Root Cause Analysis
- What's happening
- Why it's happening
- Where in codebase
## Proposed Solution
1. Change X in file Y
2. Add validation Z
## Implementation Plan
- [ ] Fix core issue
- [ ] Add tests
- [ ] Update docs
## Validation
npm test -- issue-123
npm run lint/prp-issue-fix/prp-issue-fix 123/prp-debug/prp-debug "users can't login after password reset"# Debug Report: Issue Description
## 5 Whys Analysis
1. Why? Users see "invalid token" error
2. Why? Token expired before email delivered
3. Why? Email queue has 5min delay
4. Why? Queue worker throttled
5. Why? Rate limit too conservative
## Root Cause
Queue worker rate limit set to 10/min, should be 100/min
## Fix
Update `config/queue.js` rate limit configuration
## Validation
- Test password reset flow
- Check email delivery time/prp-commit/prp-commit "fix validation bug in user registration" --files "auth, validation"fix(auth): fix validation bug in user registration
- Updated UserValidator.validate() to check email format
- Added test coverage for edge cases
- Fixes #123/prp-pr/prp-pr "Add user authentication" --base main --head feature/auth.github/pull_request_template.md## Description
Added JWT-based authentication system
## Changes
- Implemented JWT token generation
- Added auth middleware
- Created login/logout endpoints
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [x] Code follows style guide
- [x] Self-review completed
- [x] Documentation updated/prp-review/prp-review 456.claude/PRPs/reviews/pr-456-review.md# PR Review: #456
## Summary
Well-structured implementation with minor suggestions
## Security Issues
⚠️ HIGH: API key exposed in config file
- Move to environment variable
## Performance Concerns
💡 MEDIUM: N+1 query in user list
- Use eager loading
## Code Quality
✓ GOOD: Clean separation of concerns
✓ GOOD: Comprehensive test coverage (94%)
⚠️ MINOR: Missing JSDoc for exported functions
## Architecture
✓ Follows existing patterns
✓ Proper error handling
## Suggestions
1. Add input validation for email field
2. Consider caching user lookup
3. Extract magic numbers to constants
## Verdict
✅ APPROVE with minor changes requested/prp-ralph/prp-ralph .claude/PRPs/plans/add-user-auth.plan.md --max-iterations 20<promise>COMPLETE</promise>.claude/prp-ralph.state.md# Ralph Loop State
Plan: .claude/PRPs/plans/add-user-auth.plan.md
Max Iterations: 20
Current Iteration: 7
## Last Validation Results
✓ npm run type-check
✗ npm run lint (3 errors)
✓ npm test
✗ npm run build (compilation error)
## Current Focus
Fixing lint errors in src/auth/jwt.ts
Resolving build error in import path
## Learnings
- Arrow functions need explicit return types
- Barrel imports must use .js extension/prp-ralph-cancel/prp-ralph-cancelCLAUDE.md# Project Context for Claude Code
## Tech Stack
- Node.js 20
- TypeScript 5.3
- Express 4.18
- PostgreSQL 15
## Code Patterns
### File Structure
src/
features/
<feature>/
<feature>.controller.ts
<feature>.service.ts
<feature>.model.ts
<feature>.test.ts
### Naming Conventions
- Controllers: `XController`
- Services: `XService`
- Models: `XModel`
- Files: kebab-case
### Error Handling
```typescript
try {
await service.method();
} catch (error) {
logger.error('Context', { error });
throw new AppError('User message', 500);
}
### PRP Templates
**Base Template** (`PRPs/templates/prp_base.md`):
```markdown
# [Feature Name]
## Context
### Current State
- Describe existing implementation
- List relevant files
### Goal
- What we're building
- Why it's needed
## Technical Approach
### Architecture
- Component structure
- Data flow
### Implementation
1. Step 1
2. Step 2
## Validation
```bash
npm run type-check
npm test
## Real-World Examples
### Example 1: Adding API Pagination
**Step 1: Create Plan**
```bash
/prp-plan "add cursor-based pagination to /api/users endpoint"# Implementation Plan: API Users Pagination
## Context
- File: `src/features/users/users.controller.ts`
- Current: Returns all users (no pagination)
- Pattern: Other endpoints use `PaginationParams` from `src/utils/pagination.ts`
## Tasks
1. [ ] Update UsersController.list() signature
- Add `@Query() params: PaginationParams`
- Return `PaginatedResponse<User>`
2. [ ] Modify UsersService.findAll()
- Accept cursor and limit params
- Use cursor-based query
- Return hasMore flag
3. [ ] Add tests
- Test pagination edge cases
- Test cursor validation
## Files to Modify
- src/features/users/users.controller.ts
- src/features/users/users.service.ts
- src/features/users/users.test.ts
## Validation Commands
npm run type-check
npm run lint
npm test -- users
npm run build
## Success Criteria
- [ ] Endpoint accepts cursor and limit params
- [ ] Returns paginated results with hasMore
- [ ] All tests pass
- [ ] No type errors/prp-ralph .claude/PRPs/plans/api-users-pagination.plan.md --max-iterations 10Title: Email notifications not sent for password reset
Labels: bug, priority:high
Users report not receiving password reset emails.
Checked spam folders - emails aren't being sent at all./prp-issue-investigate 789# Issue Investigation: #789 - Email notifications not sent
## Issue Summary
Password reset emails not being sent to users
## Code Analysis
File: `src/features/auth/auth.service.ts`
```typescript
async resetPassword(email: string) {
const token = generateToken();
await this.userRepo.saveResetToken(email, token);
// BUG: emailService.send() is async but not awaited
this.emailService.send({
to: email,
subject: 'Password Reset',
template: 'reset-password',
data: { token }
});
return { success: true };
}await
**Step 2: Fix**
```bash
/prp-issue-fix 789/prp-commit "fix password reset email sending" --files auth
/prp-pr "Fix password reset email sending" --closes 789/prp-prd "real-time chat system with websockets"# PRD: Real-time Chat System
## Implementation Phases
| # | Phase | Description | Status | Parallel | Depends | PRP Plan |
|---|-------|-------------|--------|----------|---------|----------|
| 1 | Infrastructure | WebSocket server setup | pending | - | - | - |
| 2 | Data Model | Chat schema & migrations | pending | - | 1 | - |
| 3 | Backend API | Message CRUD endpoints | pending | - | 2 | - |
| 4 | WebSocket Handlers | Real-time event handlers | pending | - | 3 | - |
| 5 | Frontend UI | Chat interface | pending | with 6 | 4 | - |
| 6 | Frontend State | Redux/state management | pending | with 5 | 4 | - |
| 7 | Tests | E2E and unit tests | pending | - | 5,6 | - |/prp-plan .claude/PRPs/prds/real-time-chat-system.prd.md
# Selects Phase 1 (first pending with no dependencies)
/prp-ralph .claude/PRPs/plans/real-time-chat-phase-1.plan.md --max-iterations 15/prp-plan .claude/PRPs/prds/real-time-chat-system.prd.md # Phase 2
/prp-ralph .claude/PRPs/plans/real-time-chat-phase-2.plan.md
# ... continue through all phases# Current branch has phases 1-4 complete
git worktree add -b phase-5-ui ../chat-phase-5
git worktree add -b phase-6-state ../chat-phase-6
# Terminal 1
cd ../chat-phase-5
/prp-plan .claude/PRPs/prds/real-time-chat-system.prd.md
/prp-ralph .claude/PRPs/plans/real-time-chat-phase-5.plan.md
# Terminal 2
cd ../chat-phase-6
/prp-plan .claude/PRPs/prds/real-time-chat-system.prd.md
/prp-ralph .claude/PRPs/plans/real-time-chat-phase-6.plan.md
# After both complete, merge both branches# Create initial plan
/prp-plan "add file upload feature"
# Review generated plan, add details to plan file manually
# Then implement
/prp-implement .claude/PRPs/plans/add-file-upload.plan.md# Generate plan
/prp-plan "refactor user service to use repository pattern"
# Review plan artifact, discuss with team
# Modify plan file if needed
# Then execute with validation
/prp-ralph .claude/PRPs/plans/refactor-user-service.plan.md# Investigate issue first
/prp-issue-investigate 456
# Review investigation
# Edit investigation artifact to add context
# Then fix
/prp-issue-fix 456## Validation Commands
# Type safety
npm run type-check
# Code quality
npm run lint
npm run format:check
# Functionality
npm test
npm run test:integration
npm run test:e2e
# Build
npm run build
# Runtime
npm run dev # Manual verification checklist<promise>COMPLETE</promise># Verify hook is configured
cat .claude/settings.local.json
# Verify hook script exists and is executable
ls -la .claude/hooks/prp-ralph-stop.sh
chmod +x .claude/hooks/prp-ralph-stop.sh
# Manual cancel
/prp-ralph-cancelplans/.claude/PRPs/plans/completed/mkdir -p .claude/PRPs/plans/completed# Test commands manually
npm run type-check
npm run lint
npm test## Validation Commands
npm run type-check
npm run lint -- --fix # Auto-fix lint issues
npm test -- --testPathPattern=users # Only relevant tests/prp-plan| # | Phase | Description | Status | Parallel | Depends | PRP Plan |
|---|-------|-------------|--------|----------|---------|----------|pendingin-progresscompleteCLAUDE.md## Code Patterns
### Authentication
Always use `AuthMiddleware.verify()` before protected routes
### Database Queries
Use repository pattern from `src/repositories/base.repository.ts`
### Error Responses
```typescript
throw new AppError(
'User-facing message',
HttpStatus.BAD_REQUEST,
{ details: 'debug info' }
);
### Ralph Exceeds Max Iterations
**Symptom**: Ralph hits max iterations without completing
**Solution 1**: Increase iterations
```bash
/prp-ralph plan.md --max-iterations 50# Instead of one large plan, create multiple focused plans
/prp-plan "add user model and migration"
/prp-plan "add user service layer"
/prp-plan "add user API endpoints"## Validation Commands
npm run type-check
npm run lint
npm test
npm run build
npm run e2e # if applicableUserRepository.findByEmail()/prp-implement plan.md
/prp-commit "descriptive message" --files "relevant-keywords"cat .claude/PRPs/reports/feature-name.report.md
# Review changes, validation results, challengesPRPs/ai_docs/PRPs/ai_docs/
├── express-best-practices.md
├── typescript-patterns.md
├── jest-testing.md
└── postgresql-queries.md# Create project-specific template
cp PRPs/templates/prp_base.md PRPs/templates/prp_api_endpoint.md
# Edit to include API-specific patterns.claude/agents/# .claude/agents/database-expert.md
You are a database optimization expert.
When analyzing queries:
1. Check for N+1 issues
2. Verify indexes exist
3. Suggest query optimizations
4. Estimate query performance
Use EXPLAIN ANALYZE for all queries.## Special Instructions
@database-expert review all queries in this implementation# PRPs/templates/prp_prd_api.md
# API Feature PRD Template
## API Specification
### Endpoints
- `GET /api/resource`
- `POST /api/resource`
### Request/Response Schemas
```typescript
interface CreateResourceRequest {
name: string;
description: string;
}resource:create| # | Phase | Description | Status | Parallel | Depends | PRP Plan |
|---|---|---|---|---|---|---|
| 1 | Schema | Database schema | pending | - | - | - |
| 2 | Repository | Data access layer | pending | - | 1 | - |
| 3 | Service | Business logic | pending | - | 2 | - |
| 4 | Controller | API endpoints | pending | - | 3 | - |
| 5 | Tests | Integration tests | pending | - | 4 | - |
### Metrics and Observability
Add to validation commands:
```markdown
## Validation Commands
npm run type-check
npm run lint
npm test
npm run build
## Performance Validation
npm run benchmark -- feature-name
npm run lighthouse -- http://localhost:3000/feature
## Observability
- Check logs for errors
- Verify metrics exported
- Confirm traces captured.github/workflows/prp-validate.ymlname: PRP Validation
on:
pull_request:
paths:
- '.claude/PRPs/plans/**'
- '.claude/PRPs/reports/**'
jobs:
validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Run PRP validations
run: |
npm run type-check
npm run lint
npm test
npm run build
- name: Check for incomplete plans
run: |
if ls .claude/PRPs/plans/*.plan.md 2>/dev/null; then
echo "❌ Incomplete plans found - all plans should be archived"
exit 1
fi