> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-HK/llms.txt # `.getSkill()` 按名稱從 Agent 已設定的 Skill(包括 Agent 層級和 Workspace Skill)擷取指定 Skill。 ## 使用範例 ```typescript import { agent } from '../mastra/agents' const skill = await agent.getSkill('code-review') if (skill) { console.log(skill.name) // "code-review" console.log(skill.description) // "Use when reviewing code changes." console.log(skill.instructions) // Full markdown instructions } ``` ## 參數 **skillName** (`string`): 要擷取的 Skill 名稱。 **options** (`object`): 解析 Skill 的選項。 **options.requestContext** (`RequestContext`): 傳送至動態 Skill 解析器的請求情境。 ## 傳回值 傳回 `Promise`。 如找到 Skill,便傳回 `Skill` 物件;如不存在該名稱的 Skill,則傳回 `null`。 ```typescript interface Skill { name: string description: string instructions: string path: string source: { type: string; projectPath: string } references: string[] scripts: string[] assets: string[] license?: string compatibility?: string[] 'user-invocable'?: boolean metadata?: Record } ``` ## 合併行為 同時設定 Agent 層級 Skill 和 Workspace Skill 時,`.getSkill()` 會搜尋合併後的集合。如果名稱衝突,Agent 層級 Skill 優先。 ## 相關內容 - [Agent Skill](https://mastra.zisheng.pro/zh-HK/docs/agents/skills) - [`.listSkills()` 參考](https://mastra.zisheng.pro/zh-HK/reference/agents/listSkills) - [`createSkill()` 參考](https://mastra.zisheng.pro/zh-HK/reference/agents/createSkill)