小工具 · 做一个自己真会用的东西Build · Make a Tool You Will Use.
做一个批量改名预览器, 从样本、冲突规则和失败测试开始。先得到能核对的计划, 再在副本里执行, 并保留恢复清单。Build a batch-renaming previewer from examples, collision rules, and failure tests. Inspect the plan, execute only on copies, and retain a recovery manifest.
旅行回来,你想把几十张照片改成便于整理的名字。逐个改很烦,让 AI 直接接管照片文件夹又不放心。这是一个适合做个人小工具的问题:规则简单,结果能看见,做错了也应该在碰到原件之前被拦住。After a trip, you want manageable names for a few dozen photos. Renaming them individually is tedious; handing an agent the photo folder feels risky. This is a good personal-tool problem: simple rules, visible results, and errors that should be caught before touching originals.这一章的成果是一个单文件网页:输入名字,预览改名表,下载正向计划与反向映射。你不需要先学编程,但需要能说清希望怎么排、亲自看结果,以及知道它没做什么。先只做预览,实际改名是另一个需要明确授权的步骤。The deliverable is a single HTML file: enter names, preview a mapping, and download forward and reverse CSVs. You need not learn programming first, but you do need to explain the order, inspect the result, and understand its limits. Planning comes first; actual renaming is a separate action requiring explicit authorization.
— I
第一版只完成一件事Give Version One One Job.
先下载本章改名预览器,用桌面浏览器打开。它不依赖服务器、不上传名字,也不读取文件内容。页面上的文件选择器只取文件名。你也可以直接粘贴三个虚构名字,不交出任何照片:Start by downloading the rename previewer and opening it in a desktop browser. It needs no server, uploads no names, and reads no file contents. Its file picker uses names only. Alternatively, paste these three fictional names without sharing any photos:
IMG_020.jpgIMG_003.JPGIMG_011.jpg
前缀填 trip,点击「生成预览」。本工具按名字排序,忽略大小写,保留最后一个扩展名并转小写;不是按拍摄时间。得到的顺序应是 003、011、020,对应 trip-001.jpg、trip-002.jpg、trip-003.jpg。如果你要的是拍摄时间,这份工具目前就不符合要求,不能因为输出整齐而凑合接受。Enter trip as the prefix and click Preview. This tool sorts by filename, ignoring case, and retains the final extension in lowercase. It does not use capture time. Expect 003, 011, 020 to map to trip-001.jpg, trip-002.jpg, trip-003.jpg. If you need capture-time order, this tool does not meet the requirement, however tidy its output looks.这里用的是字典序,不是文件管理器常见的自然数字序:IMG_10 会排在 IMG_2 前面。练习名把数字补到同样位数,所以顺序一致。自己的文件名没有补零时,先看预览,不要猜它会如何理解数字。The order is lexical, not the natural-number sorting common in file managers: IMG_10 comes before IMG_2. The practice names use equal-width, zero-padded numbers. If yours do not, inspect the preview rather than guessing how numbers are interpreted.这次没有登录、付费 API、云数据库或发布网站的需要。先把下载的 HTML 和两份导出表保存在一个练习文件夹里。页面刷新会清空输入;它不是相册管理系统,也没有偷偷替你保存历史。No login, paid API, cloud database, or website deployment is needed. Keep the HTML and both exported tables in a practice folder. Reloading clears the inputs: this is not a photo manager and does not silently retain history.
— II
让 Codex 按你的规则做Have Codex Build to Your Rules.
如果想自己做一份,在可用的 Codex 桌面任务中选一个新建的空练习文件夹,不要选照片原件所在目录。能直接交付 HTML 的 Work 也可以尝试;这不是两个体验的排他能力分界。没有本地文件工具时,要求输出完整 HTML,保存为 .html 再打开;不要把半段代码当成可用成品。To build your own version, select a new empty practice folder in an available Codex desktop task, not the folder containing your originals. Work may also deliver an HTML file; this is not an exclusive capability boundary. Without local file tools, request the complete HTML, save it with an .html extension, and open it. A partial code snippet is not a finished tool.
提示词Prompt先说明验收,再实施Agree on checks, then build
我想做一个自己用的 <小工具>,解决 <反复遇到的麻烦>。输入是 <材料>,输出是 <能保存的成果>。先用我给的 <少量例子> 确认规则和期望结果,最多问三个会改变实现的问题。第一版只做 <最小范围>,不要添加登录、付费服务或发布。只在 <练习文件夹> 写入,不操作原件。交付可直接打开的文件、使用说明、错误输入测试和已知限制;不能运行的检查明确标未测。Build a personal <tool> for <recurring problem>. Inputs are <material> and outputs are <saveable result>. Use my <small examples> to confirm the rules and expected results, asking at most three questions that affect implementation. Version one only covers <minimum scope>: no login, paid service, or deployment. Write only in <practice folder>, never touch originals. Deliver an openable file, instructions, error-input tests, and known limits. Label checks you cannot run as untested.
请在当前空练习文件夹制作单文件 rename-preview.html,离线可用,不加载外部依赖。输入一行一个文件名和前缀 trip,只预览,绝不改文件、不读取内容、不联网。按名字排序并编号为 trip-001 加原扩展名的小写形式。IMG_020.jpg、IMG_003.JPG、IMG_011.jpg 应按 003、011、020 对应 001、002、003。拒绝重复名字、路径和不安全字符,检查已提供名字中的目标冲突。允许补充目录里的其他名字用于冲突检查,明确看不到未提供的文件。修改输入后旧预览与下载必须失效。提供正向计划和反向映射 CSV,说明后者不是已执行的撤销记录。请跑逻辑测试并实际打开页面试用;遇到浏览器不可用就写未测,不要说全部通过。Create a standalone offline rename-preview.html in this empty practice folder, with no external dependencies. Accept one filename per line and the prefix trip. Preview only: no renaming, reading contents, or network access. Sort filenames and number them trip-001 plus the lowercased original extension. IMG_020.jpg, IMG_003.JPG, IMG_011.jpg should map in 003, 011, 020 order to 001, 002, 003. Reject duplicate names, paths, and unsafe characters. Check target collisions against supplied names and an optional list of other names in the folder; state that unlisted files are invisible. Input changes must invalidate old previews and downloads. Export forward and reverse CSV mappings, explaining that reverse is not an execution undo log. Run logic tests and exercise the page in a browser. If a browser is unavailable, mark it untested rather than claiming everything passed.
先说能验收的结果,再让 agent 开工,与官方实践建议一致。1注 1Note 1OpenAI · Best practices。任务要有上下文、边界和完成条件;交付前检查实际行为。核对于 2026-10-09。OpenAI · Best practices. Give context, boundaries, and completion criteria; check the actual behavior before accepting work. Checked on 2026-10-09.这里「离线」是成品网页的运行要求,不是说让 ChatGPT 编写和修改程序也不消耗用量。不要为了这个小例子先开最高推理强度或多个 agent;做不对时先检查规则有没有说清。Specifying a checkable outcome before implementation follows the official guidance.1注 1Note 1OpenAI · Best practices。任务要有上下文、边界和完成条件;交付前检查实际行为。核对于 2026-10-09。OpenAI · Best practices. Give context, boundaries, and completion criteria; check the actual behavior before accepting work. Checked on 2026-10-09. Offline describes the finished webpage, not the process of asking ChatGPT to build or revise it. That process still uses your allowance. This small task does not need the highest reasoning setting or multiple agents by default; first inspect whether the rules are clear.
— III
用一条反例,比说「更安全」有效Give a Counterexample.
现在在「同一目标文件夹里的其他名字」里填 trip-001.jpg。重新预览,工具应拒绝生成计划,而不是悄悄覆盖、加一个莫名后缀或漏掉这张照片。这个反例是人为设计的测试,不是说某次产品运行已经真的覆盖过你的文件。Now enter trip-001.jpg under other names in the destination folder. Preview again: the tool should refuse the plan, not overwrite, invent a suffix, or skip a photo. This is a constructed test case, not a claim that a product run actually overwrote a file.
提示词Prompt把错误输入和期望行为一起交回去Return the failing input and expected behavior
我用 <具体输入> 操作 <步骤>,看到了 <实际结果>。期望是 <正确行为>,因为 <原因>。请先复现,把它加入回归测试,再做最小修复。保留原来的 <已通过行为>;不要借修复扩大功能或权限。交付修改前后差别、测试结果和仍未验证的地方。Using <exact input> with <steps>, I observed <actual result>. I expected <correct behavior> because <reason>. Reproduce it, add a regression test, and make the smallest fix. Preserve <working behavior>; do not expand features or permissions. Report the change, test results, and remaining unverified areas.
如果旧版本修改前缀后仍能下载旧计划,请这样修:任一名字、前缀或其他文件名变化时,立即清空旧结果并禁用下载,提示重新预览。测试顺序为预览 trip → 改成 holiday → 不重新预览直接点击下载;此时不得导出 trip 计划。再预览后才能下载 holiday 计划。不要增加自动改名功能。If an earlier version still exports a stale plan after the prefix changes, invalidate the result and disable downloads whenever any name, prefix, or other filename changes. Test: preview trip, change to holiday, then try downloading without another preview. It must not export the trip plan. A new preview must be required before downloading holiday. Do not add automatic renaming.
这是第二个构造反例。本书提供的版本已主动处理输入失效;你做自己的版本时,拿同样步骤验证。反馈应保留你真正看到的现象,没有遇到的错误不要冒充运行记录。This is a second constructed counterexample. The supplied version already invalidates stale input; use the same steps on your own version. Report what you actually observed, rather than presenting imagined failures as a run log.
— IV
亲手验收,不必读完所有代码Inspect Behavior Without Reading Every Line.
本章采用社区实践中的一个具体方法:让 agent 实际操作程序,而不只阅读程序后宣称正确。2注 2Note 2Simon Willison · Agentic manual testing。吸收其让 agent 实际操作程序并留下检查证据的实践;本章工具与测试材料为本书原创,不代表其他程序也经过验证。Simon Willison · Agentic manual testing. We adopt the practice of having an agent exercise the program and retain evidence. This chapter's tool and fixtures are original and do not validate other programs.你再亲手做下面几个小检查。代码测试能覆盖规则,浏览器检查能发现按钮失效、输出不可见或窄屏看不全;它们不能互相替代。This chapter adopts one concrete community practice: have the agent exercise the program rather than merely read the code and declare it correct.2注 2Note 2Simon Willison · Agentic manual testing。吸收其让 agent 实际操作程序并留下检查证据的实践;本章工具与测试材料为本书原创,不代表其他程序也经过验证。Simon Willison · Agentic manual testing. We adopt the practice of having an agent exercise the program and retain evidence. This chapter's tool and fixtures are original and do not validate other programs. Then perform a few checks yourself. Logic tests cover rules; browser checks catch broken controls, invisible outputs, and narrow-screen problems. Neither replaces the other.
按保守规则拒绝重复,不假定文件系统大小写敏感Conservative duplicate rejection, without assuming a case-sensitive filesystem
空输入、路径、已有目标名Empty input, a path, an existing target
说明错误,下载按钮不可用An explanatory error with exports disabled
预览后修改前缀Change the prefix after previewing
旧表清空,重新预览才可导出Old rows cleared; export requires another preview
下载并用表格软件打开两份 CSVDownload and open both CSVs
正向表三行,反向表把每一对名字对调Three forward mappings, with every pair swapped in reverse
刷新网页Reload the page
名字不保留;此前下载的文件仍由你保存Names are cleared; downloaded files remain yours to keep
— V
真正改文件之前,再停一下Pause Before Touching Files.
预览正确只说明已知名字的映射符合规则。工具看不到未列出的文件、软链接、磁盘权限、正在同步的云盘,也没有读取照片中的拍摄时间。大小写与 Unicode 等价重名检查是保守保护,不是对所有操作系统命名规则的完整实现。A correct preview only shows that the known names follow the rules. The tool cannot see unlisted files, symlinks, disk permissions, or an actively syncing drive, and it does not read photo timestamps. Case and Unicode-equivalent duplicate checks are conservative safeguards, not a complete implementation of every operating system's naming rules.确实要执行时,先在一个不含唯一原件的独立文件夹复制三张照片。把正向计划交给 agent,要求重新清点该文件夹,发现冲突、路径越界、数量不符就停止,先给 dry-run 结果。你确认这个明确目录和计划后,才允许执行;不要用一句「后面都不用问」替代授权。If you decide to execute, copy three photos into a separate folder containing no unique originals. Give the forward plan to the agent and request a fresh inventory and dry run. It must stop on collisions, paths outside the folder, or mismatched counts. Authorize execution only after confirming that exact folder and plan; do not replace this with blanket permission.执行者还应留下逐文件成功或失败记录,比较前后数量及内容哈希,并打开几张图片确认可读。中途失败可能只改了一半:此时不能把整份反向表盲目运行,要根据实际成功记录重新生成恢复计划并再确认。保留原件副本,直到你确认整理结果可以使用。The executor should log per-file success or failure, compare counts and content hashes, and open a few images. A failure may leave a partially renamed folder. Do not blindly run the entire reverse mapping: derive a recovery plan from the actual success log and confirm it again. Retain the original copies until you accept the result.
— VI
什么时候值得继续做Decide Whether to Keep It.
用过两次再决定下一步。若你每次都需要按拍摄时间排序,再讨论读取时间信息的权限与缺失值;若只是临时整理三张图,系统自带批量改名也许已经够用。不要因为做出了网页,就顺手增加账户、分享服务器和自动扫描整盘。Use it twice before expanding it. If capture-time sorting repeatedly matters, discuss permission to read timestamps and how missing values should behave. For three occasional photos, your operating system's batch-renaming feature may be enough. A working webpage is not a reason to add accounts, a sharing server, or whole-drive scanning.留下 HTML、练习输入、两份映射和一段已知限制,下次要改时一起给 ChatGPT。记录这次准备、修订和验收花了多久,再去长用章判断它值不值得保留。能解释规则、能复现检查、能不用它,才算这个工具真正属于你。Keep the HTML, practice inputs, both mappings, and known limits together for the next revision. Record preparation, revision, and checking time, then use the Sustain chapter to decide whether it is worth keeping. The tool is yours when you can explain its rules, reproduce its checks, and choose not to use it.
先做一个你看得懂结果的小工具,再决定给它多少权限.
First build a tool whose results you understand. Then decide how much access it needs.
CHATGPT · BUILD
— 讨论Discussion
讨论Discussion.
评论区初始化中…Initializing comments…
01 / 01
没有匹配结果No matches.
换个关键词,或按 Esc 回到页面Try another keyword, or press Esc to return