协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
ralph-mode【开发与工程】Autonomous development loops with iteration, backpressure gates, and completion criteria. Use for sustained coding sessions that require multiple iterations, test validation, and structured progress tracking. Supports Next.js, Python, FastAPI, and GPU workloads with Ralph Wiggum methodology adapted for OpenClaw.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Ralph Mode implements the Ralph Wiggum technique adapted for OpenClaw: autonomous task completion through continuous iteration with backpressure gates, completion criteria, and structured planning.
Use Ralph Mode when:
Phase 1: Requirements Definition
specs/ (one file per topic of concern)Phase 2: Planning
IMPLEMENTATION_PLAN.md with prioritized tasksPhase 3: Building (Iterative)
Reject incomplete work automatically through validation:
Programmatic Gates (Always use these):
[test command] - Must pass before committing[typecheck command] - Catch type errors early[lint command] - Enforce code quality[build command] - Verify integrationSubjective Gates (Use for UX, design, quality):
Create this structure for each Ralph Mode project:
project-root/
├── IMPLEMENTATION_PLAN.md # Shared state, updated each iteration
├── AGENTS.md # Build/test/lint commands (~60 lines)
├── specs/ # Requirements (one file per topic)
│ ├── topic-a.md
│ └── topic-b.md
├── src/ # Application code
└── src/lib/ # Shared utilities
Priority task list - single source of truth. Format:
# Implementation Plan
## In Progress
- [ ] Task name (iteration N)
- Notes: discoveries, bugs, blockers
## Completed
- [x] Task name (iteration N)
## Backlog
- [ ] Future task
Can you describe the topic in one sentence without "and"?
Succinct guide for running the project. Keep under 60 lines:
# Project Operations
## Build Commands
npm run dev # Development server
npm run build # Production build
## Validation
npm run test # All tests
npm run lint # ESLint
npm run typecheck # TypeScript
npm run e2e # E2E tests
## Operational Notes
- Tests must pass before committing
- Typecheck failures block commits
- Use existing utilities from src/lib over ad-hoc copies
Specialized roles for different tasks:
Hat: Architect (@architect)
Hat: Implementer (@implementer)
Hat: Tester (@tester)
Hat: Reviewer (@reviewer)
Usage:
"Spawn a sub-agent with @architect hat to design the data model"
Your job as main agent: engineer setup, observe, course-correct.
Each sub-agent iteration:
Loop ends when:
Define success upfront - avoid "seems done" ambiguity.
[test_command] returns 0For quality criteria that resist automation:
## Completion Check - UX Quality
Criteria: Navigation is intuitive, primary actions are discoverable
Test: User can complete core flow without confusion
## Completion Check - Design Quality
Criteria: Visual hierarchy is clear, brand consistency maintained
Test: Layout follows established patterns
Run LLM-as-judge sub-agent for binary pass/fail.
specs/
├── authentication.md
├── database.md
└── api-routes.md
src/
├── app/ # App Router
├── components/ # React components
├── lib/ # Utilities (db, auth, helpers)
└── types/ # TypeScript types
AGENTS.md:
Build: npm run dev
Test: npm run test
Typecheck: npx tsc --noEmit
Lint: npm run lint
specs/
├── data-pipeline.md
├── model-training.md
└── api-endpoints.md
src/
├── pipeline.py
├── models/
├── api/
└── tests/
AGENTS.md:
Build: python -m src.main
Test: pytest
Typecheck: mypy src/
Lint: ruff check src/
specs/
├── model-architecture.md
├── training-data.md
└── inference-pipeline.md
src/
├── models/
├── training/
├── inference/
└── utils/
AGENTS.md:
Train: python train.py
Test: pytest tests/
Lint: ruff check src/
GPU Check: nvidia-smi
Start a Ralph Mode session:
"Start Ralph Mode for my project at ~/projects/my-app. I want to implement user authentication with JWT.
I will:
When Ralph patterns emerge, update AGENTS.md:
## Discovered Patterns
- When adding API routes, also add to OpenAPI spec
- Use existing db utilities from src/lib/db over direct calls
- Test files must be co-located with implementation
When trajectory goes wrong:
For subjective criteria (tone, aesthetics, UX):
Create src/lib/llm-review.ts:
interface ReviewResult {
pass: boolean;
feedback?: string;
}
async function createReview(config: {
criteria: string;
artifact: string; // text or screenshot path
}): Promise<ReviewResult>;
Sub-agents discover and use this pattern for binary pass/fail checks.
Based on empirical usage, enforce these practices to avoid silent failures:
Ralph MUST write to PROGRESS.md after EVERY iteration. This is non-negotiable.
Create PROGRESS.md in project root at start:
# Ralph: [Task Name]
## Iteration [N] - [Timestamp]
### Status
- [ ] In Progress | [ ] Blocked | [ ] Complete
### What Was Done
- [Item 1]
- [Item 2]
### Blockers
- None | [Description]
### Next Step
[Specific next task from IMPLEMENTATION_PLAN.md]
### Files Changed
- `path/to/file.ts` - [brief description]
Why: External observers (parent agents, crons, humans) can tail one file instead of scanning directories or inferring state from session logs.
Before spawning a new Ralph session:
sessions_listAnti-pattern: Spawning Ralph v2 while v1 is still running = file conflicts, race conditions, lost work.
Never assume directory structure. At start of each iteration:
// Verify current working directory
const cwd = process.cwd();
console.log(`Working in: ${cwd}`);
// Verify expected paths exist
if (!fs.existsSync('./src/app')) {
console.error('Expected ./src/app, found:', fs.readdirSync('.'));
// Adapt or fail explicitly
}
Why: Ralph may be spawned from different contexts with different working directories.
When done, Ralph MUST:
PROGRESS.md with "## Status: COMPLETE"Example completion PROGRESS.md:
# Ralph: Influencer Detail Page
## Status: COMPLETE ✅
**Finished:** [ISO timestamp]
### Final Verification
- [x] TypeScript: Pass
- [x] Tests: Pass
- [x] Build: Pass
### Files Created
- `src/app/feature/page.tsx`
- `src/app/api/feature/route.ts`
### Testing Instructions
1. Run: `npm run dev`
2. Visit: `http://localhost:3000/feature`
3. Verify: [specific checks]
If Ralph encounters unrecoverable errors:
Do not silently fail. A Ralph that stops iterating with no progress log is indistinguishable from one still working.
Set explicit iteration timeouts:
## Operational Parameters
- Max iteration time: 10 minutes
- Total session timeout: 60 minutes
- If iteration exceeds limit: Log blocker, exit
Why: Prevents infinite loops on stuck tasks, allows parent agent to intervene.
After each Ralph Mode session, document:
## [Date] Ralph Mode Session
**Project:** [project-name]
**Duration:** [iterations]
**Outcome:** success / partial / blocked
**Learnings:**
- What worked well
- What needs adjustment
- Patterns to add to AGENTS.md
Common anti-patterns observed:
| Anti-Pattern | Consequence | Prevention |
|---|---|---|
| No progress logging | Parent agent cannot determine status | Mandatory PROGRESS.md |
| Silent failure | Work lost, time wasted | Explicit error logging |
| Overlapping sessions | File conflicts, corrupt state | Check/cleanup before spawn |
| Path assumptions | Wrong directory, wrong files | Explicit verification |
| No completion signal | Parent waits indefinitely | Clear COMPLETE status |
| Infinite iteration | Resource waste, no progress | Time limits + blockers |