🪢 Langfuse 图解教程Langfuse Visual Guide 第七部分 · Prompt 与 PlaygroundPart 7 · Prompts & Playground 37 / 55
第七部分 · Prompt 与 PlaygroundPart 7 · Prompts & Playground

Prompt 管理Prompt management

🧭 读前Before you start
先读 第9课 的元数据 schema,本课讲 prompt 如何版本化管理。
Read Lesson 9 on the metadata schema; this lesson covers how prompts are versioned and managed.

上一部分反复在「考」一个东西——prompt。它是你和模型对话的「脚本」,是 LLM 应用里改动最频繁的部分:一个词的措辞、一句指令的增删,都可能让效果天差地别。这一课讲 Langfuse 怎么像 git 管代码一样管 prompt:不可变的版本、可移动的 label、每次改动的 commit message,外加让一个 prompt 引用另一个的依赖组合。 理解了这套「版本控制」模型,你就握住了「安全地改 prompt」的关键——能发布、能秒回滚、能精确复现任意历史版本,而这一切都不需要改一行应用代码。

📋 生活类比
prompt 管理几乎就是专为 prompt 定制的 git。每次你改 prompt 并保存,就生成一个新版本(像一次 commit,编号自增、内容永不再改),还能附一句改动说明(commitMessage)。 而「production」「staging」这些 label,就像 git 的分支 / 标签——它们是可移动的指针,每个指向某一个版本。把 production 指向 v5,就等于「发布」了 v5;发现不对,把它指回 v4,就是「秒回滚」——而你的应用代码一个字都不用动,因为它只认「给我 production 那版」,不认具体版本号。 你甚至能让一个 prompt 引用另一个(依赖),就像代码里 import 一个公共模块——公共的开场白写一次,处处复用。

不可变的版本 + 可移动的 label

一个 prompt 由 (name, version) 唯一确定(@@unique([projectId, name, version]))。新建一版时,version = 上一版 + 1——版本号自增、内容一旦写下永不再改。而 labels 是一个字符串数组,关键规则是:同一个 label 在一个 name 下只能指向一个版本。所以当你给新版打上 production 标签,系统会自动把这个标签从旧版上摘掉——label 就这样「移动」到了新版。

版本不可变(自增),label 可移动(唯一指针) 时间 / 版本 v1(旧) v2(旧) v3(最新) label: latest label: production 发布:把 production 移到 v3 应用代码只说「给我 production 那版」——发布 = 移 label 到 v3,回滚 = 移回 v2,代码一行不改
git 式版本控制:version 自增不可变(latestPrompt.version + 1);label 唯一、可移动——给新版打 production 会从旧版自动摘除该标签(removeLabelsFromPreviousPromptVersions)。新建版本默认带 latest 标签。源码:createPrompt.ts:88-181、constants.ts:1-2(PRODUCTION_LABEL/LATEST_PROMPT_LABEL)。
示例:一个 prompt 的版本历史 prompt · name=support-reply · type=text · 3 versions version labels commitMessage createdBy · createdAt v3 production latest 收紧退款措辞 alice · 2026-06-20 v2 staging 加一句共情开场 bob · 2026-06-12 v1 (无) 初版 alice · 2026-06-01 版本不可变递增(unique projectId+name+version);production / latest 是可移动指针,现都指向 v3
版本历史就是一段「prompt 的 git log」(字段取自 schema.prisma 的 Prompt:version/labels/commitMessage/createdBy;值为示例):每次保存生成一个不可变的新版本(@@unique([projectId,name,version])),最新在上。production、latest 不是版本号而是可移动的标签指针——发布=把 production 移到某版,回滚=移回去,应用代码只认标签。这张表正是上面「git 式模型」的真实数据形态。
web/src/features/prompts/server/actions/createPrompt.ts版本自增 + label 移动
// 找到当前最新版,新版号 = 它 + 1(首版为 1)——版本号自增、内容不可变
const latestPrompt = await prisma.prompt.findFirst({ where: {…name}, orderBy: [{ version: "desc" }] });
version: latestPrompt?.version ? latestPrompt.version + 1 : 1,

