Blog
Tutorials·27 min read

Ralph Wiggum 入门指南 第四部分:高级模式与故障排除

Ralph Wiggum 高级技巧——专家级提示词模式、全面的故障排除策略,以及企业级实践方案。

Jo Vinkenroye·January 18, 2026
Ralph Wiggum 入门指南 第四部分:高级模式与故障排除

你已经掌握了基础知识和核心方法论。现在让我们深入那些将业余玩家和专业人士区分开来的高级技巧。

这是你的高级实战手册——涵盖复杂场景的技巧、全面的故障排除方法,以及让你成为 Ralph 专家的企业级模式。

高级提示词工程

约束三明治模式(Constraint Sandwich Pattern)

Ralph 提示词中最有效的模式之一,是将约束条件包裹在任务周围:

# BUILDING MODE
## Pre-Constraints (What to consider first)
- Read IMPLEMENTATION_PLAN.md
- Check progress.txt for prior learnings
- Study existing patterns in the codebase
- Verify dependencies are installed
## Core Task
[Your main instruction here]
## Quality Gates (Must pass before proceeding)
- All tests pass: npm test
- Type check passes: npm run type-check
- Linter passes: npm run lint
- No console.logs or debugger statements remain
## Post-Task Actions
- Commit with semantic message
- Update IMPLEMENTATION_PLAN.md
- Append learning to progress.txt

这个模式之所以有效,是因为它按正确顺序引导 Ralph 的思考过程,这在 11 Tips for AI Coding with Ralph Wiggum 中有详细记录。

查看实际案例: 浏览社区的生产级提示词文件:

苏格拉底提问法(Socratic Prompting Technique)

与其告诉 Ralph 具体做什么,不如用问题引导它找到更好的解决方案:

弱提示词:

Implement caching for the API.

强提示词(苏格拉底式):

We need to improve API performance. Before implementing:
1. What are the slowest endpoints currently? (Analyze with profiler)
2. Which data changes frequently vs rarely?
3. What caching strategy best fits this access pattern?
4. Where should the cache layer live (app, Redis, CDN)?
After analysis, implement the most appropriate solution with tests.

这迫使 Ralph 系统性地思考问题,正如 The Ralph Playbook 中所强调的。

逃生出口模式(Escape Hatch Pattern)

永远给 Ralph 留一条出路,以防它卡住:

## If You Encounter a Blocker
1. Document the issue in progress.txt
2. Create a TODO.md file with:
- What you tried
- Why it didn't work
- What needs human decision
3. Mark the current task as "blocked" in IMPLEMENTATION_PLAN.md
4. Move to the next independent task
DO NOT spin indefinitely on unsolvable problems.

学习累积模式(Learning Accumulation Pattern)

构建 progress.txt 来积累知识:

After completing each task, append:
## [TIMESTAMP] [TASK-ID]: [Task Title]
### What Was Built
- Feature/change summary
### Technical Decisions
- Why this approach over alternatives
### Challenges & Solutions
- What went wrong and how it was fixed
### Learnings for Next Tasks
- Patterns to reuse
- Pitfalls to avoid
### Dependencies/Prerequisites for Related Tasks
- What's now available for other tasks

这将创建一个 Ralph 可以参考的知识库,避免重复犯错。

高级文件组织

多模式项目结构

对于使用全部三个阶段的复杂项目:

project-root/
├── ralph/ # Ralph-specific files
│ ├── phases/
│ │ ├── PROMPT_plan.md
│ │ ├── PROMPT_build.md
│ │ └── PROMPT_refactor.md # Optional: separate refactor mode
│ ├── IMPLEMENTATION_PLAN.md
│ ├── progress.txt
│ ├── blockers.md # Current blockers needing human input
│ └── loop.sh # Orchestrator script
├── specs/ # Requirements
│ ├── architecture.md
│ ├── features/
│ │ ├── auth.md
│ │ └── api.md
│ └── non-functional.md # Performance, security, etc.
├── docs/ # Generated documentation
├── src/ # Application code
└── tests/ # Test suite

