本页目录

📘 第 13 课:Building with AI Code Assistant(用 AI Code Assistant 构建)

官方课程名:Building with AI Code Assistant(Curriculum 第四段「Building with AI Code Assistant」唯一正课 · 正文收官课) 官方地址:https://anthropic.skilljar.com/claude-platform-101 归档路径:Claudeexams/20-课程/课程003 the AI Platform 101/ 针对认证:CCAR-P(架构师 Professional) 归档日期:2026-10-14 ⚠️ 语料来源:官方 Skilljar 课程正文(用户提供,需登录)。CC BY-NC-SA 4.0,仅供个人学习。

⭐⭐ 本课权重提示:领域 7(7%)的正名课——考纲领域 7 考「工具配置、AI Code Assistant 工作流、调试运维」,本课就是那个工作流的官方演示,且是全课程性价比最高的 4 分收官。同时回收费纲领域 2 复用策略的最后一个词:模块化提示在本课表现为「一次 prompt 三要素」(file / pattern / end state)。第 5 课的 Tool Runner 在此完成闭环——那时你手工写,现在让 AI Code Assistant 替你写。 🔗 与前十二课的关系:官方原话 using the same primitives you've learned throughout this course —— 本课示例用到的正是全课程教的那些原语(tool、agent loop、tool runner)。这课既是领域 7 教学课,也是全课程的实操总复习。


🎯 本课学习目标

⚠️ 本课官方未提供 What you'll learn 区块。以下按文稿结构反推:

  1. 能说清 stub-first 工作流:先把文件桩出来(函数签名+类型),再交给 AI Code Assistant 填肉。
  2. ⭐⭐ 能讲清 the AI API skill 的两种触发方式:/claude-api 手动调用,或检测到 TypeScript SDK 时自动加载。
  3. ⭐⭐ 能背出好 prompt 三要素:点名文件(file)、点名模式(pattern)、点名终态(end state)。
  4. 能复述 AI Code Assistant 的执行闭环:填桩 → 追加调用 → 跑脚本 → 报输出 → 错了就地修(patches in place)。
  5. ⭐⭐ 能默写 the AI API 三步模式:define a tool → hand it to a runner → return the result。
  6. 能记住收尾工作流公式:stub it, delegate it, review the diff。

📖 一、从桩开始(Starting from a stub)

官方原句: Writing code that calls the the AI API by hand works fine, but there's an even faster path: have the AI write it for you. In this lesson, we'll use AI Code Assistant to fill in an API integration from a stubbed-out file — using the same primitives you've learned throughout this course.

精译:手写调 the AI API 的代码当然可行,但有条更快的路:让 AI 替你写。本课用 AI Code Assistant 从一个只剩桩的文件里填出一套 API 集成 —— 用的正是你全课程学过的那些原语。

官方原句: The project is simple: a TypeScript file that gets weather. It contains two stubs: getWeather — accepts a city and returns the temperature and conditions. / run — a function that should use the tool runner and the the AI TypeScript SDK.

精译:项目很简单:一个取天气的 TypeScript 文件,里面两个桩——getWeather(收城市名,返回气温与天气状况)、run(应当使用 tool runner 与官方 TypeScript SDK 的函数)。

官方原句: The tool runner is the piece that handles tool calling and the agent loop for you*, so you don't have to wire that up manually*.

精译:tool runner 就是替你处理工具调用与 agent loop 的那个部件——你不用手工接线。

⭐⭐ 第 5 课闭环:第 5 课学过 Tool Runner(TS/Python/Ruby 三语言,折叠了循环细节)——当时是「知道有这东西」;本课它成了被 AI Code Assistant 直接调用的构件。「你不必手写循环」从第 4 课的原则变成了本课的日常。


📖 二、the AI API skill(内置技能)

官方原句: AI Code Assistant comes with a built-in skill called the AI API. You can invoke it directly with /claude-api, or AI Code Assistant will invoke it automatically when it detects that you're using the TypeScript SDK.

精译:AI Code Assistant 自带一个叫 the AI API 的内置技能。你可以用 /claude-api 直接调用它;或者当你在用 TypeScript SDK 时,AI Code Assistant 检测到后会自动调用它。

官方原句: If you don't see the skill, you can add it from the marketplace: /plugin marketplace add AnthropicsSkills Note the s at the end of Anthropics — it's easy to miss.

精译:看不到这个技能?从市场加装:/plugin marketplace add AnthropicsSkills。注意 Anthropics 结尾有个 s —— 很容易看漏。

触发方式 机制 考点
手动 斜杠命令 /claude-api skill 的调用形态(课程 001 渐进式披露的「按需调取」)
自动 检测到 TypeScript SDK 即加载 第 8 课 Skills 触发机制的平台版(name+description 先行,判定相关再加载)

