Pair Debugging with an AI Assistant
和 AI 助手结对排错的一段对话
读完你能和同事用英语一起排一个查不出原因的错:先让 AI 助手解释而不是直接改、一开始就把版本和堆栈喂足、用一条日志验证它的猜测、把含糊报错变成清晰问题,再从它给的几个方案里自己挑一个。文中还有一条能直接搬进团队的规矩:提 PR 时必须用自己的话把修复讲清楚。
当前浏览器暂不支持语音朗读
Scene: A checkout page is throwing an error and nobody knows why. Nadia and Tom sit together on a call, with an AI coding assistant open in the editor. Neither of them is the expert here. The point of this session is not to look smart; it is to narrow the problem down step by step, and to say out loud what each of them is thinking.
Tom: Okay, the error says "undefined is not a function" on line 40. Should we just ask the assistant to fix it? Nadia: Let's not. If we ask it to fix the file, we get a change we do not understand, and neither of us can defend it later. Let's ask it to explain line 40 first, and we keep the decision. Ten minutes of reading now saves an afternoon next week.
Tom: Fair. I will paste the stack trace and the file, and ask what could make that value undefined. Nadia: Give it the version of the library too. Last week it guessed an old API and we lost an hour to that. It has no way of knowing what we actually run unless we tell it. The more context we hand it up front, the fewer wrong turns we take later.
Tom: It says the cart object may be empty on the first render, so the method does not exist yet. That matches what we see. Nadia: It matches, but it is still a guess. Let's check it before we trust it. Add a log above line 40 and reload the page. If the cart is empty there, we have our answer.
Tom: Confirmed. The cart is empty on the first render. Nadia: Good. Now we know the real question: why does the page render before the cart loads? That is a different bug from the one we started with. Let's ask the assistant for two or three ways to handle it, and then we pick one ourselves.
Tom: It gave three options. The first one adds a loading state, the second one moves the fetch, the third one just adds a null check. Nadia: The null check would hide the problem, not fix it. I would go with the loading state. Do you want to write it, or should we walk through it together?
Tom: I will write it, and I will ask the assistant for a test too. Nadia: Good idea. One rule when we open the pull request: we explain the fix in our own words, not the assistant's. If we cannot explain it, we are not ready to ship it. The reviewers are trusting us, not the tool.
Look at how they talked. They never let the assistant own the decision. They asked it to explain before asking it to fix, they gave it context up front, they checked its guess with a log, and they turned a vague error into a clear question. Working with an AI assistant is a conversation with three voices, and the two human ones still have to agree on what is true.