Ask for an explanation before the patch
Goal: Avoid blind copy-paste of code you do not understand—by forcing a plain-language diagnosis first.
Best for: Every coding chat for beginners; also useful when you are tired and tempted to “just apply it.”
If you cannot explain the bug to a friend, you should not ship the fix. Split the chat: Step A explain only; Step B patch only after OK.
Explain-then-change is a seatbelt: the model must show it understands the bug before it rewrites. You catch wrong assumptions early—when they are cheap.
If the explanation cites a file you do not have, stop. Guessing the locus is how wrong patches feel productive.
Why beginners skip this
“Just fix it” on “Avoid blind copy-paste of code you do not” skips the explain pass that catches the wrong layer The fix is one dated pass/fail on a live artifact for “Avoid blind copy-paste of code you do not”—not another bookmark. If you cannot name what you will refuse this week, you are still collecting titles
Step 1 — Two-step ask
Do this step with a real artifact open—not from memory.
Step A: Explain the bug in plain language (5 bullets). Do not give fixed code yet.
Step B: After I say “OK”, show the smallest patch and why each changed line exists.
Constraints: no unrelated refactors; no new dependencies unless I ask.
Step 2 — Minimal repro gate
Example
Filled prompt
Bug: login form submits twice on slow networks. Before any patch, ask for: suspected cause, which file/function to touch, and a 3-step verify plan. Stack: React + basic fetch. Do not invent files I did not mention.
What good output looks like
- Five bullets: suspected cause, file/function locus, why double-submit happens
- Names only React + fetch pieces you mentioned—no invented files
- Includes a 3-step verify plan you can run
- Explicitly withholds patch code until you say OK
- You could explain the bug to a teammate from the bullets alone
Step 3 — Teach-back check
Before merging:
Quiz me with 3 short questions about this bug and fix. Do not reveal answers until I reply.
If you miss two, re-read the explanation—do not ship yet.
Example
Filled prompt
Intermittent signature verify fail.
Explain 5 bullets then minimal fix in src/webhooks/ only. No secrets in chat.
Context: real workstream this week (Asia/Shanghai). Name actual files/people.
Constraints: no invented metrics/owners/prices; label Unknowns; stop before send/delete/pay.
Done check: I can mark pass/fail in one minute on the output.
What good output looks like
- Three sharp questions aimed at wrong assumptions (locus, race, retry)
- Questions would fail a model that guessed the wrong file
- Still withholds patch code in this challenge turn
- Each question is answerable from the pasted explanation
- You pause shipping if you miss more than one
Save this card
Card: Explain current behavior before you accept a patch—wrong locus is expensive—date a refuse-line this week, or nothing changed. Keep this beside the tool; read before you start.
1. What I shipped: ___ 2. What I refused: ___ 3. What I will never-do again: ___ (date: Asia/Shanghai)
- [ ] Tools/writes paused
- [ ] Refuse-line dated
- [ ] Artifact path saved
- [ ] Next link chosen (or stop)
Before you start
Open the failing test, diff, or ticket for “Avoid blind copy-paste of code you do not.” Keep secrets out of the chat. Have the file path you will name. Guide: code-explain-then-change. If you only have a blank practice box, stop and fetch the real job first.
- Goal in one line: ___
- Allowed tools: ___
- Forbidden: ___
- Human approve needed for: ___
How to use this week
This week in code: before accepting a patch, demand an explanation of current behavior and the exact locus. Wrong locus → no merge on a live artifact—not a blank demo. Write one refuse-line and date the note (Asia/Shanghai). If you only skimmed code-explain-then-change, put 25 minutes on the calendar and redo once.
Mid-week cost check: if this habit disappeared tomorrow, what breakages would you notice in 24 hours? Write one line (Asia/Shanghai).
Wrong locus check
If the explanation names files you lack, stop—the model is guessing.
Teach-back before merge
After the patch draft, ask the model to quiz you with three short questions about the bug and fix—answers withheld until you reply. Miss two? Re-read the explanation; do not ship yet.
Example
Filled prompt
Webhook signature verify failing intermittently.
Explain 5 bullets then minimal fix in src/webhooks/ only.
Stop if secrets needed in chat.
What good output looks like
- Names files/functions you provided for “Avoid blind copy-paste of code you do not understa”
- No secrets in logs; no mystery whole-repo rewrite
- Explain-before-patch or minimal repro respected
- Pass/fail: you can restate the change in 3 bullets
Red flag
Pretty patch on the wrong locus; cannot state before/after behavior in three lines—do not merge.
Pitfalls
| Pitfall | Fix |
|---|---|
| “Fix this” in one message | Hard split A/B |
| Accepting a rewrite as “simpler” | Demand smallest patch |
| Skipping the repro | Minimal repro first |
| Shipping without teach-back | 3-question quiz |
Example
Filled prompt
Job: Avoid blind copy-paste of code you do not understa
Prior fail: [what missed the check]
Repair: keep the same Done; add one constraint + one concrete example from my notes.
Boundaries: draft only; label Unknowns [?]; no silent send.
Return: fixed output + the one-minute pass/fail I will mark.
What good output looks like
- Names the prior fail without inventing a new job
- Adds one constraint tied to “Avoid blind copy-paste of code you do not understa”
- Still draft-only / Unknowns labeled
- Pass/fail: you mark green on the same checklist (code-explain-then-change #4)
Practice now
Live card: one real code change under “Ask for an explanation before the patch”—diff-only + test note (Asia/Shanghai).
Today: pick one real failing test or stack trace. Ask: explain current behavior in five bullets, then propose a minimal change. Apply only if the explain matches reality. Quiz yourself with three questions before merge.
Today card (copy) — code-explain-then-change: 1. Artifact I will produce: ___ 2. Pass/fail check: ___ 3. Refuse-line if tempted to skip verify/send: ___ (date: Asia/Shanghai) 4. One never-do from this guide: ___
- [ ] Artifact path written
- [ ] Refuse example would say "yes"
- [ ] Dated Asia/Shanghai
One sentence takeaway
Explain current behavior before you accept a patch—wrong locus is expensive—date a refuse-line this week, or nothing changed
- You can point to a dated refuse-line
- You have one artifact path from tonight
- You can teach the red flag in one sentence
Next
Minimal repro · Tests first · PR description · Coding agent boundaries · Code path
Pair with today: open the first Next link (code-minimal-repro-first) only after you dated a refuse-line for this guide (Asia/Shanghai).
先要解释,再要补丁
目标: 避免盲目粘贴你看不懂的代码——先强迫模型用白话诊断。
适合: 新手的每一次写码对话;也适合你很累、很想「直接套用」的时候。
若你不能把 bug 讲给朋友听,就不该上线修复。把对话拆开:步骤 A 只解释;你说 OK 后才进入步骤 B 补丁。
先解释再改是安全带:模型必须先证明它懂 bug,再重写。错误假设要趁还便宜时抓住。
若解释点到你没有的文件,停下。猜位置会让错误补丁显得很有产出。
为什么新手跳过
直接「帮我修」感觉快,直到你合并了改错文件的补丁。先只要解释,能在成本还低时抓住错误假设。
步骤 1——两步提问
用真实材料做这一步——不要凭记忆。
步骤 A:用白话解释 bug(5 条)。先不要给修复代码。
步骤 B:我回复「OK」后,再给最小补丁,并说明每一行改动为什么存在。
约束:不要无关重构;除非我要求,不要加新依赖。
步骤 2——最小复现闸门
实例
填好的提示词
失败现象:周二部署后 POST /api/session 返回 500。
先用五条解释当前行为(要能对上调用栈),再只在 src/auth/ 给出最小 diff。
没点名的路径,补丁直接打回。别提 force-push。
像样的输出大概长这样
- 五条:疑似原因、文件/函数位点、为何会双提交
- 只点名你提过的 React + fetch,不编文件
- 含三步你能跑的验证计划
- 明确在你说 OK 前不给补丁代码
- 单凭这五条就能跟同事讲清这个 bug
步骤 3——回讲检查
合并前:
用 3 个短问题考我这个 bug 和修复。等我回答后再公布答案。
若你错两个,重读解释——先别上线。
实例
填好的提示词
偶发问题:只有 CI 里 test_session_refresh 失败。
先给五条假设,再只在允许路径做测试修复。要是得改 infra/,先停下来问我。
像样的输出大概长这样
- 三个尖锐问题对准错误假设(位点、竞态、重试)
- 猜错文件的模型会答不上
- 本轮仍无补丁代码
- 每个问题都能从已贴解释作答
- 错超过一个就暂停发版
保存这张卡
卡面:解释当前行为与位点 → 再补丁。合入前看卡;说不清不合;缺项就停,不硬开。
1. 我交出了:___ 2. 我拒绝了:___ 3. 我永不再做:___(日期:Asia/Shanghai)
- [ ] 工具/写入已暂停
- [ ] 拒做句已标注日期
- [ ] 成品路径已存
- [ ] 已选下一步(或停)
开始前
打开你真正会用的账号/项目。准备好与「先要解释,再要补丁」相关的真实材料(不要空白练习框)。
默认姿态:在人确认发送/写入之前只出草稿。授予新工具前,先写一条带日期的拒做句(Asia/Shanghai)。
- 一句话目标:___
- 允许的工具:___
- 禁止:___
- 需要人批准:___
本周怎么用
本周对一次真实 bug:先要「当前行为 + 改动位点」解释,位点对了再接受补丁。拒绝盲贴看不懂的代码。过/不过注明日期(Asia/Shanghai)。
错误位置检查
若解释点名你没有的文件,停下——模型在猜。
把练习做完
实卡:「先要解释,再要补丁」下一次真实改代码——只要 diff + 测试备注(Asia/Shanghai)。
今天把「先要解释,再要补丁」练完:真实材料、过/不过、一句永不做。注明日期(Asia/Shanghai)。
合并前先教回去
补丁草稿出来后,让模型用三个短问题考你(先别公布答案)。错两个?重读解释,先别发版。
红旗
补丁漂亮但位点错——不合。三句话讲不清「改前/改后行为」也不合。卡上写不清就不继续——先补检查项再跑。
常见坑
| 坑 | 改法 |
|---|---|
| 一条消息「帮我修」 | 强制拆 A/B |
| 接受大重写「更简单」 | 只要最小补丁 |
| 跳过复现 | 先最小复现 |
| 不做回讲就上线 | 3 题小测验 |
实例
填好的提示词
任务:Avoid blind copy-paste of code you do not understa
上次失败:[哪条检查未过]
修复:保持同一 Done;加一条约束 + 一条你笔记里的具体例子。
边界:仅草稿;未知标 [?];禁止悄悄发送。
返回:修好的输出 + 我将打勾的一分钟过/不过。
像样的输出大概长这样
- 点名上次失败,不另起炉灶
- 约束贴着「先要解释,再要补丁」
- 仍是草稿 / 未知已标注
- 过/不过:同一张检查表能打绿(code-explain-then-change #4)
实例
填好的提示词
任务:Avoid blind copy-paste of code you
场景要点:缺陷单/diff 打开;练习编号 4/4。
边界:仅草稿;未知 [?];禁止悄悄发送;禁止编造指标。
返回:可检查产出 + 过/不过理由一行。
像样的输出大概长这样
- 约束贴着「先要解释,再要补丁」与 code-explain-then-change
- 未知标 [?];不编造负责人/数字
- 不可逆动作前停下
- 一分钟内能打过/不过(code-explain-then-change #4)
现在就练一次
今天对一个真实缺陷先只要解释,核对位点后再要补丁。写下过/不过与永不做(日期:Asia/Shanghai)。只收藏标题算失败。
今日卡片(可复制)— code-explain-then-change: 1. 我要产出的成品:___ 2. 通过/失败标准:___ 3. 若想跳过核验/发送的拒做句:___(日期:Asia/Shanghai) 4. 本篇一条永不做:___
- [ ] 成品路径已写
- [ ] 拒做例句会说「可以」
- [ ] 已标注 Asia/Shanghai 日期
一句话带走
先让模型解释当前行为与改动位点,再接受补丁;位点错了,补丁再漂亮也别合进主分支。本周对一次真实 bug 先要解释。本周留下可核对的过/不过记录并注明日期(Asia/Shanghai)
- 能指出一条带日期的拒做句
- 今晚有一条成品路径
- 能用一句话说清红旗
下一步
最小复现 · 先写测试 · 有用的 PR 描述 · 编程 Agent 边界 · 编程路径
今日搭配:先为本篇写上拒做句日期(Asia/Shanghai),再打开下一步里的第一篇(code-minimal-repro-first)。
← Back to home · Learn · Tools · Compare · Start