Skip to main content

.getSkill()

Retrieves a specific skill by name from the agent's configured skills (both agent-level and workspace skills).

Usage example
Direct link to Usage example

src/routes/skills.ts
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
Direct link to Parameters

skillName:

string
The name of the skill to retrieve.

options?:

object
Options for skill resolution.
object

requestContext?:

RequestContext
Request context passed to dynamic skill resolvers.

Return value
Direct link to Return value

Returns Promise<Skill | null>.

Returns the Skill object if found, or null if no skill with that name exists.

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
Direct link to 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.

On this page