TypeSafe 智能体技能为你的 AI 编程智能体提供关于 TypeSafe API 的完整上下文:三种问题类型、架构模式,以及组织评估的最佳实践。
安装
在终端中运行这两条命令:
claude plugin marketplace add typesafe-ai/skills
claude plugin install typesafe@typesafe-ai
npx skills add typesafe-ai/skills --skill typesafe-ai
出现提示时选择你的智能体。默认安装为项目本地安装;添加 -g 可全局安装。
把下面的提示词粘贴到你的编程智能体中:
Install the TypeSafe skill. If you're in Claude Code, run `claude plugin marketplace add typesafe-ai/skills`, then `claude plugin install typesafe@typesafe-ai`. If you're in another agent, run `npx skills add typesafe-ai/skills --skill typesafe-ai` and select your agent. Use one installation method. You can read the skill directly at https://github.com/typesafe-ai/skills/blob/main/skills/typesafe-ai/SKILL.md (raw: https://raw.githubusercontent.com/typesafe-ai/skills/main/skills/typesafe-ai/SKILL.md). Then use the TypeSafe skill when working on this project.
阅读 GitHub 上的 SKILL.md,或直接获取原始 Markdown。如需手动安装,请将整个 skills/typesafe-ai 目录(包括其中的参考文件)复制到你所用智能体的 skills 目录中。
请只选择一种安装方式,以避免出现重复副本。
更新
对于 Claude Code 插件,运行:
claude plugin marketplace update typesafe-ai
claude plugin update typesafe@typesafe-ai
重启 Claude Code 或运行 /reload-plugins 以加载更新。要启用自动更新,请打开 /plugin,选择 Marketplaces → typesafe-ai → Enable auto-update。
对于通过 skills.sh 安装的方式,运行 npx skills update。对于手动复制的安装,请将整个技能目录替换为 GitHub 上的最新版本。
示例提示词
在提示词中点出技能名称——“use the TypeSafe skill”——在任何智能体中都有效,因此下面的每个提示词都采用了这种写法。使用 Claude Code 插件时,你还可以直接调用 /typesafe:typesafe-ai。
-
一个好的入门提示词是头脑风暴式的提示词,帮助你弄清 TypeSafe 最适合用在项目的哪些地方。
textUsing the TypeSafe skill, explore the project and find opportunities for using intelligent judgement to stand in for complex parsing or other fragile code. -
你还可以创建一个 API 密钥,并让你的智能体通过运行低成本的测试查询,自行找出使用 TypeSafe 的最佳方式。
textUsing the TypeSafe skill, run some experiments using the TypeSafe API key that I've exported to `TYPESAFE_API_KEY`. Propose changes based on the most promising results. -
让你的智能体参考能解决你代码库中某个具体问题的某篇实战指南,或者让它查看实战指南索引,问问其中是否有与你项目里的模式类似的做法。
textUsing the TypeSafe skill, analyze my code and see if there are any applicable cookbooks (https://console.typesafe.ai/docs/cookbooks) that show how I could refactor my code to be less fragile or complex.
良好的氛围编程原则
- 与你的智能体把事情谈透,以上面的示例提示词为起点。
- 在实施之前先审查计划,确认它合理可行。
- 把常量(问题和阈值)集中放在一个地方,便于审查。智能体并不擅长编写问题,所以要准备好与它们协作修改。
- 不要对断言照单全收;鼓励智能体验证自己的假设。
常见问题
智能体没有使用该技能
使用 Claude Code 插件时,调用 /typesafe:typesafe-ai。在其他智能体中,要求“使用 TypeSafe 技能”。如果仍未加载,请确认安装器面向的是你正在使用的智能体,然后重启该智能体。
路由的表现不如预期
检查问题和阈值。你的阈值可能设置得过高(导致漏报)或过低(导致误报)。你也可能需要把问题调整得更具体。
你在到处使用置信度阈值
如果你只关心选出最佳选项,那么只需选择置信度最高的选项(而不是设置一个置信度阈值)。如果你心里有明确的统计算法,那么你应该使用概率而不是置信度。
TypeSafe 代码难以审查
最需要人工审查的,是 TypeSafe 代码中用到的问题和所有阈值常量。它们应该集中定义在一个代码文件中,这样无需四处翻找就能轻松定位。
智能体编造请求或响应字段
技能版本过旧可能导致这个问题。按上面对应的安装方式更新后重试。