文档导航

Agent 技能

Agent 技能

即插即用的技能,适用于 Claude Code、Codex 等 agent 环境。

TypeSafe agent 技能让你的 AI 编程 agent 完整掌握 TypeSafe API:三种问题类型、架构模式,以及组织评估的最佳实践。

安装

在终端里运行这两条命令:

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

出现提示时选择你的 agent。安装默认只对当前项目生效;加 -g 可全局安装。

把下面这段提示词粘贴进你的编程 agent:

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 目录(含其中的参考文件)复制到你的 agent 的 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」—— 在任何 agent 里都管用,所以下面每条提示词都这么写。用 Claude Code 插件时,你也可以直接调用 /typesafe:typesafe-ai。

  • 可以先从头脑风暴式的提示词入手,帮你找出项目里最适合用 TypeSafe 的地方。

    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 密钥,让 agent 通过跑一些便宜的测试查询,自己找出使用 TypeSafe 的最佳方式。

    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.
  • 把你的 agent 指向某个具体的 cookbook,来解决你代码库里的某个问题;或者指向 cookbooks 索引,问它有没有和你项目里相似的模式。

    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.

良好的 vibe coding 原则

  1. 先和你的 agent 聊清楚,把上面的示例提示词当作起点。
  2. 实现之前先审阅方案,确认它讲得通。
  3. 把常量(问题和阈值)集中放在一处,方便审阅。agent 写问题并不擅长,做好和它一起改的准备。
  4. 不要照单全收它的断言;让 agent 验证自己的假设。

常见问题

agent 没有使用这个技能

用 Claude Code 插件时,调用 /typesafe:typesafe-ai。在其它 agent 里,让它「use the TypeSafe skill」。如果还是没加载,确认安装器指向的是你在用的 agent,然后重启 agent。

路由表现和预期不符

检查问题和阈值。有可能阈值设得太高(导致漏判),也可能设得太低(导致误判)。你可能还需要把问题改得更具体些。

到处都在用置信度阈值

如果你只想选出最佳选项,只需要选置信度最高的那个(而不是设一个置信度阈值)。如果你心里有特定的统计算法,那大概应该用概率而不是置信度。

TypeSafe 代码不好审阅

人最该审阅的是问题和 TypeSafe 代码里用到的阈值常量。它们应该定义在同一个代码文件里,这样不用到处翻就能找到。

agent 编造请求或响应字段

技能版本太旧会导致这个问题。按上面的安装方式更新它,再重试。