// 新建的 prompt 永远带上 'latest' 标签
const finalLabels = [...labels, LATEST_PROMPT_LABEL];   // "latest"

// 关键:label 在一个 name 下唯一 —— 给新版打的 label,要从旧版上摘掉
await removeLabelsFromPreviousPromptVersions({ …, labelsToRemove: finalLabels });
// 于是 production 这个指针「移动」到了新版,旧版不再带它
git 概念prompt 管理对应说明
commitversion不可变快照,编号自增,内容永不再改
commit messagecommitMessage每次改动的一句说明,留痕可追溯
branch / taglabels(production/latest…)可移动指针,每 name 下唯一,指向某版
仓库级标签tags跨所有版本一致(贴在 name 上,非某一版)
import 模块PromptDependency一个 prompt 引用另一个,组合复用

把这张对照表记在心里,prompt 管理就不再是新概念——它就是你已经熟悉的 git,只不过管的不是代码,而是「和模型对话的脚本」。

按 label 取:让「发布」和「写代码」彻底分家

这套 git 式模型最大的实用价值,藏在应用怎么取 prompt里。生产代码不该写死「给我 v5」——而该写「给我 production 那版」。于是「用哪一版」这个决定,从代码部署里被剥离出来,变成一次移动 label 的运营动作。发布和回滚因此快到秒级,且不经过任何代码改动、CI、上线流程。

按 label 取(生产推荐)

get("greeting", label="production"):应用永远只认 production 指针,谁指过去就用谁。换版本是运营在 UI 上移 label,应用无感。这是「配置与代码分离」的教科书。

按 version 取(钉死)

get("greeting", version=5):精确锁定第 5 版,永不漂移。适合需要绝对可复现的场景(如一次正式实验、一篇论文的复现)。

protected labels(防误操作)

PromptProtectedLabels 让你把 production 等关键 label 设为「受保护」——移动它需要更高权限,避免新人手滑把没测过的版本推上线。

「用哪版」从代码部署里剥离,变成移 label 的运营动作 应用代码(不变)get("greeting", label="production")只认指针,不认版本号 production 指针运营在 UI 上移动当前 → v5 v4(旧·可回滚目标)移回即秒回滚 v5(新·现役)production 现在指这 回滚
配置与代码分离:应用按 label="production" 取,指针指向哪版由运营在 UI 决定。发布 = 移 label 到 v5;回滚 = 移回 v4——秒级、零代码、零部署。关键 label 可用 PromptProtectedLabels 加权限门槛。

依赖:让一个 prompt 引用另一个

prompt 多了会有重复——同一段「你是一个友好的客服助手……」开场白,可能出现在十个 prompt 里。改一次得改十处,极易漏。PromptDependency 解决这个:一个 prompt(parent)可以引用另一个 prompt(child),引用时既能按版本钉死(childVersion),也能按 label 浮动(childLabel)。这就像代码里 import 一个公共模块——公共片段写一次,处处复用。

prompt 组合:公共片段写一次,处处引用 父 prompt:客服-退款引用「系统开场白」+ 自己的退款逻辑 父 prompt:客服-投诉也引用「系统开场白」+ 自己的投诉逻辑 子 prompt:系统开场白「你是友好的客服助手…」写一次,被多处引用 childLabel=production(浮动) childVersion=3(钉死) 跟 label:子 prompt 升级,父自动获得新开场白 · 钉版本:父永远用第3版开场白,不受子升级影响
组合即复用:schema.prisma:864 的 PromptDependency 用 parentId + childName + childLabel(浮动)或 childVersion(钉死)描述引用。浮动让公共片段一改处处更新,钉定让父 prompt 不受子升级影响——和第一节的 label/version 取舍如出一辙。
packages/shared/prisma/schema.prisma:864 · createPrompt.ts依赖:浮动 or 钉死
model PromptDependency {
  parentId  String   // 引用方(父 prompt)
  childName String   // 被引用的 prompt 名
  childLabel   String?  // 二选一:按 label 浮动(如 "production"),子升级父自动跟
  childVersion Int?     // 或:按 version 钉死(如 3),父永远用这版,不漂移
}
// 创建时按 dep.type 决定钉哪种(createPrompt.ts)
...(dep.type === "version" ? { childVersion: dep.version } : { childLabel: dep.label })

