> ## Documentation Index
> Fetch the complete documentation index at: https://docs.hitheo.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 技能（defineSkill）

> 用于创建 Theo 技能清单的类型安全构建器。

## `defineSkill(input)`

根据部分输入验证并返回完整的 `SkillManifest`。

```typescript theme={null}
import { defineSkill } from "@hitheo/sdk";

export default defineSkill({
  name: "Inventory Check",
  slug: "inventory-check",
  version: "1.0.0",
  description: "Real-time inventory lookup and reorder alerts",
  category: "automation",
  author: { name: "Acme Corp" },
  systemPromptExtension: `
    You are an inventory management specialist. When the user asks about
    stock levels, use the check_stock tool.
  `,
  tools: [
    {
      name: "check_stock",
      description: "Look up current stock levels by SKU",
      inputSchema: {
        type: "object",
        properties: {
          sku: { type: "string" },
          warehouse: { type: "string" },
        },
      },
    },
  ],
  permissions: ["read:artifacts", "external:http", "execute:tools"],
  modelPreference: "theo-1-reason",
  trigger: { type: "keyword", config: { keywords: ["stock", "inventory"] } },
  knowledge: ["./warehouse-rules.json"],
});
```

## 验证

`defineSkill` 会验证：

* **Slug 格式** — 小写字母数字加连字符，且首尾不能有连字符
* **版本号** — 必须遵循语义化版本规范（`1.0.0`）
* **工具名称** — 小写字母数字加下划线

输入无效时会抛出 `Error`。

## SkillManifestInput 字段

| 字段 | 类型 | 是否必填 | 说明 |
| - | - | - | - |
| `name` | `string` | ✅ | 人类可读的技能名称 |
| `slug` | `string` | ✅ | 唯一标识符（小写、连字符） |
| `version` | `string` | ✅ | 语义化版本号 |
| `description` | `string` | ✅ | 简短描述 |
| `category` | `SkillCategory` | ✅ | `"productivity"`、`"domain"`、`"integration"`、`"automation"`、`"creative"` |
| `author` | `{ name, email?, url? }` | ✅ | 作者信息 |
| `systemPromptExtension` | `string` | ✅ | 注入到 LLM 系统提示词中的内容 |
| `tools` | `SkillToolInput[]` | — | 工具定义 |
| `permissions` | `SkillPermission[]` | — | 所需权限 |
| `knowledge` | `string[]` | — | 随附的知识文件路径 |
| `modelPreference` | `string` | — | 首选模型 ID |
| `trigger` | `SkillTriggerInput` | — | 激活触发器 |
| `hooks` | `{ onInstall?, onUninstall? }` | — | 生命周期钩子 |
| `readme` | `string` | — | Markdown 格式的 README |
| `changelog` | `string` | — | Markdown 格式的更新日志 |
| `license` | `string` | — | 许可证标识符（默认：`"MIT"`） |
| `repository` | `string` | — | 源代码仓库 URL |
| `keywords` | `string[]` | — | 搜索关键词 |

完整的编写指南请参见 [技能深入解析](/skills/overview)。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.