编码智能体可以端到端地驱动错误修复 — 重现、定位、修复、验证、提交 — 但您可以通过限定权限、人工批准和小的可逆步骤来保持控制。智能体负责打字;您决定什么最终会合并到代码库。
循环
text
1. REPRODUCE → write/run a failing test that demonstrates the bug (red)
2. LOCATE → search the codebase, read the relevant files, form a hypothesis
3. PROPOSE → draft a minimal fix (you can review the plan before any edit)
4. VERIFY → run tests + lint/typecheck → fix is proven by the test going green
5. REVIEW → show the DIFF for your approval (nothing committed yet)
6. COMMIT → only after approval, on a branch, with a clear message
核心思想是测试驱动验证:智能体不是声称"已修复" — 而是通过让失败的测试通过来证明它。第 1 步的失败测试是证明更改有效的客观信号。
控制机制
text
- SCOPED PERMISSIONS → allowlist safe commands (test, lint); prompt for the rest
- APPROVAL GATES → human confirms destructive/irreversible actions + the final commit
- SMALL STEPS → one focused change at a time → easy to review and revert
- BRANCH / WORKTREE → work isolated from main; throw it away if it goes wrong
- DIFF REVIEW → read the actual diff before commit, not just the agent's summary