把这套机制串起来,「安全地改 prompt」就成了一条清晰的流水线——这也正好衔接后两课的 Playground(第39课)与整个 Part 6 的实验:

1

编辑 → 存为新版

改完保存即生成新 version(自增、带 commitMessage),旧版原封不动留存。

2

在 Playground 试

新版先在 Playground(第39课)手动试几条,或拉进数据集跑实验(第36课)量化对比。

3

满意 → 移 production label

确认更好,把 production 指针移到新版——线上应用下一次取 prompt 即生效,零部署。

4

出问题 → 秒回滚

万一线上表现不对,把 production 移回旧版即可——旧版一直在,回滚不丢数据、不等发布。

🎯 设计取舍
为什么版本要不可变、而 label 要可移动? 这套「不可变实体 + 可移动指针」是版本控制的精髓,git 如此、第 34 课的数据项版本如此、这里的 prompt 亦如此。不可变保证了「可复现」:v5 永远是 v5,你三个月前生产用的那版,今天一字不差地还能调出来复盘。可移动的 label则提供了「可演进」:现实需要一个稳定的名字(production)来指代「当前现役」,而现役会变。两者结合,你既能大胆迭代(每改一版都安全留存),又能安心运营(用 label 平滑切换、随时回滚)。把不可变与可变这对矛盾,干净地分配到「版本」和「label」两个概念上——这是数据建模的优雅。

为什么「按 label 取」是生产解耦的关键? 因为它把「用哪一版 prompt」这个决定,从代码里彻底搬走了。如果应用写死 version=5,那换 prompt 就得改代码、过 CI、重新部署——慢、重、还得工程师在场。而写 label="production",换版本就变成运营在 UI 上点一下移个指针:秒级生效、可回滚、非工程师也能做。这正是「配置与代码分离」的威力——把变化频繁的东西(prompt 内容)从变化缓慢的东西(应用代码)里剥离,各自用最适合的节奏演进。PromptProtectedLabels 再给关键 label 加一道权限门,让「秒级发布」既灵活又不失控。
🎯 本课要点
  • prompt = 专为 prompt 定制的 git:(name, version) 唯一;版本号自增、内容不可变,附 commitMessage——每次改动都安全留存、可精确复现。
  • label 是可移动指针:production/latest 等 label 在一个 name 下唯一,指向某一版;给新版打 label 会自动从旧版摘除(removeLabelsFromPreviousPromptVersions)——移 label = 发布 / 回滚。
  • 按 label 取 = 配置与代码分离:生产写 get(label="production"),换版本只需运营移指针——秒级、零代码、零部署、可回滚;按 version 取则用于绝对复现。
  • protected labels 防误操作:PromptProtectedLabels 给 production 等关键 label 加权限门槛,避免误把未测版本推上线。
  • 依赖 = prompt 组合复用:PromptDependency 让父 prompt 引用子 prompt,按 childLabel 浮动或 childVersion 钉死——公共片段写一次处处用,取舍逻辑和 label/version 一脉相承。

🧪 自测 · 想一想为什么这么设计

1. Langfuse 把 prompt 的 version 设计成不可变(自增、内容不再改),而 label(如 production)设计成可移动指针。这种「不可变实体 + 可移动指针」组合的核心好处是?
  1. 加密 prompt 内容
  2. 让 prompt 自动优化
  3. 节省数据库空间
  4. 同时获得「可复现」与「可演进」:不可变版本让任意历史版精确复盘,可移动 label 让 production 这个稳定名字平滑切换/回滚——把矛盾干净分配到两个概念上