⭐⭐ 考点:① 触发方式二选一题——「只能手动调用」与「永远自动加载」都是干扰项,官方答案是两种都有;② marketplace 命令里 Anthropics 的 s 是官方自己点名的细节陷阱。


📖 三、一个 prompt,能跑的代码(One prompt, working code)

官方原句: Open the project folder in your terminal and launch AI Code Assistant. From there, it takes a single prompt. A good prompt does three things: - It names the file you want changed. - **It names the pattern you want used. - It names the end state you expect.**

精译:在终端里打开项目文件夹,启动 AI Code Assistant。接着只要一句 prompt。好 prompt 做三件事:点名你要改的文件;点名你要用的模式;点名你期望的终态。

要素 本例对应 反面(缺失时)
file 文件 那个 stubbed-out 的 TS 文件 AI 乱开新文件
pattern 模式 tool runner + TypeScript SDK AI 自己发明写法
end state 终态 getWeather/run 填好且能跑出结果 「改好了」但没验收标准

官方原句: AI Code Assistant then fills in getWeather and run against the types, appends a call at the bottom of the file, executes the script, and reports the output. If something errors out, it reads the error message and patches the code in place.**

精译:然后 AI Code Assistant 照着类型填好 getWeather 与 run,在文件末尾追加一次调用,执行脚本,汇报输出。哪里报错,它就读错误信息,就地修补代码。

⭐⭐ 考点:prompt 三要素与第 8 课判别句同族——这本质上是把「how」写进 prompt(file=what to change、pattern=how to do it、end state=what done looks like)。与第 11 课 rubric(定义完成)和领域 6「结构化沟通」同构:给验收标准,不给代劳步骤。


📖 四、它产出了什么(What AI Code Assistant produced)

官方原句: In this run, AI Code Assistant created a Zod tool that parsed the input and returned the output based on the city type. It also created the tool runner and the run function we asked for, and printed the final results of the agent loop.

精译:这一次运行里,AI Code Assistant 建了一个 Zod 工具(解析输入、按城市类型返回输出),建好了我们要的 tool runner 与 run 函数,并打印出 agent loop 的最终结果。

⭐ 注意 Zod:TypeScript 生态的 schema 校验库——工具输入用 schema 约束,正是第 4–5 课「工具定义=schema」的 TS 生态实现。考题若出现 Zod,认出它是「输入校验/schema 库」即可。


📖 五、要记住的模式(The pattern to remember)

官方原句: Most of what you write against the the AI API has a familiar shape: 1. Define a tool. 2. **Hand it to a runner. 3. Return the result.**

精译:你对 the AI API 写的大多数代码都是这个熟悉的形状:① 定义一个工具;② 交给 runner;③ 返回结果。

官方原句: You don't need to type that from memory every single time.* Instead, stub the file, hand it to AI Code Assistant, and just review the diff*.

精译:你不需要每次凭记忆敲这三步。把文件桩出来,交给 AI Code Assistant,然后只审 diff 就行。

⭐⭐ 收尾公式(全课程收官句)

Stub it, delegate it, review the diff. 「桩出来、委派出去、审 diff。」 * 考点:三动词工作流与第 11–12 课「你定义完成、AI 干到达标」一脉相承——人守验收,AI 干活。这是领域 7「用 AI Code Assistant 构建与审查」的标准姿势,也是第 2 课 Discernment(审查 AI 产出)在编码场景的落地。


📌 六、Recap(官方四条要点)

# 官方原句 一句话
1 AI Code Assistant is an agent that edits files and runs commands inside your terminal. 会改文件、能跑命令的终端 agent
2 The built-in the AI API skill loads automatically when AI Code Assistant detects the TypeScript SDK, or you can invoke it with /claude-api. skill 双触发:自动检测+手动斜杠
3 Give it a prompt that names the file, the pattern, and the end state — it writes the code, runs it, and fixes errors in place. prompt 三要素+就地修错
4 the AI API code follows a familiar shape: define a tool, hand it to a runner, return the result. Stub it, delegate it, review the diff.** 三步模式+收官工作流

🧠 本课 → CCAR-P 考点映射

本课内容 对应领域 权重
AI Code Assistant 工作流(skill 触发、prompt 三要素、就地修错) 领域 7 Developer Productivity 7%
the AI API 三步模式(define → runner → return) 领域 3 + 领域 7 19% / 7%
prompt 三要素(结构化委派=模块化提示实践) 领域 2 Models, Prompting & Context Engineering 13%
审查 diff(Discernment 落地) 领域 5 + 领域 6(审查与责任) 14%

