Chapter 03 · Domain 2(本章 skill 权重合计 8.6%)
Claude 应用设计让同一条指令在五种界面上仍有明确边界
Claude Code、Desktop、claude.ai、API 与 SDKs 都能承接自然语言需求,但它们接收的上下文、可用工具、持久配置与状态责任并不相同。本章不做产品导览,而是训练一个 developer 判断:同一项业务意图进入不同界面时,应用 contract 应怎样改写。
一、先选执行边界,再写提示词
「让 Claude 检查退款工单并修复问题」不是一个可直接搬运到所有界面的 instruction。它至少混合了四件事:读取工单、读取代码、提出判断、改变生产或仓库状态。界面只决定交互入口;真正的应用设计要回答:
内容从哪里来: 用户粘贴、项目知识、工作区文件,还是应用检索?
动作在哪里执行: 模型只返回文本,还是调用由宿主暴露的工具?
状态由谁持有: 当前 chat、项目配置、仓库文件,还是应用数据库?
什么必须强制: schema 校验、权限、审批与副作用闸门由哪一层执行?
因此,跨界面迁移不是复制同一段 prompt,而是保持业务不变量,再重建该界面的 instruction source → content boundary → tool contract → state owner → validation 链。若先写 prompt、后补边界,最常见的结果就是把某个界面的隐式能力误当成所有界面的共同能力。
判断点 — 题干若把「能对话」等同于「能读本机文件、记住旧会话、执行工具」,先停下来逐项核对宿主实际提供了什么。
二、五种界面对照:同一句话进入了不同 contract
界面 instruction 与 content 从哪来 文件 / 工具边界 持久性与 developer 责任
Claude Code 当前请求加工作区约定;项目根目录 CLAUDE.md 会在每个会话开始时读取 面向代码工作区,可跨文件写代码并验证;实际动作仍受当前工具与授权边界约束 把仓库级稳定约定放进版本化配置,把本次目标与验收条件放进当前请求
Claude Desktop 当前对话,以及用户明确连接或提供的内容 不能因「桌面应用」就假定能读整台电脑;desktop extension 可在本机运行,其暴露能力才是边界 应用设计要列出 extension / connector 的来源、权限和可见数据,不能把本机存在等同于模型可见
claude.ai 当前 chat;Project instructions 只作用于该 project,跨 chat 的资料需显式加入 project knowledge 没有「浏览器自动拥有本机文件系统」这一默认前提;只按已上传内容和已配置能力设计 Project 适合稳定语境,单次 chat 适合本次任务;不要把另一个 chat 的细节当作当前上下文
API 应用组装顶层 system、messages、必要内容与顶层 tools API 没有应用主机的隐式文件权限;客户端工具由应用定义、授权并执行 Messages API 是 stateless;应用负责发送完整对话历史、存储业务状态、校验输出并处理失败
SDKs 应用通过目标语言的 client SDK 构造同一类 API request SDK 是调用层,不会凭空增加本机内容、工具权限或业务审批 应用仍逐次发送请求、处理响应,并拥有 session、重试、持久化与副作用责任
API 与 SDKs 容易被误画成两个能力层:前者像「底层」、后者像「自动 agent」。正确区分是,API 定义服务 contract,client SDK 提供语言侧调用接口;若要循环调用工具、保存状态或执行业务动作,仍须由应用明确实现。Claude Code、Desktop 与 claude.ai 则由各自宿主组装一部分上下文与能力,但 developer 仍不能越过可见边界做假设。
三、Content boundary:把「模型能看到什么」写成清单
系统里存在的数据,不等于本次推理可见的数据。一个可靠的 content boundary 至少包含五栏:
边界栏 要写清的问题 退款审查示例
允许来源 哪些文档、记录、文件或检索结果可以进入上下文? 当前 case、已批准的 policy 版本、脱敏订单摘要
排除来源 哪些内容即使宿主能访问,也不得送入模型? 其他客户工单、原始支付凭证、无关仓库 secret
选择规则 由谁检索、裁剪、排序与去重? 按 case ID 检索,限定 policy 生效日期,拒绝全库拼接
来源标识 输出如何回链到版本与记录? 保留 policy ID、revision、case ID 与检索时间
生命周期 内容只在本 turn、当前 session,还是跨 session 使用? case 详情只随本次任务;通用 policy 进入受控知识层
这张清单在不同界面落点不同:claude.ai Project 要区分单个 chat 与 project knowledge;API 应用要在每次 request 明确组装完整 conversation history 与本轮检索内容;Claude Code 要区分仓库内任务文件与机器上无关路径;Desktop 要以实际启用的 extension / connector 为准。共同原则是:显式提供才算上下文,授权可读也不代表应该读取。
边界不是 prompt 句子 — 「只看这个客户的数据」可以表达意图,但检索过滤、tenant scope、redaction 与审计应由应用可强制执行。自然语言不能替代数据访问控制。
四、Instruction source:稳定政策与本次任务分层
同一条规则放在不同位置,会得到不同的作用域与维护方式。设计时先按寿命分层,而不是把所有文字粘成一个超长 prompt:
层 适合放什么 不应承担什么
稳定行为政策 角色、输出原则、全局限制、升级条件 某一张 ticket 的临时数据
项目约定 仓库标准、Project instructions、领域词汇与长期知识 秘密凭证或自动跨项目继承的假设
本次任务 目标、输入、验收标准、允许修改的对象 持久权限与不可绕过的审批
工具 contract 工具做什么、何时用、参数 schema、错误与副作用 靠模型猜测隐藏参数或调用权限
在 Messages API 中,从开始就适用的 instruction 放在顶层 system 字段,不把它伪装成 messages 的第一条 system message;用户输入与后续对话属于 messages。在 Claude Code 中,仓库级约定可以落到根目录 CLAUDE.md,但本次 change 的范围、数据与完成条件仍要随当前请求说明。claude.ai 则要区分 Project instructions 与单个 chat 的任务内容。
分层的价值是可替换:业务政策变化时不必改 tool schema;换界面时可以保留同一组不变量,只把它们映射到新界面的 instruction source。若把审批、访问控制或金额上限只写进自然语言层,迁移时看似「提示词还在」,真正的控制却从未存在。
五、Schema design:把自由语言限制在合适的位置
在 API / SDK 应用中,tool definition 位于请求顶层 tools;input_schema 用 JSON Schema 描述预期参数,而 description 说明工具做什么、何时使用、如何表现。以只读工单查询为例:
{
"name": "get_refund_case",
"description": "Read one refund case after tenant authorization; never modify it.",
"input_schema": {
"type": "object",
"properties": {
"case_id": { "type": "string", "pattern": "^case-[0-9]+$" }
},
"required": ["case_id"],
"additionalProperties": false
}
}
一个好 schema 让合法形状窄而明确:required field、类型、枚举、格式与是否允许额外字段都有决定。description 补充 schema 难以表达的语义,例如「只读」「何时调用」「不存在时返回什么」。两者分工,不把可机器验证的约束全塞进 prose,也不指望 schema 说明全部业务语义。
但 schema 仍不是授权系统。Claude 返回结构化调用后,client tool 由应用执行;所以应用必须在执行点再次验证 tenant、actor、资源状态与审批证据。若工具会产生退款,较稳的 contract 是拆成 propose_refund 与受审批保护的 execute_refund,并让后者要求不可伪造的 approval token。模型选择哪个工具,不能替应用决定它是否有权成功。
三层校验 — schema 拒绝形状错误;业务校验拒绝非法状态;authorization 拒绝无权 actor。把三者都写成「请不要误用」属于用措辞冒充控制。
六、Session hygiene:延续是选择,不是默认事实
场景 已知 session 行为 设计动作
Claude Code /clear 开始一个新 session任务、仓库或信任边界变化时清理对话上下文;把必须长期成立的规则留在版本化项目配置
Messages API 服务端不替应用保存对话状态;每次 request 发送完整对话历史 应用保存 canonical history,为同一 conversation 的每次 request 组装并发送完整历史;新任务另起边界
claude.ai Project 普通 chat context 不自动跨 chat;加入 project knowledge 的信息才可跨 chat 使用 新任务开新 chat 时不要假定旧 chat 已知;只把真正稳定、允许复用的内容提升到知识层
Desktop / SDK 应用 不能从界面名称推断隐含状态 contract 明确记录 conversation ID、输入版本、工具结果与恢复策略;没有证据就按不延续设计
Session hygiene 的目标不是「上下文越少越好」,而是防止旧假设、旧权限与旧数据悄悄进入新任务。恢复一个 session 前应核对:目标是否仍相同、输入是否过期、工具权限是否变化、先前未完成动作是否可能重放。新 session 也不等于删除外部系统记录;对话边界、业务状态与审计保留是三件不同的事。
把长期真相外部化到可版本化、可审计的来源;
把本次选择过的上下文与来源版本记入 trace;
对具有副作用的 tool result 使用稳定 operation ID,恢复时先查状态再决定是否重试;
在 tenant、仓库、目标或 operator 改变时建立清晰的新边界。
七、Plugin 与 connector 管理:安装是供应链决定
Claude Code plugin 可以包含 skills、agents、hooks 与 MCP servers。它不是一段孤立提示词,而是可能同时改变 instruction、tool surface 与运行时行为的扩展包。因此管理对象至少要记录:来源、版本、包含组件、可访问资源、启用范围、owner、升级验证与撤销路径。
Marketplace 是发现渠道,不是自动授权渠道:把 marketplace 加入 Claude Code 只登记 catalog,尚未安装其中的 plugin。应用设计应保留这两个独立决策——先决定信任哪个 catalog,再逐个审查和安装所需 plugin。把「能浏览」误当「已安装」,或把「已安装」误当「可无条件执行」,都会把可见性、部署状态与权限混成一层。
Desktop extension 运行在本机,并只在 Claude Desktop 与 Claude Code 可用;这使它适合承接明确需要本机资源的能力,也意味着它的本地访问面必须被单独审查。跨界面方案不能写成「所有 Claude 界面都调用这个 desktop extension」;若同一业务还要支持 claude.ai 或 API,应另行设计可用的远程服务或 client tool contract,并保持相同授权规则。
管理门 最少证据 失败时动作
发现 catalog / package 来源与 owner 可追溯 来源不明则不进入安装评估
安装 组件清单、所需权限、版本锁定、适用界面 超出最小能力就缩权或拒绝
启用 隔离环境验证 tool schema、失败路径与副作用 验证不完整则保持禁用
升级 / 移除 change review、回归测试、撤销与残留状态检查 回退到已验证版本并复核凭证
八、迁移演练:保留不变量,重写界面适配
考虑一条跨界面需求:「读取退款工单与 policy,判断是否需要代码修复;任何资金动作都必须人工批准。」不变量是内容按 tenant 隔离、结论可追溯、代码变更可审查、资金执行有强制审批。五种界面的落法不同:
界面 合适的任务形态 必须补上的适配
Claude Code 在指定 repo 分析并形成可测试的 patch 用 CLAUDE.md 承载仓库约定;工单通过受限工具输入;资金工具不进入代码修改 task
Desktop 人工操作者审阅本机资料与建议 只启用完成任务所需的 extension / connector,列清其本地访问面;默认输出 proposal
claude.ai 在 project 语境中比较 policy 与已提供 case 稳定 policy 放 project knowledge;case 留在单个 chat;不假定可直接修改 repo 或执行退款
API 嵌入工单系统的可重复 workflow 应用组装 system/messages、检索内容与 tools;在执行点校验 tenant 与 approval token;保存业务状态
SDKs 用目标语言实现同一 API workflow 复用 API contract 与测试,不把 SDK convenience 当作 session、授权或 tool loop 已自动完成
做题时可以按四问裁决:需要宿主文件系统吗?需要可强制的工具动作吗?状态要跨请求或跨 chat 吗?稳定指令应由谁维护? 答案决定界面与适配层。若一个选项只是把原 prompt 原样复制到新界面,却没有重建内容、schema、session 与 plugin 边界,它通常只保留了文字,没有保留应用 contract。
考点回链 — 本章覆盖:TS 2.5(五种界面的 instruction source、content boundary、schema design、session hygiene 与 plugin management)。相邻考点:prompt/context 基础见
ch02 ;Claude Code 内部组件与运行模式见
ch15 ;工程 requirement 与 API contract 见
ch05 。
本章题组
QUESTION 01 · TS 2.5 · INTERFACE SELECTION
A developer must update twelve files in one repository, follow version-controlled project conventions, run the repository's tests, and return a reviewable diff. No separate application service is required. Which design best matches the task?
A Use Claude Code in the scoped repository, keep stable conventions in the root CLAUDE.md, and put this change's goal and acceptance checks in the current request.
B Use a claude.ai Project and upload the repository snapshot as Project knowledge so its browser chat can apply conventions, edit the local files, and run the tests.
C Open Claude Desktop with no extension or connector, describe the repository path in the prompt, and rely on the desktop application's location on the machine to grant access to every file and test process under that path.
D Send the instruction once through the Messages API without repository content or file tools, because the API can infer the local workspace from the path and persist the resulting edits until the developer requests a diff.
正确 A 题干要在一个真实 repo 中跨文件修改、遵守版本化约定并验证结果;Claude Code 的工作区形态直接承载这些约束。稳定项目规则与本次 change 分层,既保留复用,又让当前范围和验收证据明确。按 P1,所选界面逐项作用于文件、约定、测试和 diff 四条约束。
D5 错层承载 违反 P4 B :Project 可以承载项目语境,却不是题干本机 repo 的执行载体。snapshot 一旦上传就是静态副本,会与仓库后续提交脱节;把浏览器 chat 当成原工作区的文件与进程执行层,能力住错了地方。
D1 凭空捏造 违反 P5 C :Desktop 位于本机不等于自动获得任意文件和进程。已启用 extension / connector 暴露什么才有什么;选项凭界面名称捏造了默认权限,不能用熟悉的产品名替代机制职责核对。
D6 半对半错 违反 P1 D :API 可以构建这类应用,但选项故意拿掉了 repo content、file tools 与应用侧状态。它只选对了一个可编程入口,却没有满足读写文件、运行测试与保存 change 的核心约束。
QUESTION 02 · TS 2.5 · API SESSION STATE
A support application calls the Messages API. In turn one, a user supplies order o-481 and asks for a refund proposal. In turn two, the application sends only “Yes, proceed.” Claude cannot identify the order. What is the best fix?
A Add a system instruction saying, “Always remember every order mentioned in earlier API calls,” while continuing to send only the newest user message so the request remains small and inexpensive.
B Store canonical conversation and business state in the application, resend that thread's full conversation history, and validate the approval against the stored order before any action.
C Replace the direct HTTP call with a client SDK and keep the same one-message request, because the SDK automatically resumes the prior server-side session and restores tool results for the application.
D Attach the complete history of every support conversation and the full order database to each request, ensuring that whichever earlier fact Claude needs is always somewhere in context even when tenant and case boundaries differ.
正确 B Messages API 是 stateless,应用必须把本轮需要的对话历史送回请求;资金审批还应与 canonical business state 对表,而不是只从一句 “Yes” 猜目标。这个方案同时恢复语义连续性与可强制的执行边界。
D3 措辞冒充控制 违反 P3 A :system instruction 不能创造请求里不存在的历史,也不能证明 “proceed” 对应哪个订单。对资金动作来说,记忆请求更不能替代服务端订单与审批校验;文字没有补上状态机制。
D1 凭空捏造 违反 P5 C :client SDK 负责调用 API,不会凭空恢复一个服务端会话。选项把真实机制「SDK」安上了未登记的自动持久化职责,换调用库后缺失的 history 仍然缺失。
D7 过度工程 违反 P10 D :本轮只需当前 case 的必要历史,发送所有客户的对话与订单既浪费 context,又破坏 tenant boundary。已有更轻且有效的办法:按 conversation / case 精确取回所需状态。
QUESTION 03 · TS 2.5 · CONTENT BOUNDARY
A compliance team uses a claude.ai Project. The approved refund policy should be reusable across cases, but each customer's case data must remain isolated and access control is enforced by the case system. Which setup best preserves those boundaries?
A Upload the complete customer-ticket archive into Project knowledge so every new chat can search all prior cases, then ask reviewers to mention only the customer they are currently authorized to handle.
B Use one long chat for all customers to preserve the policy and prior reasoning, but begin each case with “forget all previous customer data” and rely on that instruction to prevent accidental cross-case disclosure.
C Place the approved policy and stable guidance in the Project's shared knowledge and instructions, open a separate chat with only the authorized case data for each customer, and keep access enforcement in the case system.
D Create a customer-specific repository and Claude Code environment for each case, copy the approved policy into that repository, and implement the compliance workflow as code within the dedicated workspace.
正确 C 稳定 policy 需要跨 chat 复用,适合受控的 Project knowledge / instructions;单个 case 只进入自己的 chat,而真正的 authorization 继续由 case system 强制。这个分层同时处理复用、隔离和失守代价,没有把 chat 边界误当权限系统。
D5 错层承载 违反 P4 A :全量 ticket archive 被放进所有 chat 共用的知识层,活的 case 数据住进了错误的持久载体。让 reviewer 只提当前客户不会收回已经进入共享语境的数据,也无法保持 tenant isolation。
D3 措辞冒充控制 违反 P3 B :“forget” 是自然语言请求,不是清除旧客户内容的确定性边界。题干明确涉及隐私隔离,失守代价高;继续共用一个 chat 再加一句禁止使用,仍无法强制。
D7 过度工程 违反 P10 D :题干只要求 policy 复用与 case 隔离,并没有代码工作区需求,也没证明独立 repo 是必要条件。先把知识层、chat 和外部 authorization 分开已经有效;逐客户造 repo 扩大了维护面。
QUESTION 04 · TS 2.5 · TOOL SCHEMA AND ENFORCEMENT
An API application exposes execute_refund. A refund may run only for the authenticated tenant and only after a human approval token is issued. Which tool design is safest?
A Describe the policy in the system prompt using “must never” and “only after approval,” then let the tool accept any JSON object and trust Claude to omit calls that would violate those instructions.
B Define a narrow JSON schema for case_id, amount, and approval_token, but execute every schema-valid call immediately because structural validation proves that the actor and tenant are authorized.
C Build a dedicated approval agent backed by a vector store of refund policy, and route executions through a new approval microservice that centralizes policy retrieval, decisioning, token issuance, and audit logs before the refund tool runs.
D Give the tool a precise description and closed JSON schema, then have the application verify tenant, case state, amount, and approval token at execution before performing an idempotent refund.
正确 D schema 先把参数形状收窄,description 说明用途;更关键的是 client tool 由应用执行,所以 tenant、case state 与 approval token 必须在副作用发生点重验。结构校验、业务校验、authorization 和幂等分别守住不同 failure mode。
D3 措辞冒充控制 违反 P3 A :高后果资金动作不能靠 “must never” 防守,开放 JSON 还扩大了歧义。prompt 只能表达请求;真正能拦住未授权退款的是执行层的 schema、权限与审批闸门。
D6 半对半错 违反 P3 B :收紧 schema 是对的,但 schema-valid 只证明字段形状,不证明 token 真实、tenant 匹配或 case 可退款。选项用半个正确机制掩盖了缺失的强制 authorization。
D7 过度工程 违反 P10 C :题干已有能签发 token 的 authorization service,缺口是把验证接到现有 tool 的执行点。尚未证明这种轻量修复失败,就新增 agent、vector store 与 service,只扩大攻击面和运维面。
QUESTION 05 · TS 2.5 · SESSION HYGIENE
A Claude Code session has spent an hour analyzing tenant Alpha's repository and logs. The developer now opens tenant Beta's repository for an unrelated incident with different rules and data. What should the developer do first?
A Run /clear to start a new session, confirm Beta's repository-level instructions, and provide only Beta's incident scope and required evidence.
B Continue the session to reuse its analysis, append Beta's logs after Alpha's, and ask Claude to retain only assumptions that still fit.
C Keep the session but type “forget Alpha completely and never use its data,” treating that sentence as sufficient proof that no old tenant context can influence the new incident.
D Uninstall every plugin, rebuild project configuration from a reviewed allowlist, and investigate tenant Beta from a freshly cloned repository on a dedicated workstation, using a clean-room setup to minimize inherited extension and host state.
正确 A tenant、repo、目标与证据边界同时改变,旧上下文的收益低于污染风险。/clear 明确开始新 session,再读取 Beta 的项目级约定并只注入本 incident 内容;长期规则与临时上下文也得到正确分层。
D2 无关杠杆 违反 P9 B :保存少量重述 token 并不是题干目标,真正约束是 tenant isolation 与旧假设污染。把两套日志继续堆在同一 context 中,既扩大预算,又让过期信息与当前事实竞争注意力。
D3 措辞冒充控制 违反 P3 C :“forget” 不会成为可验证的上下文清理动作。涉及另一 tenant 的日志与规则时,失守代价要求明确的新 session 与输入边界,而不是在旧 context 里追加一句愿望。
D7 过度工程 违反 P10 D :清晰的新 session 和正确 repo 配置已能建立所需边界;题干没有 plugin compromise 或机器污染证据。卸载全部扩展、删除配置和换电脑远超已知 failure mode。
QUESTION 06 · TS 2.5 · PLUGIN MANAGEMENT
A team adds a third-party marketplace to Claude Code to evaluate one plugin that bundles a skill, hook, and MCP server. A reviewer claims the whole catalog is now installed and available in claude.ai, Desktop, API, and SDK applications. What is the best response?
A Accept the claim because registering a marketplace automatically installs every catalog entry, enables every bundled component, and synchronizes those components to all Claude interfaces under the same user account.
B Treat marketplace registration and plugin installation as separate gates: inventory and review the selected plugin's components and permissions, install only what is needed, and design separate tool integration for surfaces that do not host that plugin.
C Rename the marketplace entry as a desktop extension and assume it will then run locally in Desktop, remotely in claude.ai, and inside every API or SDK request without additional deployment or tool definitions.
D Copy the skill, hook, and MCP server source text into a universal system prompt for every surface, because putting plugin components in context provides the same executable capability with fewer installation decisions.
正确 B 添加 marketplace 只登记 catalog,并未安装其中 plugin;即使选择安装,也要逐项审查包内 skill、hook 与 MCP server 的权限和副作用。不同 surface 的宿主能力不相同,跨界面复用要另建受控 tool integration,不能靠账户名推断传播。
D1 凭空捏造 违反 P5 A :选项给 marketplace registration 捏造了自动安装、自动启用与全界面同步三项职责。官方机制明确把登记 catalog 与安装 plugin 分成两步;名字是真的,行为是假的。
D1 凭空捏造 违反 P5 C :改名不会改变 package 类型或可用 surface。Desktop extension 的本地可用范围有明确边界,API / SDK 还需要应用定义 tools;选项把标签当成了部署机制。
D5 错层承载 违反 P4 D :skill instruction 的文字可以进入 context,但 hook 与 MCP server 的可执行能力不能靠粘贴源码获得。要维护、授权和调用的活能力应住在扩展或 tool 服务层,不在 system prompt 里假装运行。
QUESTION 07 · TS 2.5 · DESKTOP-TO-API MIGRATION
A Desktop prototype uses a local extension to read a developer's localhost case database. The workflow must now run as a multi-tenant API service. Which migration preserves the capability without carrying over the wrong boundary?
A Keep calling the developer's desktop extension from the hosted API, because a local extension remains reachable from web servers and all users once its name is included in the API system prompt.
B Serialize the entire localhost database into every request's system field, allowing the hosted model to reproduce the prototype's local access while avoiding any tenant-aware service or client tool.
C Expose a tenant-scoped client tool, send only selected case content per request, store workflow state in the application, and recheck authorization when executing the tool.
D Put a tenant ID in the system prompt and use one database credential, relying on the model to apply the tenant filter before each tool call.
正确 C 原型的业务能力是按 case 取数据,不变量是 tenant isolation;本地 extension 只是 Desktop 下的载体。迁移后由 hosted application 暴露 tenant-scoped client tool、组装必要内容、持有 state,并在执行点重验权限,能力与边界都被保留。
D1 凭空捏造 违反 P5 A :本地 extension 不会因名字进入 system prompt 就被 hosted API 远程调用。选项捏造了跨网络可达性,也没有部署任何受控数据服务。
D5 错层承载 违反 P4 B :活的多租户数据库不该作为静态 context 全量复制。它需要按请求、按 tenant 从受权工具读取;否则既浪费 context,也失去实时性、选择规则和数据访问边界。
D3 措辞冒充控制 违反 P3 D :模型被告知 tenant 规则,不等于数据库 credential 被收敛。单一无限制凭证使任一失误都能越界;高后果数据访问必须由 tool execution 的 tenant filter 与 authorization 拦住。
QUESTION 08 · TS 2.5 · SDK RESPONSIBILITY
A team rewrites a working Messages API client in another language using an official client SDK. The design document now says the SDK will remember conversation history, execute client tools, and enforce business authorization automatically. What correction should the reviewer request?
A Approve the document because all client SDKs include a persistent agent loop, shared conversation storage, and automatic execution for any tool whose JSON schema is accepted by the library.
B Add a Claude Code plugin marketplace to the service account so the SDK can inherit plugin sessions, hooks, and MCP tools without implementing application state or execution controls in the new language.
C Switch the application to a more capable model, which will compensate for missing conversation state and make authorization mistakes less likely even if the SDK executes every returned tool call.
D Keep the contract explicit: the application sends required history, executes authorized client tools, validates results, and owns business state; the SDK supplies the language-side API client.
正确 D client SDK 改善语言侧调用方式,不会接管应用 contract。Messages history、业务 state、client tool execution、authorization 与输出校验仍由应用负责。跨语言迁移应复用这些明确责任和测试,而不是把责任移交给库名。
D1 凭空捏造 违反 P5 A :选项给 client SDK 捏造了 persistent agent loop、共享存储和任意工具自动执行。官方职责是由应用发送请求、处理响应;机制名真实,不代表这些额外职责存在。
D5 错层承载 违反 P4 B :Claude Code plugin 与一个 hosted SDK service 的业务状态不是同一载体。添加 marketplace 既不会安装 plugin,更不会把 session、hook 或 tool 自动注入另一应用;跨应用能力需要正式接口。
D4 换模型当解法 违反 P1 C :题干缺口来自 state ownership 与 authorization,不是模型推理能力。换模型不会补回未发送的 history,也不会把无条件 tool execution 变成可强制的权限检查。