看答案与解析 点击展开
答案:D。这是版本控制的精髓,git、第34课数据项、prompt 皆然。不可变保证可复现:v5 永远是 v5,三个月前生产那版今天一字不差可复盘。可移动 label 提供可演进:现实需要 production 这个稳定名字指代「当前现役」,而现役会变。两者结合既能大胆迭代(每版安全留存)又能安心运营(label 平滑切换/秒回滚)。
2. Langfuse 推荐生产代码用 get(label="production") 而不是 get(version=5) 来取 prompt。这么做最大的运营价值是?
  1. 按 label 取更快
  2. 把「用哪一版」从代码里搬走:换版本变成运营在 UI 移指针——秒级生效、可回滚、非工程师也能做,无需改代码/过CI/重新部署(配置与代码分离)
  3. 按 label 取更省 token
  4. version 取不到旧版
看答案与解析 点击展开
答案:B。若应用写死 version=5,换 prompt 就得改代码、过 CI、重新部署——慢重且要工程师在场。写 label="production",换版本就是运营在 UI 点一下移指针:秒级、可回滚、非工程师可做。这把变化频繁的东西(prompt 内容)从变化缓慢的东西(应用代码)里剥离,各自用最适合的节奏演进。protected labels 再给关键 label 加权限门。
3. PromptDependency 让一个父 prompt 引用子 prompt,可以按 childLabel(如 production)浮动,也可以按 childVersion(如 3)钉死。这两种引用方式分别适合什么?
  1. 钉死会自动升级
  2. 浮动(label):子 prompt 升级时父自动获得更新,适合「公共片段一改处处生效」;钉死(version):父永远用那一版、不受子升级影响,适合需要稳定的场景——和按 label/version 取 prompt 同一种取舍
  3. 两者完全等价
  4. 浮动更安全,钉死有风险
看答案与解析 点击展开
答案:B。PromptDependency 用 childLabel 或 childVersion 二选一描述引用。浮动(childLabel):跟着 label 走,子升级父自动获得新内容——适合公共开场白这种「改一次处处更新」。钉死(childVersion):锁定具体版本,父不受子升级影响——适合要绝对稳定/可复现。这和第一节「按 label 取 vs 按 version 取」是同一种「浮动求便利、钉定求稳定」的取舍,一脉相承。
💭 发散思考(没有标准答案,动手或动脑想想)
  • prompt 管理把「软件版本控制」的思想(不可变版本、可移动 label、依赖、commit message)整套搬到了 prompt 上。回想你用 git 的经验:哪些 git 工作流(如分支策略、code review、回滚演练)你觉得也值得搬到 prompt 管理上?反过来,prompt 和代码有什么本质不同,使得某些 git 实践未必适用?

The previous part kept "examining" one thing—the prompt. It's the "script" of your conversation with the model, the most frequently changed part of an LLM app: rewording one word, adding or removing one instruction, can swing the outcome wildly. This lesson is about how Langfuse manages prompts like git manages code: immutable versions, movable labels, a commit message per change, plus dependency composition that lets one prompt reference another. Grasp this "version control" model and you hold the key to "changing prompts safely"—you can release, roll back instantly, and reproduce any historical version exactly, all without touching a line of application code.

📋 Analogy
Prompt management is almost git tailored for prompts. Each time you edit a prompt and save, it creates a new version (like a commit—an auto-incrementing number, content never changed again), with an optional change note (commitMessage). And labels like "production" / "staging" are like git's branches / tags—they're movable pointers, each pointing to one version. Point production at v5 and you've "released" v5; if something's wrong, point it back at v4 for an "instant rollback"—and your application code doesn't change one character, because it asks for "the production one", not a specific version number. You can even have one prompt reference another (a dependency), like import-ing a shared module in code—write the shared preamble once, reuse it everywhere.

Immutable versions + movable labels

