mastra
БесплатноБез исполняемых скриптовНе проверенMastra is a TypeScript framework for building AI agents, tools, workflows, memory and RAG pipelines, with a local Studio for testing. Use when building an…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
Mastra
Overview
Mastra is a TypeScript framework (1.x line; @mastra/core 1.78 and mastra CLI 1.34 were current on 2026-10-15) for agents, tools, workflows, memory and RAG. Everything is registered on one Mastra instance, and mastra dev serves it with Studio, a local UI for chatting with agents and running workflows. Models are named with provider/model strings and read the provider key from the environment (OPENAI_API_KEY). Imports use sub-paths such as @mastra/core/agent; the old import { Agent } from "@mastra/core", @mastra/openai and new Workflow/new Step forms are gone.
Instructions
- Scaffold with
npm create mastra@latest, or by hand:npm install @mastra/core@latest zod typescript @types/node mastra@latestin a package with"type": "module". Source lives insrc/mastra/(index.ts,agents/,tools/,workflows/). - Define tools with
createToolfrom@mastra/core/tools(id,description, zodinputSchema,execute). Plain-object tools do not execute. - Define agents with
new Agent({ id, name, instructions, model, tools })from@mastra/core/agent, register them innew Mastra({ agents }), and fetch withmastra.getAgentById("id"). - Call
agent.generate(prompt)(returnstext,toolCalls,usage) oragent.stream(prompt)and iteratestream.textStream. For typed output pass{ structuredOutput: { schema: zodSchema } }and readresponse.object. - Workflows: build steps with
createStepand chain withcreateWorkflow(...).then(step).branch(condition, step).commit()from@mastra/core/workflows. Run withawait mastra.getWorkflow("key").createRun()thenrun.start({ inputData }); checkresult.status === "success"before readingresult.result(other statuses: failed, suspended, tripwire, paused). - Memory:
npm install @mastra/memory @mastra/libsql, setstorageon the Mastra instance, give the agentmemory: new Memory({ options: { lastMessages: 20 } }), and passmemory: { resource, thread }on each call. Observational memory (observationalMemory: true), working memory and semantic recall are the other memory types. - RAG:
MDocument.fromText()anddoc.chunk()from@mastra/rag,embedManyfromai, and a vector store such asPgVectorfrom@mastra/pg(upsert,query). - Run
npx mastra devfor Studio and the local API,mastra buildandmastra startfor production.
Examples
Example 1: Support agent with a tool
User request: "Build an agent that looks up a customer's plan by email."
// src/mastra/tools/plan-tool.ts
import { createTool } from "@mastra/core/tools";
import { z } from "zod";
export const planTool = createTool({
id: "get-customer-plan",
description: "Look up a customer's subscription plan by email",
inputSchema: z.object({ email: z.string().email() }),
outputSchema: z.object({ plan: z.string() }),
execute: async ({ email }) => ({ plan: email.endsWith("@acme.io") ? "Growth" : "Starter" }),
});
// src/mastra/agents/support-agent.ts
import { Agent } from "@mastra/core/agent";
import { planTool } from "../tools/plan-tool.ts";
export const supportAgent = new Agent({
id: "support-agent",
name: "Support Agent",
instructions: "Answer billing questions. Check the plan with the tool before promising features.",
model: "openai/gpt-5-mini",
tools: { planTool },
});
// src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { supportAgent } from "./agents/support-agent.ts";
export const mastra = new Mastra({ agents: { supportAgent } });
Result: npx mastra dev opens Studio where support-agent can be chatted with; in code, (await mastra.getAgentById("support-agent").generate("What plan is [email protected] on?")).text returns the answer after one tool call.
Example 2: Workflow with a branch, verified to run
User request: "Add one to a number, then multiply by ten only if it is above one."
import { createStep, createWorkflow } from "@mastra/core/workflows";
import { z } from "zod";
const num = z.object({ n: z.number() });
const addOne = createStep({ id: "add-one", inputSchema: num, outputSchema: num,
execute: async ({ inputData }) => ({ n: inputData.n + 1 }) });
const timesTen = createStep({ id: "times-ten", inputSchema: num, outputSchema: num,
execute: async ({ inputData }) => ({ n: inputData.n * 10 }) });
export const calc = createWorkflow({ id: "calc", inputSchema: num, outputSchema: num })
.then(addOne)
.branch(async ({ inputData }) => inputData.n > 1, timesTen)
.commit();
Result: with new Mastra({ workflows: { calc } }), run.start({ inputData: { n: 2 } }) returns status success; the branch output is keyed by step id, here { "times-ten": { n: 30 } }.
Example 3: Remember a user across calls
User request: "The agent should remember my favourite colour."
import { Memory } from "@mastra/memory";
// in the Agent options: memory: new Memory({ option
Установить mastra в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл mastra?
Mastra is a TypeScript framework for building AI agents, tools, workflows, memory and RAG pipelines, with a local Studio for testing. Use when building an agent in TypeScript, adding tools, multi-step workflows with branching, conversation memory or retrieval to a Node.js app, or when the user mentions Mastra, @mastra/core, createWorkflow or mastra dev.
Как установить скилл mastra?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл mastra запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic