@mastra/core
Version:
60 lines (42 loc) • 1.64 kB
Markdown
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
# `.getSkill()`
Retrieves a specific skill by name from the agent's configured skills (both agent-level and workspace skills).
## Usage example
```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
}
```
## Parameters
**skillName** (`string`): The name of the skill to retrieve.
**options** (`object`): Options for skill resolution.
**options.requestContext** (`RequestContext`): Request context passed to dynamic skill resolvers.
## Return value
Returns `Promise<Skill | null>`.
Returns the `Skill` object if found, or `null` if no skill with that name exists.
```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<string, unknown>
}
```
## Merging behavior
When both agent-level skills and workspace skills are configured, `.getSkill()` searches the merged set. Agent-level skills take precedence on name conflicts.
## Related
- [Agent skills](https://mastra.ai/docs/agents/skills)
- [`.listSkills()` reference](https://mastra.ai/reference/agents/listSkills)
- [`createSkill()` reference](https://mastra.ai/reference/agents/createSkill)