A prompt is uniquely identified by (name, version) (@@unique([projectId, name, version])). On creating a version, version = previous + 1—the number auto-increments, and once written the content is never changed again. labels is a string array, with the key rule: a given label can point to only one version under a name. So when you tag a new version with production, the system automatically strips that label from the old version—the label thus "moves" to the new one.

versions immutable (auto-increment), labels movable (unique pointers) time / version v1 (old) v2 (old) v3 (latest) label: latest label: production release: move production to v3 app code just says "give me the production one"—release = move the label to v3, rollback = move it back to v2, no code change
git-style version control: version auto-increments and is immutable (latestPrompt.version + 1); a label is unique and movable—tagging a new version with production auto-strips it from the old one (removeLabelsFromPreviousPromptVersions). A new version always gets the latest label. Source: createPrompt.ts:88-181, constants.ts:1-2 (PRODUCTION_LABEL/LATEST_PROMPT_LABEL).
Example: a prompt's version history prompt · name=support-reply · type=text · 3 versions version labels commitMessage createdBy · createdAt v3 production latest tighten refund wording alice · 2026-06-20 v2 staging add an empathy line bob · 2026-06-12 v1 (none) initial version alice · 2026-06-01 versions are immutable & incrementing (unique projectId+name+version); production / latest are movable pointers, both on v3 now
The version history is a "git log for your prompt" (fields from the Prompt model in schema.prisma: version/labels/commitMessage/createdBy; values illustrative): each save creates a new immutable version (@@unique([projectId,name,version])), newest on top. production and latest are not version numbers but movable label pointers — a release moves production onto a version, a rollback moves it back, and app code only knows the label. This table is the concrete data form of the git-style model above.
web/src/features/prompts/server/actions/createPrompt.tsversion increment + label move
// find the current latest version; new = it + 1 (first is 1)—number auto-increments, content immutable
const latestPrompt = await prisma.prompt.findFirst({ where: {…name}, orderBy: [{ version: "desc" }] });
version: latestPrompt?.version ? latestPrompt.version + 1 : 1,

// a newly created prompt always gets the 'latest' label
const finalLabels = [...labels, LATEST_PROMPT_LABEL];   // "latest"

// key: a label is unique per name — labels put on the new version must be stripped from old ones
await removeLabelsFromPreviousPromptVersions({ …, labelsToRemove: finalLabels });
// so the production pointer "moves" to the new version; old versions no longer carry it
git conceptprompt management counterpartnote
commitversionimmutable snapshot, auto-incrementing number, content never changed
commit messagecommitMessagea note per change, leaving a traceable trail
branch / taglabels (production/latest…)movable pointers, unique per name, pointing to a version
repo-level labelstagsconsistent across all versions (on the name, not a version)
import a modulePromptDependencyone prompt references another, composition reuse

Keep this mapping in mind and prompt management is no longer a new concept—it's the git you already know, just managing not code but "the script of your conversation with the model".

Fetch by label: fully divorce "releasing" from "writing code"

This git-style model's biggest practical value hides in how the app fetches a prompt. Production code shouldn't hardcode "give me v5"—it should say "give me the production one". So the decision of "which version to use" is lifted out of code deployment into a label-moving operations action. Releases and rollbacks thus become second-scale, and bypass any code change, CI, or deploy flow.

fetch by label (production-preferred)

get("greeting", label="production"): the app only ever knows the production pointer, using whatever it points to. Switching versions is operations moving a label in the UI, with the app oblivious. A textbook of "config-code separation".

fetch by version (pinned)

get("greeting", version=5): locks exactly to version 5, never drifting. Suits absolute-reproducibility scenarios (a formal experiment, reproducing a paper).

protected labels (against fat-fingering)

PromptProtectedLabels lets you mark key labels like production as "protected"—moving it needs higher permission, preventing a newcomer from accidentally shipping an untested version.

"which version" lifted out of code deploy into a label-move ops action app code (unchanged)get("greeting", label="production")knows the pointer, not the version production pointeroperations moves it in the UIcurrently → v5 v4 (old · rollback target)move back = instant rollback v5 (new · active)production points here now rollback
config-code separation: the app fetches by label="production", with which version the pointer targets decided by operations in the UI. Release = move the label to v5; rollback = move it back to v4—second-scale, zero-code, zero-deploy. Key labels can be gated via PromptProtectedLabels.

Dependencies: let one prompt reference another

With many prompts comes duplication—the same "You are a friendly support assistant…" preamble might appear in ten prompts. Editing it once means editing ten places, easy to miss. PromptDependency solves this: a prompt (parent) can reference another prompt (child), either pinned by version (childVersion) or floating by label (childLabel). It's like import-ing a shared module in code—write the shared snippet once, reuse it everywhere.

prompt composition: write the shared snippet once, reference everywhere parent: support-refundreferences "system preamble"+ its own refund logic parent: support-complaintalso references "system preamble"+ its own complaint logic child: system preamble"You are a friendly support assistant…"written once, referenced by many childLabel=production (floating) childVersion=3 (pinned) follow a label: child upgrades, parent auto-gets new preamble · pin a version: parent always uses preamble v3, unaffected by upgrades
composition is reuse: schema.prisma:864's PromptDependency uses parentId + childName + childLabel (floating) or childVersion (pinned). Floating makes a shared snippet update everywhere on one edit; pinning shields a parent from a child upgrade—mirroring the first section's label/version trade-off.
packages/shared/prisma/schema.prisma:864 · createPrompt.tsdependency: floating or pinned
model PromptDependency {
  parentId  String   // the referrer (parent prompt)
  childName String   // the referenced prompt's name
  childLabel   String?  // one of: float by label (e.g. "production"), parent follows child upgrades
  childVersion Int?     // or: pin by version (e.g. 3), parent always uses this, no drift
}
// on create, dep.type decides which to pin (createPrompt.ts)
...(dep.type === "version" ? { childVersion: dep.version } : { childLabel: dep.label })

String this mechanism together and "changing a prompt safely" becomes a clear pipeline—dovetailing with the next lessons' Playground (L39) and all of Part 6's experiments:

1

edit → save as a new version

Saving an edit creates a new version (auto-incrementing, with a commitMessage); the old version is preserved intact.

2

try in the Playground

Try the new version on a few cases in the Playground (L39), or pull it into a dataset to run an experiment (L36) for a quantitative comparison.

3

satisfied → move the production label

Confirmed better, move the production pointer to the new version—the production app's next prompt fetch picks it up, zero-deploy.

4

trouble → instant rollback

If production misbehaves, move production back to the old version—the old one is always there, rollback loses no data and waits for no release.

🎯 Design trade-off
Why are versions immutable while labels are movable? This "immutable entity + movable pointer" is the essence of version control—git is so, Lesson 34's dataset items are so, prompts here too. Immutability guarantees "reproducibility": v5 is forever v5, and the version you ran in production three months ago can be pulled up today, word for word, for a post-mortem. Movable labels provide "evolvability": reality needs a stable name (production) to denote "the current active one", and the active one changes. Together, you can both iterate boldly (every edit safely preserved) and operate calmly (switch smoothly via labels, roll back anytime). Cleanly assigning the immutable/mutable tension onto the two concepts "version" and "label" is the elegance of data modeling.

