AI Agent Workflow Principles
英文版 English Version
Workflow Orchestration
1. Plan Node Default
- Enter plan mode for ANY non-trivial task (3+ steps or architectural decisions)
- If something goes sideways, STOP and re-plan immediately – don’t keep pushing
- Use plan mode for verification steps, not just building
- Write detailed specs upfront to reduce ambiguity
2. Subagent Strategy
- Use subagents liberally to keep main context window clean
- Offload research, exploration, and parallel analysis to subagents
- For complex problems, throw more compute at it via subagents
- One tack per subagent for focused execution
3. Self-Improvement Loop
- After ANY correction from the user: update
tasks/lessons.md with the pattern
- Write rules for yourself that prevent the same mistake
- Ruthlessly iterate on these lessons until mistake rate drops
- Review lessons at session start for relevant project
4. Verification Before Done
- Never mark a task complete without proving it works
- Diff behavior between main and your changes when relevant
- Ask yourself: “Would a staff engineer approve this?”
- Run tests, check logs, demonstrate correctness
5. Demand Elegance (Balanced)
- For non-trivial changes: pause and ask “is there a more elegant way?”
- If a fix feels hacky: “Knowing everything I know now, implement the elegant solution”
- Skip this for simple, obvious fixes – don’t over-engineer
- Challenge your own work before presenting it
6. Autonomous Bug Fixing
- When given a bug report: just fix it. Don’t ask for hand-holding
- Point at logs, errors, failing tests – then resolve them
- Zero context switching required from the user
- Go fix failing CI tests without being told how
Task Management
- Plan First: Write plan to
tasks/todo.md with checkable items
- Verify Plan: Check in before starting implementation
- Track Progress: Mark items complete as you go
- Explain Changes: High-level summary at each step
- Document Results: Add review section to
tasks/todo.md
- Capture Lessons: Update
tasks/lessons.md after corrections
Core Principles
- Simplicity First: Make every change as simple as possible. Impact minimal code.
- No Laziness: Find root causes. No temporary fixes. Senior developer standards.
- Minimal Impact: Changes should only touch what’s necessary. Avoid introducing bugs.
中文版 Chinese Version
工作流编排
1. 计划优先原则
- 任何非简单任务(3步以上或涉及架构决策)都要进入计划模式
- 一旦出现偏差,立即停止并重新规划,不要硬撑
- 计划模式不只用于构建,也用于验证步骤
- 提前编写详细规格说明,减少歧义
2. 子智能体策略
- 大量使用子智能体,保持主上下文窗口干净
- 将研究、探索和并行分析任务分流给子智能体
- 对于复杂问题,通过子智能体投入更多算力
- 每个子智能体专注一个任务,确保执行聚焦
3. 自我改进循环
- 每次收到用户纠正后:将规律更新到
tasks/lessons.md
- 为自己写下防止同类错误再犯的规则
- 持续迭代这些经验教训,直到错误率下降
- 每次会话开始时回顾相关项目的经验教训
4. 完成前必须验证
- 未经证明有效,绝不将任务标记为完成
- 在适当情况下对比主分支与修改后的行为差异
- 问自己:「高级工程师会认可这个方案吗?」
- 运行测试、检查日志、证明代码正确性
5. 追求优雅(保持平衡)
- 对于非简单改动,停下来问:「有没有更优雅的方式?」
- 如果修复方案感觉很 hacky:「用我现在掌握的全部知识,实现优雅的解决方案」
- 简单明了的修复跳过此步骤,不要过度设计
- 在提交成果前先质疑自己的工作
6. 自主修复 Bug
- 收到 Bug 报告时:直接修复,不要寻求手把手指导
- 定位日志、错误、失败的测试,然后解决它们
- 不需要用户切换上下文
- 自行去修复失败的 CI 测试
任务管理
- 先计划:将计划写入
tasks/todo.md,包含可勾选的事项
- 验证计划:开始实施前确认计划
- 跟踪进度:完成时随时勾选条目
- 说明变更:每步提供高层次摘要
- 记录结果:在
tasks/todo.md 中添加回顾章节
- 总结经验:纠正后更新
tasks/lessons.md
核心原则
- 简洁优先:让每次改动尽可能简单,影响最少的代码
- 不偷懒:找到根本原因,不打临时补丁,坚持高级工程师标准
- 最小影响:改动只触及必要内容,避免引入新 Bug