TS TypeSafe 文档中文版 原文 ↗

智能体技能

面向 Claude Code、Codex 以及其他智能体环境的即插即用技能。

TypeSafe 智能体技能为你的 AI 编程智能体提供关于 TypeSafe API 的完整上下文:三种问题类型、架构模式,以及组织评估的最佳实践。

安装

在你的终端中运行以下两条命令:

bash
claude plugin marketplace add typesafe-ai/skills
claude plugin install typesafe@typesafe-ai
 
bash
npx skills add typesafe-ai/skills --skill typesafe-ai
 

提示时选择你的智能体。安装默认限定在项目内;加上 -g 可全局安装。

把下面这段提示词粘贴到你的编程智能体中:

plaintext
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 目录(包括其中的参考文件)复制到你的智能体技能目录中。

请只选择一种安装方式,以免出现重复副本。

更新

对于 Claude Code 插件,请运行:

bash
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 上的最新版本替换整个技能目录。

示例提示词

在提示词中指明该技能——「使用 TypeSafe 技能」——在任何智能体中都有效,因此下面每个提示词都这样写。使用 Claude Code 插件时,你也可以直接调用 /typesafe:typesafe-ai。

  • 一个很好的起手提示词是头脑风暴式的提示词,帮你找出 TypeSafe 在项目中能发挥最大作用的地方。
plaintext
Using 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 的最佳方式。
plaintext
Using 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.
 
  • 把你的智能体指向某个能解决你代码库中具体问题的特定实践手册,或者指向实践手册索引,让它看看是否有与你项目中的做法相似的模式。
plaintext
Using 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.
 

良好的氛围编程原则

  1. 与你的智能体把想法聊透,以上面的示例提示词作为起点。
  2. 在实施之前先审查方案,确认它确实合理。
  3. 把常量(问题与阈值)集中放在一处,以便审查。智能体并不擅长撰写问题,因此要做好与它们协作修改的准备。
  4. 不要轻信断言;鼓励智能体验证它自己的假设。

常见问题

智能体没有使用该技能

使用 Claude Code 插件时,调用 /typesafe:typesafe-ai。在其他智能体中,请要求「使用 TypeSafe 技能」。如果仍未加载,请确认安装程序针对的是你正在使用的智能体,然后重启该智能体。

路由没有按预期工作

检查问题与阈值。你的阈值可能设得过高(造成漏判)或过低(造成误判)。你也可能需要调整问题,使其更具体。

到处都在使用置信度阈值

如果你关心的只是选出最好的选项,那么只需选择置信度最高的选项(而不必设置置信度阈值)。如果你心里有特定的统计算法,那么你大概应该使用概率而不是置信度。

TypeSafe 代码难以审查

人类最需要审查的是问题本身,以及 TypeSafe 代码中用到的任何阈值常量。它们应定义在同一个代码文件中,这样不必大费周章地翻找就能找到。

智能体凭空编造请求或响应字段

技能版本过旧可能导致这种情况。用上面的安装方式更新它,然后重试。