> Discover all available pages from the documentation index: https://mastra.zisheng.pro/zh-TW/llms.txt # `.getSkill()` 依名稱從 Agent 已設定的 Skill 中取得特定 Skill(包含 Agent 層級與 Workspace 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 resolver 的 request context。 ## 回傳值 回傳 `Promise`。 若找到則回傳 `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-TW/docs/agents/skills) - [`.listSkills()` 參考文件](https://mastra.zisheng.pro/zh-TW/reference/agents/listSkills) - [`createSkill()` 參考文件](https://mastra.zisheng.pro/zh-TW/reference/agents/createSkill)