Skip to main content

Agent Skill

机器翻译译自英文(docs.typesafe.ai)本页 31 段里 1 段还没译

文档索引

在以下地址获取完整的文档索引:https://docs.typesafe.ai/llms.txt 使用此文件可以在进一步探索之前发现所有可用页面。

Agent Skill

适用于 Claude Code、Codex 及其他 agent 环境的即插即用 skill。

TypeSafe agent skill 为你的 AI 编程 agent 提供了关于 TypeSafe API 的完整上下文:三种问题 类型、架构 模式 以及结构化评估的最佳实践。

安装

Claude Code其他 agents复制到你使用的 agent

在终端中运行以下两个命令:

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

阅读 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 上的最新版本替换整个 skill 目录。

示例提示词

在提示词中命名该 skill —— “使用 TypeSafe skill” —— 适用于任何 agent,因此下方的提示词都采用了这种方式。如果使用 Claude Code 插件,还可以直接调用 /typesafe:typesafe-ai。

  • 一个不错的开始提示(prompt)是头脑风暴提示,帮助你找出 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,或者指向 cookbook 索引,并询问是否有与你项目中相似的模式。

    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. 参考上方的示例提示词,与你的 agent 讨论方案。
  2. 在实施前审阅该计划,确保其合理。
  3. 将常量(问题和阈值)放在一个地方,以便轻松审阅。Agents 在生成问题上表现不佳,因此预期你需要与它们协同编辑。
  4. 不要轻易接受断言;鼓励 agent 验证其假设。

常见问题

Agent 未使用该 skill

使用 Claude Code 插件时,调用 /typesafe:typesafe-ai。在其他 agent 中,要求“使用 TypeSafe skill”。如果仍未加载,请确认安装程序针对你正在使用的 agent,然后重启 agent。

路由未按预期工作

检查问题和阈值。你的阈值可能设置得过高(导致假阴性)或过低(导致假阳性)。你也可能需要调整问题使其更具体。

你随处可见地使用了置信度阈值

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

复审 TypeSafe 代码很困难

人类复审最重要的部分是问题以及 TypeSafe 代码中使用的任何阈值常量。应将它们定义在单个代码文件中,以便轻松查找而无需深入挖掘。

Agent 捏造了请求或响应字段

过时的 skill 可能会导致此问题。请使用上述安装方法更新它并重试。