检查点系统(Checkpoint System)

为长期运行的项目创建检查点:

# ralph/checkpoints/checkpoint-YYYY-MM-DD-description.md
## Project State
- Branch: feature/user-management
- Commit: abc123
- Tasks completed: 15/30
- Blockers: None
## Ralph Configuration
- Mode: Building
- Max iterations: 100
- Completion promise: "MILESTONE COMPLETE"
## Next Steps
1. Complete user role management (TASK-016 to TASK-020)
2. Then regenerate plan for Phase 2 features
3. Consider splitting into separate Ralph session
## Learnings So Far
- Database schema changes require migration strategy
- Test data setup takes 2-3 iterations
- Auth patterns now stable and reusable

为 Ralph 设置 PRD

一个结构良好的 PRD(Product Requirements Document,产品需求文档)对 Ralph 的成功至关重要。这是 specs/*.md + IMPLEMENTATION_PLAN.md 方法的替代方案——有些团队更喜欢用 JSON 格式,因为机器可读性更好。

辅助工具: Ralph TUI 包含 /ralph-tui-prd 可以交互式创建 PRD,以及 /ralph-tui-create-json 可以将其转换为 JSON。snarktank/ralph 提供基于 PRD 驱动的任务管理,支持自动分支和流程图可视化。

prd.json 模板

{
"project": "Todo API",
"schema_version": "2.0",
"final_tests": ["npm test", "npm run type-check", "npm run lint"],
"stories": [
{
"id": "S001",
"priority": 1,
"title": "User Authentication",
"category": "backend",
"description": "Implement JWT-based authentication with login/logout",
"acceptance": [
"User can register with email/password",
"User can login and receive JWT token",
"Protected routes require valid JWT",
"User can logout and invalidate token"
],
"steps_to_verify": [
"Run: npm test -- auth.test.ts",
"Verify all 12 auth tests pass",
"Check JWT is stored in httpOnly cookie",
"Verify token expiry works correctly"
],
"tests": ["npm test -- auth.test.ts"],
"estimated_complexity": "medium",
"depends_on": [],
"passes": false
},
{
"id": "S002",
"priority": 2,
"title": "Todo CRUD Endpoints",
"category": "backend",
"description": "Create POST, GET, PUT, DELETE endpoints for todos",
"acceptance": [
"POST /api/todos creates a todo",
"GET /api/todos returns user's todos only",
"PUT /api/todos/:id updates a todo",
"DELETE /api/todos/:id deletes a todo"
],
"steps_to_verify": [
"Run: npm test -- todos.test.ts",
"Test with Postman or curl",
"Verify authorization works"
],
"tests": ["npm test -- todos.test.ts"],
"estimated_complexity": "medium",
"depends_on": ["S001"],
"passes": false
}
]
}

PRD 关键原则

二元通过/失败标准:每个任务都需要自动化验证。正如 The Ralph Playbook 所强调的:「让它变好」是无法测试的——「所有测试通过且覆盖率超过 80%」才是可验证的。

原子化任务:如果一个任务需要 500 行以上的代码,就把它拆分。每个 story 应该在 2-3 次迭代内完成。

passes 字段:Ralph 完成后会将其更新为 true。循环会持续运行,直到所有任务通过。

测试要求:每个 story 都应该指定如何自动验证完成情况。不要有手动验证步骤。

常见陷阱及规避方法

起步太激进

错误做法: 在你的第一个 Ralph 项目上就跑 50 次迭代。

正确做法: 从 10-20 次迭代开始,了解成本和行为模式。正如社区建议中记录的,一个 50 次迭代的循环可能花费 $50-100 以上。

完成标准模糊

错误做法: 「让应用更快」或「改善 UI」

正确做法: 使用具体、可测试的标准:

  • ✅ 「将 API 响应时间降低到 200ms 以下(通过负载测试验证)」
  • ✅ 「所有 Lighthouse 分数超过 90」
  • ✅ 「所有模块的测试覆盖率超过 80%」

没有自动化验证

错误做法: 需要人工判断的任务,比如「让它好看点」

正确做法: Ralph 需要二元的通过/失败条件。如果你无法为它写自动化测试,Ralph 就无法验证。正如 The Ralph Playbook 所说:「反压胜过方向。」

任务太大

错误做法: 把「构建整个认证系统」作为一个任务

正确做法: 拆分成更小的 story:

  • S001:用户注册端点
  • S002:带 JWT 的登录端点
  • S003:Token 刷新机制
  • S004:密码重置流程
  • S005:邮箱验证

忽略上下文限制

错误做法: 让 Ralph 无限运行而不刷新上下文

正确做法: 对长期运行的项目使用 Bash 循环方法而非插件——每次迭代获得全新的上下文窗口。这是 Geoffrey Huntley 指南中的关键洞见。

何时使用哪种方法:

  • < 20 次迭代:插件(/ralph-loop)就足够了——设置简单,上下文可控
  • 20-40 次迭代:两种都可以;推荐 bash 循环以保持一致性
  • > 40 次迭代:必须使用 bash 循环——防止上下文退化和幻觉

插件在单个上下文窗口中运行所有内容,随时间推移会填满。bash 循环方法则每次迭代启动一个全新的 Claude 实例,只有代码库状态会延续。

没有成本监控

错误做法: 开发期间不追踪 API 支出

正确做法: 设置账单提醒,从低迭代次数开始。监控每次迭代的成本。在 https://console.anthropic.com 追踪你的支出。

任务类型选错

适合 Ralph 的任务:

  • 将测试从 Jest 迁移到 Vitest
  • 添加带测试的 CRUD 端点
  • 实现规格明确的功能
  • 在已有测试覆盖下进行重构

不适合 Ralph 的任务:

  • 「找出为什么应用变慢了」(探索性的)
  • 「让 UI 更漂亮」(主观的)
  • 「修复这个奇怪的 bug」(需要深度调试上下文)
  • 需要审美判断的 UX 决策

抖动问题(Thrashing Problem)

症状: Ralph 陷入循环——同样的错误,同样的修复尝试,同样的失败。

解决方案:

  • 设置 --max-iterations 限制损失
  • 检查你的测试——是否过于严格或不够清晰?
  • 将任务拆分成更小、更原子化的部分
  • 在提示词中添加明确的调试步骤
  • 检查依赖是否正确安装

全面故障排除指南

问题:Ralph 反复犯同样的错误

症状:

  • 多次迭代中出现相同错误
  • 测试以相同消息失败
  • Ralph 反复尝试同一种方法

根本原因:

  1. 测试模糊或写错了
  2. 提示词没有包含错误反馈
  3. Ralph 缺乏理解为什么方法失败的上下文

解决方案:

修复 1:更新测试

// Bad: Vague assertion
expect(result).toBeTruthy();
// Good: Specific assertion
expect(result).toEqual({
id: expect.any(String),
email: 'test@example.com',
createdAt: expect.any(Date)
});

修复 2:在提示词中添加错误反馈

If tests fail:
1. Read the test output carefully
2. Identify the specific assertion that failed
3. Check if you're testing the wrong behavior
4. Try a different approach if current one fails twice

修复 3:添加明确的调试步骤

Before implementing:
1. Add console.log to see actual vs expected values
2. Run test in isolation: npm test -- --testNamePattern="specific test"
3. Verify mock data matches what code expects

修复 4:使用逃生出口模式

如果 Ralph 在多次尝试后仍然失败,使用逃生出口模式来记录阻塞问题,然后转向下一个任务,而不是无限循环。

问题:Ralph 生成不安全的代码

症状:

  • 密码以明文存储
  • SQL 注入漏洞
  • 缺少认证检查
  • CORS 设置为 "*"

预防方法:

在提示词中添加安全检查清单:

## Security Checklist (MUST verify before committing)
Authentication:
- [ ] Passwords hashed with bcrypt (min 12 rounds)
- [ ] JWTs signed with secure secret (min 32 chars)
- [ ] httpOnly cookies for token storage
- [ ] No secrets in code (use env variables)
Authorization:
- [ ] All protected routes have auth middleware
- [ ] User can only access own resources
- [ ] Admin endpoints check role
Input Validation:
- [ ] All user input validated with Zod/Joi
- [ ] SQL/NoSQL injection prevented (use ORMs)
- [ ] XSS prevention (sanitize HTML)
- [ ] Rate limiting on sensitive endpoints
CORS:
- [ ] Specific origins only (not "*")
- [ ] Credentials: true only with specific origin

问题:上下文窗口耗尽

症状:

  • Ralph 开始忽略提示词的部分内容
  • 第 30-40 次迭代后质量下降
  • Ralph 不再遵循约束条件

正如 JeredBlu 的指南所解释的,这就是为什么使用 bash 循环方法(每次迭代获得新上下文)对于长期运行任务来说「从根本上更好」。

解决方案:

方案 1:使用 Bash 循环方法

# loop.sh - Fresh context each iteration
while true; do
claude < PROMPT_build.md
# Check if done
if grep -q "ALL TASKS COMPLETE" progress.txt; then
echo "Build complete!"
break
fi
sleep 2
done

方案 2:上下文压缩提示词

关于 /compact /compact 命令会压缩你的对话上下文,让你能在不丢失重要细节的情况下继续工作。在接近上下文限制之前主动使用它。参见 Mastery Part 2 了解何时使用 /compact/clear

Every 10 iterations, before continuing:
1. Run: /compact to compress context
2. Summarize current state:
- Tasks completed
- Current task in progress
- Key patterns established
3. Continue with fresh focus

方案 3:拆分长会话

# Session 1: Core features (Tasks 1-10)
/ralph-loop "$(cat PROMPT_build.md)" --max-iterations 30
# Review, commit, take a break
# Session 2: Advanced features (Tasks 11-20)
/ralph-loop "$(cat PROMPT_build.md)" --max-iterations 30

问题:Ralph 停不下来(抖动)

症状:

  • 达到最大迭代次数仍未完成
  • 做出更改,又撤销,然后重复
  • progress.txt 显示循环逻辑

关于 Ralph 在抖动时的决策过程深入分析,Braintrust 的调试指南展示了如何使用 LLM 可观测性工具来理解正在发生什么。

诊断方法:

检查 progress.txt 中的模式:

[14:30] Trying approach A...
[14:35] Approach A failed, trying approach B...
[14:40] Approach B failed, trying approach A again...

解决方案:

方案 1:添加尝试次数追踪

Track attempts in progress.txt:
[Iteration X] TASK-005: Attempt #1 - Trying JWT with RSA
[Iteration Y] TASK-005: Attempt #2 - Trying JWT with HS256
[Iteration Z] TASK-005: Attempt #3 - Adding fallback
If task has 3 failed attempts:
1. Mark task as "blocked"
2. Document in blockers.md
3. Move to next task

方案 2:简化验收标准

# Too complex (causes thrashing)
- API must be performant, secure, and scalable
# Specific (Ralph can verify)
- API responds in <200ms (verified by tests)
- All endpoints require authentication (verified by tests)
- Can handle 100 concurrent requests (load test passes)

问题:测试覆盖率随时间下降

症状:

  • 早期任务有很好的测试
  • 后期任务测试很少
  • 覆盖率低于目标

根本原因: 当没有强制要求时,Ralph 会优先发布而不是测试。

解决方案: 在提示词中添加测试覆盖率门槛:

## Test Requirements (STRICT)
Every commit MUST include tests for:
1. Happy path (success case)
2. Error cases (4xx, 5xx)
3. Edge cases (empty input, missing fields)
4. Authorization (access control)
Before committing, run: npm test -- --coverage
MINIMUM COVERAGE REQUIRED:
- Statements: 80%
- Branches: 75%
- Functions: 80%
- Lines: 80%
If coverage drops below threshold:
- DO NOT commit
- Add missing tests
- Re-run coverage

问题:Ralph 忽略现有模式

症状:

  • 新代码使用了与现有代码不同的模式
  • 文件结构不一致
  • 同一件事有多种做法

解决方案: 在提示词中添加模式文档。包含项目的实际文件结构和命名约定,让 Ralph 保持一致性:

## Codebase Patterns (MUST FOLLOW)
Before implementing any feature:
1. Study existing features as reference (e.g., the user module)
2. Follow the same directory structure and file organization
3. Reuse established naming conventions and code patterns
4. Only deviate if specs explicitly require it
If unsure about a pattern, check how similar features are implemented
in the codebase before writing new code.

Ralph-TUI 高级配置

Ralph-TUI 支持通过 ~/.ralph-tui/config.json 配置文件进行自定义。

自定义任务优先级

覆盖默认的优先级排序:

{
"taskPriority": {
"TASK-001": 10,
"TASK-005": 9,
"TASK-002": 8
}
}

Ralph-TUI 会按此顺序显示任务,即使 IMPLEMENTATION_PLAN.md 中的列表顺序不同。

输出过滤

按关键词或正则表达式过滤日志行:

{
"logFilters": {
"exclude": ["Reading", "Skipping"],
"include": ["✓", "✗", "completed", "failed"]
}
}

这会隐藏嘈杂的行(文件读取),并突出显示重要事件(测试结果、任务完成)。

导出格式

选择日志导出格式:

{
"exportFormat": "markdown"
}

选项:txtmarkdownjsonhtml

Markdown 导出 会生成:

# Ralph-TUI Log Export
**Project:** my-saas-app
**Duration:** 2h 15m
**Tasks Completed:** 12 / 15
## Iteration 1
[10:05:12] Reading specs...
...

与其他工具集成

将 Ralph-TUI 事件发送到外部系统:

{
"webhooks": {
"taskComplete": "https://myapp.com/api/ralph-task-complete",
"testFailure": "https://myapp.com/api/ralph-test-failed"
}
}

当 Ralph 完成一个任务时,Ralph-TUI 会向你的 webhook 发送 POST 请求:

{
"event": "taskComplete",
"taskId": "TASK-003",
"timestamp": "2026-01-16T10:30:45Z",
"iteration": 12
}

使用场景:

  • 更新项目管理工具(Linear、Jira)
  • 发送 Slack 通知
  • 任务完成时触发 CI/CD 流水线

Ralph-TUI 故障排除

Ralph-TUI 检测不到 Ralph 循环

症状: ralph-tui run 无限显示 "Waiting for Ralph loop..."。

原因: Ralph-TUI 会在当前目录查找正在运行的 ralph 进程。如果你在不同目录启动了 Ralph,Ralph-TUI 就找不到它。

解决方案:

  1. 运行 ps aux | grep ralph 找到 Ralph 进程
  2. 通过 lsof -p <pid> 记下工作目录
  3. cd 到该目录并重新运行 ralph-tui run

替代方案: 直接指定 Ralph 进程 ID:

ralph-tui run --pid 12345

会话丢失/损坏

症状: 启动时 Ralph-TUI 显示 "Session data corrupted"。

原因: Ralph-TUI 将会话状态存储在 ~/.ralph-tui/sessions/<project-name>.json。如果 Ralph 在迭代中途崩溃,会话文件可能不完整。

解决方案:

  1. 删除损坏的会话:rm ~/.ralph-tui/sessions/my-project.json
  2. 重启 Ralph-TUI:ralph-tui run

Ralph-TUI 会创建一个新会话,但你会丢失历史上下文(之前的迭代不会显示在日志中)。

预防措施: 在配置中启用会话备份:

{
"sessionBackups": {
"enabled": true,
"interval": 300
}
}

这会每 5 分钟在 ~/.ralph-tui/sessions/backups/ 创建备份。

大日志文件导致的性能问题

症状: 监控数小时后 Ralph-TUI 变慢或无响应。

原因: 日志缓冲区增长到 100,000+ 行,拖慢了渲染速度。

解决方案:

  1. 定期导出日志:每小时按 e
  2. 在配置中启用日志轮转:
{
"logRotation": {
"maxLines": 10000,
"archiveOld": true
}
}

当日志达到 10,000 行时,Ralph-TUI 会将旧日志归档到 ~/.ralph-tui/archives/ 并清空缓冲区。

替代方案: 如果你的终端支持,增加终端缓冲区大小(例如 iTerm2 → Preferences → Profiles → Terminal → Scrollback lines)。

端口冲突

症状: ralph-tui run 失败并提示 "Port 9876 already in use"。

原因: Ralph-TUI 使用 9876 端口进行内部通信。另一个进程正在使用它。

解决方案:

  1. 找到冲突进程:lsof -i :9876
  2. 终止它或使用不同端口:
ralph-tui run --port 9999

永久修复: 在配置中设置默认端口:

{
"port": 9999
}

使用 Playwright MCP 实现无头可视化反馈

对于没有可见浏览器的 bash 循环运行,JeredBlu 推荐使用 Playwright MCP 进行可视化验证。

什么是 MCP? MCP(Model Context Protocol,模型上下文协议)是一个开放标准,让 Claude 连接外部服务——数据库、API、浏览器自动化等。MCP 服务器将 Claude 的能力扩展到文本处理之外。参见 Mastery Part 7: MCP Servers 了解设置和配置。

在项目根目录创建 .mcp.json

{
"mcpServers": {
"playwright": {
"command": "npx",
"args": ["-y", "@playwright/mcp@latest", "--headless", "--output-dir", "screenshots"]
}
}
}

然后在你的 PROMPT_build.md 中引用它:

After implementing, use Playwright to:
1. Navigate to the local server URL
2. Take a screenshot: screenshots/[task-name].png
Include the screenshot filename in your progress.txt entry.

这让你无需 Claude for Chrome 或可见浏览器窗口,就能对 Ralph 的工作进行可视化验证。截图会积累在你的项目文件夹中,提供 Ralph 构建内容的可视化审计追踪。

何时使用 Playwright MCP vs Ralph-TUI:

  • Ralph-TUI: 实时日志监控、任务编排、键盘控制
  • Playwright MCP: 无头可视化验证、截图审计追踪、CI/CD 集成

两个工具互为补充——用 Ralph-TUI 进行实时监控,用 Playwright MCP 进行可视化验证。

企业级模式

多开发者 Ralph 协作

当多个开发者在同一项目上使用 Ralph 时,协调变得至关重要。有几个工具可以帮助:

  • ralph-orchestrator — 支持 7+ AI 后端(Claude、Gemini、Copilot 等),带有 persona/hat 系统用于专项任务
  • multi-agent-ralph-loop — 并行工作流编排,用于同时运行多个 Ralph 实例
  • ralph-loop-agent — Vercel 的 TypeScript SDK 封装,用于程序化控制

模式 1:功能分支 Ralph

# Developer A
git checkout -b feature/auth
# Run Ralph for auth tasks
./loop.sh build --tasks "TASK-001 to TASK-005"
# Developer B (different branch)
git checkout -b feature/payments
# Run Ralph for payment tasks
./loop.sh build --tasks "TASK-010 to TASK-015"
# Merge both when complete

模式 2:共享进度追踪

# team-progress.md
## Active Ralph Sessions
### Developer: Alice
- Branch: feature/auth
- Tasks: TASK-001 to TASK-005
- Status: In Progress (3/5 complete)
- ETA: 2 hours
### Developer: Bob
- Branch: feature/payments
- Tasks: TASK-010 to TASK-015
- Status: Complete
- Ready for: Code review
## Blocked Tasks Needing Team Discussion
- TASK-008: Payment provider API unclear
- TASK-014: Architecture decision needed

Ralph + CI/CD 集成

在你的流水线中自动化 Ralph 运行:

# .github/workflows/ralph-build.yml
name: Ralph Autonomous Build
on:
workflow_dispatch:
inputs:
tasks:
description: 'Task range (e.g., TASK-001 to TASK-005)'
required: true
jobs:
ralph-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Claude Code
run: curl -fsSL https://claude.ai/install.sh | bash
- name: Run Ralph Loop
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
./loop.sh build \
--tasks "${{ github.event.inputs.tasks }}" \
--max-iterations 30
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
with:
title: "Ralph Build: ${{ github.event.inputs.tasks }}"
body: |
Autonomous build completed by Ralph Wiggum
Tasks completed:
${{ github.event.inputs.tasks }}
See progress.txt for details.

为 Ralph 选择 Claude 订阅方案

Ralph 可以配合 Claude 订阅或 API 使用。以下是快速指南:

  • Claude Pro ($20/月) — 每次会话 10-30 次迭代,适合学习和个人项目
  • Claude Max 5x ($100/月) — 每次会话 50-150 次迭代,适合日常开发
  • Claude Max 20x ($200/月) — 每次会话 200-600+ 次迭代,适合专业长时间运行循环

建议: 先用 Pro 学习工作流程。当你每天都在使用 Ralph 时升级到 Max 5x——5 倍的容量对应 5 倍的价格,很合理。如果你在做客户项目或需要长时间自主运行会话,就选 Max 20x。

投资回报计算: Max 20x 每月 $200,如果 Ralph 只帮你节省 5 小时(按 $40/小时计费),就已经回本了。大多数认真使用的用户报告每月节省 20-40+ 小时。

成本管理技巧

  • 始终设置 --max-iterations — 你真正的安全网
  • 从小处开始 — 在了解成本之前先跑 10-20 次迭代
  • 精准的提示词 = 更少的迭代 — 模糊的提示词会浪费 token
  • 追踪你的用量 — 在 https://claude.ai/settings 查看

总结

你现在已经掌握了帮助你更好地使用 Ralph 的高级技巧。这些技巧让你能够自信地处理复杂的生产级项目。你知道了如何在问题发生之前预防它们,以及在出现问题时快速修复。

更多资源,请探索 The Ralph Playbook 获取全面的方法论文档,Geoffrey Huntley 的原始指南了解这项技术背后的哲学,以及 JeredBlu 的实用指南获取可以直接复制粘贴的配置。

Quick Reference

Bash 循环方法(每次迭代全新上下文)— while true; do claude < PROMPT_build.md; done

上下文压缩/compact

检查抖动grep -E "Attempt #[0-9]+" progress.txt

会话管理./loop.sh build --tasks "TASK-001 to TASK-005"

CI/CD 集成claude -p "$(cat PROMPT_build.md)" --output-format text

核心要点

高级提示词模式(约束三明治、苏格拉底式、逃生出口)能提升 Ralph 的效率

第 30-40 次迭代后的上下文窗口耗尽是切换到 bash 循环方法的信号

抖动问题可以通过 progress.txt 的模式来诊断

企业级模式实现了多开发者与 Ralph 的协作

CI/CD 集成将 Ralph 运行自动化到流水线中

Stay Updated

Get notified about new posts on automation, productivity tips, indie hacking, and web3.

No spam, ever. Unsubscribe anytime.

Comments

Related Posts