prompt-engineering
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseA prompt states a goal and gets out of the way. Everything else in it is load — spent on every run, taken from the attention the model would otherwise put on the work — so each line has to buy more than it costs. What follows decides four things: what the run is given, whether a line exists, where it sits, and how it is worded.
一个 prompt 陈述目标,然后不再添置。其余内容全都是负载——每次运行都要付出代价,并从模型原本可以投入任务的注意力中扣除——因此每一行带来的价值都必须高于其成本。后文将决定四件事:运行获得了哪些输入、某一行是否有必要存在、它应放在哪里,以及应如何措辞。
What the run has in front of it
运行实际接收到的内容
A run's result is bounded by what it has in front of it: the prompt and everything fed into it — the inputs filled into a template, the files it reads, retrieved material, tool output, the conversation so far, what a handed-off agent receives. The model is usually capable enough, so bad output usually traces to that input. When a run underperforms, read what it actually had — the trace or the filled-in input, not the template alone — before you change any wording, and look for four faults:
- Missing — a piece the task needs is not there, so the run guesses.
- Conflicting — two pieces disagree, so the run picks one.
- Wrong or stale — a piece is untrue or out of date, so the run repeats it.
- Noise — what matters is there, buried under material that does not bear on the task.
Fix the input first: supply the piece or a pointer that reaches it, choose one source where two disagree, correct or drop what is wrong, cut what buries the signal. That usually moves the result more than any other change. Wording edits and after-the-fact corrections — a review pass, a self-check, a rule added after a failure — come after it. A correction that makes up for faulty input leaves the fault in place, and the next run meets it again.
Complete means complete for the task: the fix usually trades noise for the missing piece rather than adding volume. Look to the instructions when the input is already complete, consistent and clean; when the model lacks a capability no input can supply, change the architecture instead.
一次运行的结果受其实际接收到的内容限制:prompt 以及送入其中的一切——填入模板的输入、它读取的文件、检索到的材料、工具输出、当前对话,以及转交给 agent 的内容。模型的能力通常足够,因此糟糕的输出通常可以追溯到这些输入。运行效果不佳时,在改动任何措辞之前,先查看它实际拥有的内容——trace 或填充后的输入,而不只是模板——并寻找四类故障:
- 缺失——任务所需的内容没有提供,因此运行只能猜测。
- 冲突——两处内容彼此矛盾,因此运行只能择一。
- 错误或过时——某处内容不真实或已经过期,因此运行会将其照搬。
- 噪声——重要内容其实存在,却被与任务无关的材料淹没。
先修复输入:补上缺失的内容,或提供能够触达它的指针;若两处内容冲突,就选定一个来源;纠正或删除错误内容;删掉淹没有效信号的材料。这通常比其他任何改动都能更好地改善结果。措辞调整和事后补救——增加一轮审查、自检步骤,或在失败后新增规则——都应放在其后。用于弥补错误输入的补救会把问题保留下来,下次运行还会再次遇到它。
所谓完整,是相对于任务而言的完整:修复通常是从噪声中腾出空间来补齐缺失内容,而不是单纯增加篇幅。输入已经完整、一致且干净时,再去考虑指令;若模型缺少某种任何输入都无法提供的能力,则应改变架构。
Where a line came from
一行内容的来源
Ask this before asking whether the line helps. A line can be true, relevant, and still worth cutting, so usefulness does not settle it. Provenance does, and you can answer it from memory:
- The user ruled it — a decision, preference, or constraint they stated. Nothing derives it. Keep.
- The world holds it, out of the run's reach — an unwritten convention, a failure you observed, a fact outside what the run will read. Keep, and prefer a pointer to the source over a copy that can go stale.
- It counteracts a default you have watched the model take — keep, when the default is observed rather than feared.
- You worked it out from material the run will also read — cut. A conclusion available in the corpus is one the run reaches itself, so writing it down buys nothing and spends load on every invocation.
That last class is the one that feels most earned, because you did the work to reach it, and it is where over-specification comes from. Two tells: a line you could justify from the same sources the run gets, and a sentence that merely argues for the instruction above it without adding information admitted by the tests above.
A choice the request left open belongs to whoever made the request. Some of what you would add is not padding but a decision — what ranks one candidate over another, an exception to a rule they gave you, a deliverable beyond what they asked for. It reads as thoroughness and it commits them to something they never chose, under their name, in a file they will quote back later. Ask where the answer would change the work; leave it out where it would not.
A finished prompt looks thinner than you expect it to, and that is the result rather than a warning sign. Two rulings and a goal make a short document; the pull at that point is to fill it out — a section on how to rank, a definition of the term in its own name, a third source of evidence nobody asked for — and everything reached for that way comes from the class above. When it reads as too slight, check the goal is stated and the rulings are in it, then ship it.
The counterfactual question — would the model do this without the line? — asks for a prediction about the model's own behaviour, which is not reliably answerable from the inside. Ask it second, of what provenance already admitted: it can still cut a line provenance allowed, never keep one provenance rejected.
When two people disagree about whether a line is doing work, the argument is about the model's default, so settle it by running the document with the line removed and comparing. That is a tiebreak available when it is worth the trouble, not a step every line has to pass.
在问一行内容是否有用之前,先问它从何而来。一行内容可能真实、相关,却仍值得删除,因此是否有用并不能决定去留;来源可以,而且你通常可以凭记忆回答:
- 用户裁定过——这是用户明确提出的决定、偏好或约束,没有其他来源可以推导得出。保留。
- 外部世界事实成立,但运行触达不到——例如不成文的惯例、你观察到的失败,或运行不会读取范围之外的事实。保留,但优先使用指向来源的指针,而不是可能过时的副本。
- 它抵消了你曾观察到模型表现出的默认行为——如果这种默认行为来自实际观察,而不只是担忧,则保留。
- 你根据运行也会读取的材料推导出了它——删除。语料中已有的结论,运行本身就能得出;把它写下来不会增加任何信息,却会在每次调用时消耗负载。
最后一类最容易让人觉得来之不易,因为正是你付出劳动才得出它,而过度规定也正源于此。有两个迹象:一行内容可以依据运行所获得的相同来源来论证;另一句话只是为上面的指令进行辩护,却没有增加上述检验所接纳的新信息。
请求未作选择的事项,应由提出请求的人决定。 你可能想补充的一些内容并非填充物,而是替对方作决定——例如哪个候选项优先、是否偏离对方给出的规则,或增加对方未要求的交付物。这看起来很周全,实际上却以对方的名义,把他们从未选择过的方案写进之后会被他们反过来引用的文件中。判断答案在哪些地方会改变工作结果;不会改变的地方,就不要加入。
完成后的 prompt 往往比你预期的更短,这是结果,而不是警告信号。 两项裁定和一个目标就足以构成一份简短文档;到了这一步,人会忍不住继续填充——增加一节排序方法、用术语自身的名称来定义该术语,或引入无人要求的第三种证据来源——而这种伸手去拿的内容全都来自上一类。读起来觉得过于单薄时,检查目标是否已经写明、裁定是否都已纳入,然后就可以交付。
反事实问题——没有这一行,模型会这样做吗?——要求预测模型自身的行为,而这种预测无法从内部可靠回答。第二个再问这个问题,并且只针对来源已经允许保留的行:它可以用来删掉来源允许的一行,却绝不能用来保留来源已否决的一行。
当两个人对一行内容是否发挥作用产生分歧时,争点其实是模型的默认行为,因此可以通过删除该行后运行文档并比较结果来判定。这是在值得费劲时可用的决胜手段,不是每一行都必须经过的步骤。
Author upward
从目标向上撰写
Start from the goal sentence. Add only what the questions above admit, one line at a time.
Writing broadly and pruning afterwards costs more and lands longer: every line you would cut is one you already argued for, and the draft's own weight reads as evidence that it was needed.
从目标句开始。只逐行加入上述问题所允许的内容。
先广泛起草再事后删减,成本更高,成稿也会更长:每一行你后来会删掉的内容,都曾经是你据理力争保留的;而草稿自身的篇幅看起来还会成为“它确有必要”的证据。
Two budgets
两种预算
Everything you add spends one of two things:
- Context load — always-loaded material, paid every turn whether or not it fires. A skill's description, a rule in an , anything resident.
AGENTS.md - Cognitive load — what a person has to hold: which documents exist, and when to reach for each. Not a cost to drive to zero — it is what buys human judgement. Spend it where judgement matters.
Material behind a pointer escapes context load for the price of the pointer's own line. Material with no pointer rides entirely on a person remembering it.
你添加的每一样东西都会消耗以下两种资源之一:
- 上下文负载——始终被加载的材料,无论是否实际发挥作用,每一轮都要付出成本,例如 skill 的 description、中的一条规则,或任何常驻内容。
AGENTS.md - 认知负载——人必须记住的信息:有哪些文档,以及何时该取用哪一份。这不是要压到零的成本;它正是让人能够作出判断的代价。把它花在判断真正重要的地方。
放在指针背后的材料,只需付出指针本身一行的代价,就能摆脱上下文负载。没有任何指针的材料,则完全依赖人们记得它。
Where a line sits
一行内容的位置
Three rungs, ordered by how immediately the run needs the material: steps it performs in order, reference it consults on demand, and disclosed reference in a separate file reached by a pointer. Moving material down keeps the top legible; moving too much down hides what the run actually needs. Branching decides it — inline what every path needs, disclose what only some paths reach.
Keep a rule's statement, its bounds, and its exceptions together under one heading, so reading one brings the others. A rule split across a document is one rule that can drift into two.
A pointer is the line naming out-of-context material and the condition for reaching it: a skill description, a reference link. Its wording, not its target, decides whether the run gets there — so lead with the word that triggers it, give one trigger per distinct case, and cut what the target already says about itself. If material must be reached and the pointer is weak, sharpen the wording before inlining the material.
这些层级按运行需要材料的即时程度排序,共有三级:依次执行的 steps、按需查阅的 reference,以及通过指针访问、独立文件中的 disclosed reference。将材料下移能让顶层保持清晰;下移过多则会隐藏运行真正需要的内容。由分支情况决定:每条路径都需要的内容内联,只有部分路径会访问的内容则另行披露。
将规则的陈述、适用边界和例外放在同一个标题下,这样读到其中一项时也会看到其他项。分散在文档各处的同一条规则可能逐渐分裂成两条不同规则。
指针是指明上下文外材料及其取用条件的一行,例如 skill 的 description 或 reference 链接。决定运行能否找到它的,是指针的措辞而非目标本身,因此应以触发词开头,每种不同情况只设置一个触发条件,并删去目标已经自我说明的内容。如果某项材料必须被访问,而指针过于薄弱,应先强化指针的措辞,再考虑把材料内联。
Wording
措辞
Reach for a word the model already holds. A pretrained word — relentless, tight, adversarial — recruits priors and anchors a region of behaviour in one token, where a phrase spends several and lands weaker. When a directive is too weak, the fix is a stronger word rather than more words. A coined term recruits nothing, so you pay in definition what a real word gives free.
The same activation scales from a word to a discipline. A pretrained concept — adversarial verification, rival explanations, goal-based — activates everything the model already holds about practising it, so a firm goal plus a few such concepts can stand in for pages of process the model would re-derive anyway. Prefer that shape for a whole prompt: state the goal and the rulings that bind, name each discipline by the words that recruit it, and leave the manoeuvring to the model. The backbone stays firm because the goal and rulings bind — not because every step is written down; spelled-out process constrains a capable model to one path where the latent discipline covers them all.
State the target, not the ban. A prohibition names the behaviour it forbids and thereby makes it available — the negation is a weak modifier on a strongly activated concept. Write one-line comments beats don't write long comments. Keep a prohibition only as a guardrail that cannot be phrased positively, and pair it with the positive target.
End every step on a condition the run can check. Understanding reached invites stopping early, because the steps still visible ahead pull attention toward being done. Sharpen the bound first; splitting the sequence only helps across a real context boundary, since an inline mention leaves the later steps in view. Wording also sets how much work the step demands: every caller enumerated forces the sweep that list the callers does not.
Give judgment calls a rule, not an absolute. Always ask before assuming over-fires; when the missing fact would change the action, ask — otherwise proceed and label the assumption can be applied. Reserve MUST and NEVER for real invariants.
Keep the arousal low. Urgency framing, all-caps imperatives and heavy praise measurably shift behaviour — toward corner-cutting under pressure, toward agreement under flattery. Normalize failure in anything iterative: if this approach doesn't work, try another. The opening sets the register for everything after it.
优先使用模型已经掌握的词。 预训练词——relentless、tight、adversarial——能够调用先验,并在一个 token 中锚定一类行为区域;短语则要耗费多个 token,落点也更弱。当指令力度不足时,更有效的做法是换用更强烈的词,而不是增加词数。自造术语无法激活任何先验,因此真实词语可以免费提供的效果,你得靠定义来补。
同样的激活效应可以从一个词扩展到一套方法。 预训练概念——adversarial verification、rival explanations、goal-based——会激活模型已经掌握的相关实践,因此,一个坚定的目标和少数此类概念,足以替代模型本来也会自行重新推导的多页流程。整套 prompt 应优先采用这种形态:陈述目标和具有约束力的裁定,用能够激活相应方法的词为每套方法命名,并把具体操作留给模型。骨架之所以稳固,是因为目标和裁定形成了约束,而不是因为每一步都写了出来;把流程完全展开,反而会把能力足够的模型限制在一条路径上,而潜在的方法体系本可覆盖所有这些步骤。
陈述目标,而不是禁令。 禁令会点明它所禁止的行为,从而让这一行为变得可用;否定词只是一个附着在强激活概念上的弱修饰符。写一行注释优于不要写长注释。只有当护栏无法改写为正向表述时才保留禁令,并应与正向目标配对。
让每个步骤都以运行可以检查的条件结束。 已达成理解会诱使模型提前停止,因为前方仍可见的步骤会把注意力拉向结束。先收紧边界;只有在跨越真实的上下文边界时,拆分步骤序列才有帮助,因为仅仅内联提及一句仍会让后续步骤留在视野中。措辞还决定步骤需要投入多少工作:枚举每一个调用方会强制进行全面排查,而列出调用方不会。
为需要判断的情况制定规则,而不是绝对要求。 假设前始终询问会过度触发;当缺失事实会改变行动时询问,否则继续并标注假设则可以实际应用。只把 MUST 和 NEVER 留给真正的不变量。
保持情绪张力低。 强调紧迫性的表述、全大写命令和过度赞美都会显著改变行为——在压力下走向抄近路,在奉承下走向附和。对于任何迭代过程,都要让失败成为常态:如果这种方法不起作用,就换一种。开篇为之后的一切定下基调。
Pruning
删减
- One meaning, one place. The same rule in two files is two texts that drift, and only one of them will be read. (Repeating a word on purpose is the opposite move and is fine.)
- The environment is a source of truth. A prompt restating what , a config file, or
package.jsonalready answers is a cache that goes stale. Cache only what no file confesses: the unwritten convention, the reason, the gotcha.--help - Check every line for relevance, not just correctness — a line can be true and no longer bear on what the document does. Left unchecked, a prompt accretes layers nobody dares remove.
- Hunt no-ops sentence by sentence. An instruction the model already follows pays load to say nothing. Delete the whole sentence rather than trimming its words.
- 同一个含义只保留在一处。 同一条规则出现在两个文件中,就是两份会逐渐分化的文本,而且最终只会被读到其中一份。(有意重复某个 词 恰恰相反,而且完全没有问题。)
- 环境是事实来源。 prompt 重复 、配置文件或
package.json已经说明的内容,就是一个会过时的缓存。只缓存文件不会自述的内容:不成文的惯例、原因,以及容易踩的坑。--help - 检查每一行是否相关,而不只是是否正确。 一行内容可以仍然属实,却已与文档实际承担的作用无关。若不检查,prompt 会不断堆积无人敢删除的层次。
- 逐句排查 no-op。 模型本来已经遵循的指令,只是在消耗负载,却什么也没有带来。整句删除,不要只修剪其中的词。
Edges
边界情况
A line can earn its place and still break where the prompt actually runs. Check each against the conditions it will meet:
- Naming a harness-bound primitive — a specific tool, scheduler, or CLI — where the capability should be stated in plain language and the model left to find it.
- A qualifier that quietly excludes cases the principle covers (under mode X, by another reviewer).
- A mechanism stated as the only path — a fixed sequence, a hardcoded number — where the principle should stand and the number be a default.
一行内容即使有理由保留,也仍可能在 prompt 的实际运行环境中失效。逐行对照它将遇到的条件,检查:
- 点名与运行框架(harness)绑定的 primitive——某个具体工具、scheduler 或 CLI——而这里本应以朴素语言陈述能力,让模型自行找到它。
- 限定词悄悄排除了原则本应涵盖的情形(在模式 X 下、由另一位审查者执行)。
- 把某种机制写成唯一路径——固定顺序、硬编码数字——而本应保留原则,并让数字仅作为默认值。
Updating
更新
When the change follows a bad result, start with What the run has in front of it, and change the prompt's lines only for what the input does not explain. Find the gap a line closes before changing anything near it. The best patch usually replaces a line rather than adding one beside it, and a new explicit rule often retires an older vague hedge. Net change can be positive or negative; the target is balance, not direction.
The updated prompt reads as if written today for what it now does. What a line used to say, when or why it changed, and who asked for it go in the commit message or a decision record, outside the prompt's file: in the prompt they cost load on every run and can be followed as instructions. Why a rule holds can stay. Keep the ruling, not the note that it was ruled.
After the edit, reread the whole file as a newcomer would, not only the lines you touched: each rule stated once; nothing that contradicts or repeats the new line; the opening still describing what the prompt does. Remove history notes and the hedges a new rule retires wherever they sit: removing them changes no rule, so it is not a choice left to the requester.
Guard against building a wall around a single observed failure. One instance is a fix; a section is over-correction.
如果变更源于一次糟糕的结果,先从运行实际接收到的内容开始,并且只针对输入无法解释的问题修改 prompt 各行。先找出某一行所弥补的缺口,再改动它附近的内容。最佳补丁通常是替换一行,而不是在旁边新增一行;新的明确规则往往会取代旧有含糊的限定。净变化可以为正,也可以为负;目标是取得平衡,而非某个方向。
更新后的 prompt 应该读起来就像今天为它如今的行为所写。某一行过去说了什么、何时或为何改变,以及是谁提出变更,都应放进 commit message 或决策记录,而不是放在 prompt 文件中:在 prompt 里,它们每次运行都会产生负载,还可能被当作指令遵循。规则为何成立的理由可以保留。保留裁定,不要保留对裁定过程的备注。
编辑后,以新来者的视角重读整个文件,而不只是改动过的行:每条规则只陈述一次;没有任何内容与新行矛盾或重复;开头仍准确描述 prompt 的作用。无论历史说明和新规则所取代的模糊限定位于何处,都将其删除:删除它们不会改变任何规则,因此这不属于应留给请求者的选择。
防止围绕单次观察到的失败筑起一堵墙。一个实例可以作为修复依据;一整节内容则是过度纠偏。
References
参考资料
- — the shapes: a skill's frontmatter, naming and layout; an agent's isolation and capability declarations; a knowledge skill whose gap is data rather than behaviour.
references/mechanics.md - — a system prompt that ships in a deployment loop, and the ready-made blocks for one: verification passes, tool-call budgets, ambiguity handling, output contracts, high-risk self-checks. For that artifact only.
references/system-prompts.md - — diagnosing a failing prompt against logged traces.
references/metaprompting.md
- ——各种结构形态:skill 的 frontmatter、命名和布局;agent 的隔离方式与能力声明;缺口源于数据而非行为的知识型 skill。
references/mechanics.md - ——随部署循环交付的 system prompt,以及可用于组装它的现成模块:验证轮次、tool-call 预算、歧义处理、输出契约和高风险自检。仅适用于该制品。
references/system-prompts.md - ——依据已记录的 trace 诊断失败的 prompt。
references/metaprompting.md