tracer-bullets

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Tracer 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

快速参考

PrinciplePractice
Vertical over horizontalBuild one slice through all layers, not one layer across all features
Verify before advancingTests pass, page renders, round-trip works before next slice
One slice per sessionEach slice should be completable in a single agent session
First feature sets patternFirst CRUD establishes conventions; subsequent CRUDs go faster
Check before buildingTask trackers may already decompose the work into slices
Skip when trivialSingle-layer work or proven patterns don't need this ceremony
原则实践方式
优先垂直而非分层构建贯穿所有层级的单个切片,而非覆盖所有功能的单个层级
验证后再推进测试通过、页面渲染完成、往返流程正常后再开始下一个切片
每个会话完成一个切片每个切片应能在单个Agent会话内完成
首个功能确立模式首个CRUD功能确立规范;后续CRUD功能可更快推进
构建前先检查任务追踪工具可能已将工作分解为切片
简单场景可跳过单一层级工作或已验证的模式无需遵循此流程

CRUD Feature Slices

CRUD功能切片

SliceScopeVerifies
1Backend/API + tests (no UI)Data layer works, conventions set, tests prove it
2List page with real dataData flows DB -> server -> rendered page
3Create dialogFull round-trip: form -> server -> DB -> refresh
4Edit + deleteFull CRUD cycle, mutation patterns, confirm dialog
5E2E testLocks 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

常见误区

MistakeCorrect Pattern
Building all API endpoints before any UIBuild one endpoint + its UI + its test, then the next
Starting UI before the backend is testedSlice 1 is backend-only with tests; prove the data layer first
Building the full create/edit/delete UI in one passCreate dialog first (slice 3), then edit + delete (slice 4)
Skipping verification between slicesRun tests and check output before starting the next slice
Making slices too large for one sessionSplit further; a slice that can't finish in one session is too big
Applying tracer bullets to trivial single-layer workSkip 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

参考资料