Loading...
Loading...
Add enhancements to an existing project with Ralph Loop automation. Use when adding features to existing code, enhancing a codebase, or when the user says "ralph enhance", "add feature", or "enhance".
npx skill4agent add kroegha/ralph-skill ralph-enhanceWhat enhancement would you like to add? You can:
- Describe it in text
- Provide document path(s) with requirements
- Provide URL(s) with specifications# Detect operating system
if [[ "$OSTYPE" == "msys" ]] || [[ "$OSTYPE" == "win32" ]] || [[ -n "$WINDIR" ]]; then
PLATFORM="windows"
else
PLATFORM="unix"
fi# Find project files
find . -type f \( -name "*.py" -o -name "*.ts" -o -name "*.js" \) | head -50
ls -la# Check for existing Ralph files
ls PRD.md ralph.db scripts/ralph*.sh dashboard.html 2>/dev/null# Copy from personal skills location
RALPH_PATH=~/.claude/skills/ralph-new
cp $RALPH_PATH/../../../templates/schema.sql templates/ 2>/dev/null
cp $RALPH_PATH/../../../scripts/ralph*.sh scripts/ 2>/dev/null
cp $RALPH_PATH/../../../templates/dashboard.html . 2>/dev/null
chmod +x scripts/*.sh 2>/dev/null$ralphPath = "$env:USERPROFILE\.claude\skills\ralph-new"
Copy-Item "$ralphPath\..\..\..\templates\schema.sql" templates\ -ErrorAction SilentlyContinue
Copy-Item "$ralphPath\..\..\..\scripts\ralph*.ps1" scripts\ -ErrorAction SilentlyContinue
Copy-Item "$ralphPath\..\..\..\templates\dashboard.html" . -ErrorAction SilentlyContinuecurl -sO https://raw.githubusercontent.com/kroegha/Ralph-Skill/main/templates/dashboard.html
curl -sO https://raw.githubusercontent.com/kroegha/Ralph-Skill/main/templates/schema.sqlcat PRD.md 2>/dev/nullmkdir -p docs/enhancementsdocs/enhancements/ENH-XXX.md# Enhancement: [Title]
## Overview
[Brief description]
## Requirements
[From user input]
## Technical Approach
[How to implement]
## Affected Files
- [Files to modify]
- [New files to create]
## Testing Strategy
- Unit tests: [what]
- E2E tests: [Playwright scenarios]---
## Enhancement: ENH-XXX - [Title]
### US-XXX: [Story Title]
**Description:** As a [user], I want [feature] so that [benefit].
**Acceptance Criteria:**
- [ ] [Criterion 1]
- [ ] [Criterion 2]
- [ ] All tests pass
**Test Steps (Playwright):**
```json
[
{"step": 1, "action": "navigate", "target": "/path"},
{"step": 2, "action": "click", "target": "selector"},
{"step": 3, "action": "verify", "target": "text", "expected": "result"}
]
### Phase 6: Update Database
**Step 6.1: Add Tasks to Database**
For each new user story:
```bash
sqlite3 ralph.db "INSERT INTO tasks (task_id, name, type, status) VALUES ('US-XXX', 'Story title', 'enhancement', 'planned');"sqlite3 ralph.db "SELECT task_id, name, status FROM tasks WHERE status='planned';"// tests/e2e/enh-xxx.spec.ts
import { test, expect } from '@playwright/test';
test.describe('ENH-XXX: [Title]', () => {
test('US-XXX: [Story]', async ({ page }) => {
// Test implementation
});
});# tests/e2e/test_enh_xxx.py
from playwright.sync_api import Page, expect
def test_us_xxx_story(page: Page):
# Test implementation
passWHILE there are pending enhancement tasks in ralph.db:
1. Get next task:
TASK_ID=$(sqlite3 ralph.db "SELECT task_id FROM tasks WHERE status='planned' AND type='enhancement' ORDER BY priority LIMIT 1;")
2. If no task, check for in-progress:
TASK_ID=$(sqlite3 ralph.db "SELECT task_id FROM tasks WHERE status='in-progress' ORDER BY started_at LIMIT 1;")
3. If still no task, ALL DONE - exit loop
4. Mark as in-progress:
sqlite3 ralph.db "UPDATE tasks SET status='in-progress', started_at=CURRENT_TIMESTAMP WHERE task_id='$TASK_ID';"
5. Read task details from PRD.md
6. IMPLEMENT the task:
- Write/modify code files
- Follow existing project patterns
- Create/update tests
7. RUN tests:
# Node.js
npx playwright test tests/e2e/enh-xxx.spec.ts
# OR Python
pytest tests/e2e/test_enh_xxx.py
8. IF tests pass:
- sqlite3 ralph.db "UPDATE tasks SET status='completed', completed_at=CURRENT_TIMESTAMP WHERE task_id='$TASK_ID';"
- Update PRD.md: change [ ] to [x] for this task
- git add . && git commit -m "Complete $TASK_ID: [description]"
9. IF tests fail:
- Append error to progress.txt with learnings
- sqlite3 ralph.db "UPDATE tasks SET iteration_count=iteration_count+1 WHERE task_id='$TASK_ID';"
- Check failure count:
FAILURES=$(sqlite3 ralph.db "SELECT iteration_count FROM tasks WHERE task_id='$TASK_ID';")
if [ $FAILURES -ge 3 ]; then
sqlite3 ralph.db "UPDATE tasks SET status='failed' WHERE task_id='$TASK_ID';"
fi
- Try different approach on next iteration
10. CONTINUE to next task
END WHILE$taskId = sqlite3 ralph.db "SELECT task_id FROM tasks WHERE status='planned' ORDER BY priority LIMIT 1;"
sqlite3 ralph.db "UPDATE tasks SET status='in-progress' WHERE task_id='$taskId';"
npx playwright test
git add . ; git commit -m "Complete ${taskId}"TASK_ID=$(sqlite3 ralph.db "SELECT task_id FROM tasks WHERE status='planned' ORDER BY priority LIMIT 1;")
sqlite3 ralph.db "UPDATE tasks SET status='in-progress' WHERE task_id='$TASK_ID';"
npx playwright test
git add . && git commit -m "Complete $TASK_ID"completedfailed<promise>COMPLETE</promise><promise>FAILED</promise>| Action | Windows (PowerShell) | Unix (Bash) |
|---|---|---|
| Create directory | | |
| Copy file | | |
| Check if file exists | | |
| Run SQLite | | |
| Run Playwright | | |
| Git commit | | |
<promise>COMPLETE</promise>