Why is "fetch by label" the key to production decoupling? Because it fully moves the decision "which prompt version to use" out of the code. If the app hardcodes version=5, switching prompts means changing code, passing CI, redeploying—slow, heavy, and needs an engineer present. With label="production", switching becomes operations clicking a pointer-move in the UI: second-scale, rollback-able, doable by non-engineers. This is the power of "config-code separation"—lifting the frequently-changing thing (prompt content) out of the slowly-changing thing (app code), each evolving at its own pace. PromptProtectedLabels then gates key labels, keeping "second-scale releases" flexible without losing control.
🎯 Key points
  • A prompt = git tailored for prompts: (name, version) unique; the version number auto-increments, content immutable, with a commitMessage—every edit safely preserved and exactly reproducible.
  • A label is a movable pointer: production/latest labels are unique per name, pointing to one version; tagging a new version auto-strips the label from the old one (removeLabelsFromPreviousPromptVersions)—moving a label = release / rollback.
  • Fetch by label = config-code separation: production does get(label="production"), switching versions just needs operations moving a pointer—second-scale, zero-code, zero-deploy, rollback-able; fetch by version is for absolute reproducibility.
  • Protected labels against fat-fingering: PromptProtectedLabels gates key labels like production with permissions, preventing an untested version from being shipped by accident.
  • Dependencies = prompt composition reuse: PromptDependency lets a parent reference a child by childLabel (floating) or childVersion (pinned)—write a shared snippet once, reuse everywhere, with trade-off logic mirroring label/version.

🧪 Self-test - think about the design

1. Langfuse designs a prompt's version as immutable (auto-incrementing, content never changed) and a label (like production) as a movable pointer. The core benefit of this 'immutable entity + movable pointer' combo is?
  1. encrypting prompt content
  2. auto-optimizing prompts
  3. saving database space
  4. getting both 'reproducibility' and 'evolvability': immutable versions let any historical version be replayed exactly, movable labels let a stable name like production switch/roll back smoothly—cleanly assigning the tension to two concepts
Show answer & explanation click to expand
Answer: D. This is the essence of version control—git, Lesson 34's items, prompts alike. Immutability guarantees reproducibility: v5 is forever v5, the version in production three months ago is replayable word-for-word today. Movable labels provide evolvability: reality needs a stable name like production for 'the current active', which changes. Together you iterate boldly (each version preserved) and operate calmly (smooth switch/instant rollback via labels).
2. Langfuse recommends production code fetch a prompt via get(label="production") rather than get(version=5). The biggest operational value of this is?
  1. fetching by label is faster
  2. lifting 'which version' out of code: switching versions becomes operations moving a pointer in the UI—second-scale, rollback-able, doable by non-engineers, no code change/CI/redeploy (config-code separation)
  3. fetching by label saves tokens
  4. fetching by version can't get old versions
Show answer & explanation click to expand
Answer: B. If the app hardcodes version=5, switching means changing code, passing CI, redeploying—slow, heavy, needs an engineer. With label="production", switching is operations clicking a pointer-move in the UI: second-scale, rollback-able, non-engineer-doable. This lifts the frequently-changing thing (prompt content) out of the slowly-changing thing (app code), each evolving at its own pace. Protected labels then gate key labels.
3. PromptDependency lets a parent prompt reference a child, either floating by childLabel (e.g. production) or pinned by childVersion (e.g. 3). What does each reference style suit?
  1. pinning auto-upgrades
  2. floating (label): the parent auto-gets updates when the child upgrades, suiting 'edit the shared snippet once, effective everywhere'; pinned (version): the parent always uses that version, unaffected by child upgrades, suiting stability—the same trade-off as fetching prompts by label/version
  3. the two are equivalent
  4. floating is safer, pinning is risky
Show answer & explanation click to expand
Answer: B. PromptDependency describes a reference by either childLabel or childVersion. Floating (childLabel): follows the label, the parent auto-gets new content on child upgrade—suiting a shared preamble's 'edit once, update everywhere'. Pinned (childVersion): locks a specific version, the parent unaffected by upgrades—suiting absolute stability/reproducibility. This mirrors the first section's 'fetch by label vs version': float for convenience, pin for stability.
💭 Open questions (no single right answer - just think or try)
  • Prompt management ports the whole idea of 'software version control' (immutable versions, movable labels, dependencies, commit messages) onto prompts. Recall your git experience: which git workflows (branch strategy, code review, rollback drills) do you think are worth porting to prompt management? Conversely, how do prompts differ fundamentally from code, making some git practices not necessarily applicable?