> Discover all available pages from the documentation index: https://mastra.zisheng.pro/llms.txt # `.getSkill()` 按名称从 Agent 配置的 Skill(包括 Agent 级 Skill 和 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,则返回 `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/docs/agents/skills) - [`.listSkills()` 参考](https://mastra.zisheng.pro/reference/agents/listSkills) - [`createSkill()` 参考](https://mastra.zisheng.pro/reference/agents/createSkill)