tracer-bullets
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseTracer Bullets
Tracer Bullets
Build features as vertical slices through all layers, verifying each slice before starting the next. From The Pragmatic Programmer: get feedback as quickly as possible. Don't build horizontal layers in isolation (all endpoints, then all UI, then all tests). Build one thin vertical path, verify it works, then expand.
Skip for single-layer changes, one-file bug fixes, or work already decomposed into ordered vertical slices by a task tracker.
以垂直切片的方式贯穿所有层级构建功能,在开始下一个切片前先验证当前切片。出自《程序员修炼之道》:尽快获取反馈。不要孤立地构建水平分层(比如先做所有接口,再做所有UI,最后做所有测试)。先构建一条单薄的垂直路径,验证其可行后再进行扩展。
单一层级的修改、单文件bug修复,或任务追踪工具已将工作分解为有序垂直切片的场景下,无需使用此方法。
Quick Reference
快速参考
| Principle | Practice |
|---|---|
| Vertical over horizontal | Build one slice through all layers, not one layer across all features |
| Verify before advancing | Tests pass, page renders, round-trip works before next slice |
| One slice per session | Each slice should be completable in a single agent session |
| First feature sets pattern | First CRUD establishes conventions; subsequent CRUDs go faster |
| Check before building | Task trackers may already decompose the work into slices |
| Skip when trivial | Single-layer work or proven patterns don't need this ceremony |
| 原则 | 实践方式 |
|---|---|
| 优先垂直而非分层 | 构建贯穿所有层级的单个切片,而非覆盖所有功能的单个层级 |
| 验证后再推进 | 测试通过、页面渲染完成、往返流程正常后再开始下一个切片 |
| 每个会话完成一个切片 | 每个切片应能在单个Agent会话内完成 |
| 首个功能确立模式 | 首个CRUD功能确立规范;后续CRUD功能可更快推进 |
| 构建前先检查 | 任务追踪工具可能已将工作分解为切片 |
| 简单场景可跳过 | 单一层级工作或已验证的模式无需遵循此流程 |
CRUD Feature Slices
CRUD功能切片
| Slice | Scope | Verifies |
|---|---|---|
| 1 | Backend/API + tests (no UI) | Data layer works, conventions set, tests prove it |
| 2 | List page with real data | Data flows DB -> server -> rendered page |
| 3 | Create dialog | Full round-trip: form -> server -> DB -> refresh |
| 4 | Edit + delete | Full CRUD cycle, mutation patterns, confirm dialog |
| 5 | E2E test | Locks in the whole feature |
| 切片序号 | 范围 | 验证内容 |
|---|---|---|
| 1 | 后端/API + 测试(无UI) | 数据层可正常工作、规范已确立、测试可验证其有效性 |
| 2 | 展示真实数据的列表页面 | 数据可从数据库流向服务器再到渲染页面 |
| 3 | 创建对话框 | 完整往返流程:表单→服务器→数据库→页面刷新 |
| 4 | 编辑 + 删除 | 完整CRUD周期、变更模式、确认对话框 |
| 5 | 端到端测试 | 锁定整个功能 |
Non-CRUD Adaptations
非CRUD场景适配
Same principle, different slices:
- Import flow: parse one row -> display one row -> validate + dedupe -> review + commit
- Dashboard: one widget with real data -> empty/onboarding state -> layout with all widgets
- Search/palette: one entity type -> all entity types -> quick actions
- Multi-step wizard: first step end-to-end -> add steps one at a time -> final submission
遵循相同原则,切片方式不同:
- 导入流程:解析单行数据→展示单行数据→验证+去重→审核+提交
- 仪表盘:单个带真实数据的组件→空状态/引导状态→包含所有组件的布局
- 搜索/面板:单个实体类型→所有实体类型→快捷操作
- 多步骤向导:首个步骤端到端实现→逐个添加后续步骤→最终提交
Common Mistakes
常见误区
| Mistake | Correct Pattern |
|---|---|
| Building all API endpoints before any UI | Build one endpoint + its UI + its test, then the next |
| Starting UI before the backend is tested | Slice 1 is backend-only with tests; prove the data layer first |
| Building the full create/edit/delete UI in one pass | Create dialog first (slice 3), then edit + delete (slice 4) |
| Skipping verification between slices | Run tests and check output before starting the next slice |
| Making slices too large for one session | Split further; a slice that can't finish in one session is too big |
| Applying tracer bullets to trivial single-layer work | Skip for one component, one utility, or patterns already proven |
| 错误做法 | 正确模式 |
|---|---|
| 在开发任何UI前先完成所有API接口 | 先构建一个接口+对应的UI+测试,再进行下一个 |
| 后端未完成测试就开始开发UI | 切片1为仅含测试的后端部分;先验证数据层的可用性 |
| 一次性完成完整的创建/编辑/删除UI | 先实现创建对话框(切片3),再实现编辑+删除(切片4) |
| 切片之间跳过验证步骤 | 开始下一个切片前,先运行测试并检查输出结果 |
| 切片过大无法在单个会话内完成 | 进一步拆分;无法在单个会话内完成的切片规模过大 |
| 在简单的单一层级工作中使用Tracer Bullets | 单个组件、单个工具类或已验证的模式无需使用此方法 |
Delegation
任务分配
- Decompose into subtasks: Use the project's task tracker to create ordered vertical subtasks before writing code
- Isolate each slice: Delegate each slice to a subagent so failures stay contained and context stays fresh
- Find slice boundaries for non-CRUD work: Pick the smallest path through all layers as slice 1, then expand
- 分解为子任务:编写代码前,使用项目的任务追踪工具创建有序的垂直子任务
- 隔离每个切片:将每个切片分配给子Agent,确保故障可控且上下文保持清晰
- 确定非CRUD工作的切片边界:选择贯穿所有层级的最小路径作为切片1,再逐步扩展
References
参考资料
No reference files. Source: Tracer Bullets: Keeping AI Slop Under Control