⭐ 战略结论:领域 7 只有 7%(约 4 题)但成本极低——本课+第 12 课的托管 API 清单基本覆盖全部考点。至此课程 003 十三课正文全部归档完毕,接下来只剩官方 Quiz。


🔤 本课新生词(已回灌 30-单词表/03,2026-10-14)

词汇 音标 释义 备注
⭐⭐ stub /stʌb/ 桩、存根(v./n.) stubbed-out file;先桩后填工作流 → 精讲 059
⭐⭐ pattern /ˈpætərn/ 模式(写法范式) names the pattern;第 11 课「规律」义已收,此处「代码范式」义升级 → 精讲 060
⭐⭐ diff /dɪf/ 差异(代码变更对比) review the diff;开发者验收核心词 → 精讲 061
⭐⭐ invoke /ɪnˈvoʊk/ 调用 invoke it directly with /claude-api → 精讲 062
⭐⭐ detect /dɪˈtekt/ 检测 detects that you're using the TypeScript SDK → 精讲 063
⭐⭐ in place — 就地、原处 patches the code in place → 精讲 064
⭐ marketplace /ˈmɑːrkɪtpleɪs/ 市场(插件市场) /plugin marketplace add
⭐ slash command — 斜杠命令 /claude-api(skill 手动触发形态)
⭐ auto-(前缀) — 自动 auto-invoke / auto-summarize / auto-inject 三课同族
⭐ append /əˈpend/ 追加 appends a call at the bottom of the file
⭐ error out — 报错 If something errors out
⭐ patch(v.) /pætʃ/ 修补 patches the code in place
⭐ fill in — 填入、填好 fill in an API integration from a stubbed-out file
stubbed-out — 只剩桩的 函数签名+类型、无实现的文件
tool runner — 工具运行器 第 5 课已收,此处复现(handles tool calling and the agent loop for you)
TypeScript SDK — TS 软件开发包 自动触发 skill 的检测对象
SDK — 软件开发工具包 第 1 课已收,此处复现
Zod — Zod(TS schema 校验库) a Zod tool that parsed the input(输入 schema 约束)
parse /pɑːrs/ 解析 parsed the input
types /taɪps/ 类型(TS 类型) fills in … against the types
integration — 集成 精讲 037 已收,此处复现(an API integration)
primitives — 原语 精讲 001/053 已收,此处复现(the same primitives)
agent loop — agent 循环 第 4 课已收,此处复现(final results of the agent loop)
built-in — 内置的 第 7 课已收,此处复现(a built-in skill)
terminal — 终端 第 8 课已收,此处复现(edits files and runs commands inside your terminal)
wire up — 接线、接入 第 1/10 课已收,此处复现(don't have to wire that up manually)
by hand — 手工 Writing code … by hand(对比 AI 代写)
familiar /fəˈmɪliər/ 熟悉的 a familiar shape
end state — 终态 the end state you expect(prompt 三要素之三)
delegate — 委派 精讲 050 已收,此处复现(收官公式 delegate it)
launch /lɔːntʃ/ 启动 launch AI Code Assistant
review /rɪˈvjuː/ 审查 review the diff(Discernment 编码落地)
automatically /ˌɔːtəˈmætɪkli/ 自动地 loads automatically
weather /ˈweðər/ 天气 场景词(getWeather 示例)
temperature /ˈtemprətʃər/ 气温 场景词
conditions /kənˈdɪʃnz/ 天气状况 场景词;表 02-028 consideration 同族形近
execute /ˈeksɪkjuːt/ 执行 executes the script;第 5 课 your code executes 复现义
print /prɪnt/ 打印 printed the final results

✅ 本课进度

  • [x] 全文精译与架构师级拆解(2026-10-14)
  • [x] ⭐⭐ 记录 stub 工作流、prompt 三要素、the AI API 三步模式与收官公式
  • [x] 记录 skill 双触发机制与第 5 课 Tool Runner 闭环
  • [x] 生词回灌 30-单词表/03-考试核心生词与术语表.md(2026-10-14:新增速查 29 条 → 全表 534 条(与表内重复 9 词追加「第 13 课复现」);新升级精讲 6 条 059–064)
  • [x] 保存本课英文原文(28-English-13-Building-with-AI-Code-Assistant.md)
  • [x] 课程 003 十三课正文全部精译完毕(2026-10-14)—— 仅剩官方 Quiz 与 demo 实跑
  • [ ] 跑通本课 runnable demo(需 AI Code Assistant 环境)
  • [ ] 官方未提供 What you'll learn 与练习区块 —— 若后续页面补全,需回填

🔗 关联

⚠️ 语料说明:英文原文中的 the AI 产品名为去品牌化形态;其余英文引句均为官方原句,未作改动。

输入至少 2 个字符,检索全部课程与单词表