createSkill()
Creates an inline skill that can be passed directly to an agent's skills config without a filesystem or workspace.
The returned object implements the Skill interface and works anywhere a filesystem-discovered skill works.
Usage exampleDirect link to Usage example
import { createSkill } from '@mastra/core/skills'
const reviewSkill = createSkill({
name: 'code-review',
description: 'Use when reviewing code changes.',
instructions: `
When reviewing code:
1. Check for correctness
2. Check for style consistency
3. Look for potential bugs
`,
references: {
'checklist.md': '# Review Checklist\n- No unused imports\n- Error handling present',
'languages/typescript.md': '# TypeScript\n- No `any` without a comment',
},
scripts: {
'lint.sh': '#!/bin/sh\npnpm lint',
},
assets: {
'badge.svg':
'<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8"><circle cx="4" cy="4" r="4"/></svg>',
},
})
The agent reads bundled files with the skill_read tool using paths like references/languages/typescript.md, scripts/lint.sh, or assets/badge.svg. Keys containing / become nested directories.
The skill holds every bundled file in memory for as long as it exists. A filesystem skill reads its scripts/ and assets/ files from disk only when the agent opens them, so keep large scripts and binary files there. It reads references/ when the skill loads, to index them for search. To load skills from a database, return them from an async skills resolver, which runs per request.
ParametersDirect link to Parameters
name:
description:
instructions:
references?:
skill_read tool. Keys are paths inside references/, values are file contents.scripts?:
skill_read tool. Keys are paths inside scripts/, values are file contents.assets?:
skill_read tool. Keys are paths inside assets/. Values can be text or binary. skill_read returns supported images and PDFs up to 10 MiB to the model as media. Other binary files, such as ZIP archives, and media over 10 MiB come back as their path and size only.license?:
compatibility?:
user-invocable?:
undefined (agent decides).metadata?:
Return valueDirect link to Return value
Returns an InlineSkill object that implements the Skill interface:
interface InlineSkill extends Skill {
__inline: true
__referenceContents: Record<string, string>
__scriptContents?: Record<string, string>
__assetContents?: Record<string, string | Uint8Array>
}
The skill is assigned a synthetic path of inline/<name> (e.g., inline/code-review).
ValidationDirect link to Validation
createSkill() validates inputs using the same rules as filesystem skills:
nameis required and must be a valid slugdescriptionis required- Keys in
references,scripts, andassetsmust be relative file paths separated by/, without empty,., or..segments, and can't start with a drive letter such asC:. A key can't also be the directory of another key
If validation fails, an Error is thrown with details about the invalid fields.
// Throws: Invalid skill "": name: Skill name cannot be empty
createSkill({ name: '', description: 'test', instructions: 'test' })