createSkill()
ファイルシステムや Workspace を使わず、Agent の skills 設定へ直接渡せるインライン Skill を作成します。
返されるオブジェクトは Skill インターフェースを実装し、ファイルシステムから検出された Skill と同じ場所で使用できます。
使用例使用例への直接リンク
src/mastra/skills.ts
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',
},
})
パラメータパラメータへの直接リンク
name:
string
一意の Skill 名。Agent が Skill を有効化するときの識別子として使われます。有効な slug(小文字、ハイフン使用可)である必要があります。
description:
string
システムメッセージで Agent に表示する短い説明。Agent が Skill を使うタイミングを判断するために使います。
instructions:
string
Markdown 形式の完全な Skill instructions。Agent が Skill を有効化すると会話へ読み込まれます。
references?:
Record<string, string>
Agent が
skill_read Tool で読める補足ドキュメント。キーはファイル名、値はファイル内容です。license?:
string
Skill の SPDX ライセンス識別子。
compatibility?:
unknown
互換性要件。Agent Skills 仕様では柔軟に定義でき、文字列配列、オブジェクト、または Tool が想定する任意の構造を指定できます。
user-invocable?:
boolean
エンドユーザーがこの Skill を直接呼び出せるかどうか。デフォルトは
undefined(Agent が判断)です。metadata?:
Record<string, unknown>
Skill に付加する任意のメタデータ。
戻り値戻り値への直接リンク
Skill インターフェースを実装する InlineSkill オブジェクトを返します。
interface InlineSkill extends Skill {
__inline: true
__referenceContents: Record<string, string>
}
Skill には inline/<name> 形式の仮想パス(例:inline/code-review)が割り当てられます。
バリデーションバリデーションへの直接リンク
createSkill() は、ファイルシステム上の Skill と同じ規則で入力を検証します。
nameは必須で、有効な slug であることdescriptionは必須instructionsは必須で、空でないこと
検証に失敗すると、無効なフィールドの詳細を含む Error がスローされます。
// Throws: Invalid skill "": name is required
createSkill({ name: '', description: 'test', instructions: 'test' })