agentleFS
YGhorbelYGhorbel/awesome-mastra-skills/skills/mastra-guide/SKILL.md

mastra-guide

Skill2 starsChanged 29 days agoApache-2.0View on GitHub

Entry point and router for building with the Mastra TypeScript AI framework: maps any goal to the right Mastra feature and the skill that covers it, and sets the rule to verify every API against current docs before writing code. Use this skill whenever the user mentions Mastra, @mastra packages, or asks what Mastra can do, which Mastra primitive to use, how the pieces fit together, or where to start. Triggers on Mastra, mastra.ai, @mastra/core, which Mastra feature, agent or workflow, how do I build X with Mastra, Mastra architecture, Mastra overview, Mastra docs lookup. Also triggers at the start of any task inside a project that has a src/mastra folder or @mastra dependencies, even if the user does not name the feature.

The file

We split this skill into the rules it gives an agent

5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Verify the API: If node_modules/@mastra/ exists, read node_modules/@mastra/<package>/dist/docs/ and installed types.

    line 116
  2. Distinctive:

    Check for a native capability: Before designing custom infrastructure, search the routing table and docs index.

    line 117
  3. Distinctive:

    Using an agent for a fixed process: If the steps are known, a workflow is cheaper and more predictable.

    line 151
  4. Distinctive:

    Using a workflow for open-ended reasoning: If the steps depend on what the model finds, use an agent.

    line 152
  5. Very specific:

    When code follows: the files to create and where they register in src/mastra/index.ts

    line 166

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Mastra Guide

Route any Mastra request to the right feature and skill, and verify APIs against current docs before writing code.


When to use

  • The user names Mastra but not a specific feature
  • Choosing between primitives (agent vs workflow, memory vs RAG vs knowledge, tool vs MCP)
  • Planning a new Mastra app and deciding which features it needs
  • Looking up where an API is documented or checking that an API still exists
  • Onboarding someone to how Mastra's pieces fit together

When NOT to use

  • The feature is already clear: go straight to its skill (table below)
  • Building a full app end to end, idea to production (use mastra-build-playbook)
  • Creating a new project or install problems (use mastra-project-setup)
  • An error message to fix (use mastra-troubleshooting)
  • Upgrading between Mastra versions (use mastra-migrations)

Required inputs

  • What the user is trying to build or fix, in one sentence
  • Whether a Mastra project exists (ls node_modules/@mastra/ and src/mastra/index.ts)
  • The installed @mastra/core version when the project exists

The framework: one instance, many primitives

A Mastra app is one Mastra instance that registers primitives. Registration wires in shared storage, logging, tracing, the server API, and Studio.

// src/mastra/index.ts
import { Mastra } from '@mastra/core'

export const mastra = new Mastra({
  agents: { supportAgent },        // open-ended, tool-using LLM loops
  workflows: { refundWorkflow },    // fixed multi-step processes
  scorers: { answerRelevancy },     // evals
  storage,                          // persistence for memory, runs, traces
  // plus: vectors, mcpServers, server, logger, observability, ...
})

Routing table

The user wants toUse skill
Start a project, configure new Mastra(), run mastra devmastra-project-setup
Build an app end to endmastra-build-playbook
An LLM that decides what to domastra-agents
Give an agent abilities (APIs, DB, code)mastra-tools
Typed JSON outputmastra-structured-output
Filter, redact, moderate, block prompt injectionmastra-processors-guardrails
Pause for approval or ask the usermastra-agent-approval-hitl
Several cooperating agentsmastra-multi-agent
Load task instructions on demand inside a Mastra agentmastra-agent-skills
Define agents as files instead of classesmastra-file-based-agents
Classify or route inputsmastra-classifier
Stream tokens, tool calls, and eventsmastra-streaming
Speech in or outmastra-voice
Pick a provider or model ID, fallbacks, gatewaysmastra-models
Fixed steps, branching, parallel, loopsmastra-workflows
Pause and resume a workflow, snapshots, time travelmastra-workflow-suspend-resume
Conversation history, threads, working memorymastra-memory
Recall older messages by meaningmastra-semantic-recall
Very long conversations without compactionmastra-observational-memory
Answer from documents with retrievalmastra-rag
Managed, scoped knowledge for agentsmastra-knowledge
Pick a database for storagemastra-storage
Pick a vector databasemastra-vector-stores
Work that outlives a request, durable agents, coding agentsmastra-harness
Run agents or workflows on a schedulemastra-schedules
Push events or state into a running threadmastra-signals
Filesystem, shell, code execution in isolationmastra-workspace-sandbox
Let an agent drive a browsermastra-browser
Use or expose MCP serversmastra-mcp
Agent to agent protocols (A2A, ACP)mastra-a2a-acp
Slack, Discord, Telegram, Teams, WhatsApp botsmastra-channels
Prebuilt search and scraping tools, Platform Connectmastra-tool-integrations
HTTP API, custom routes, middlewaremastra-server
Call Mastra from a frontend or another servicemastra-client-sdk
Embed Mastra in Next.js, Vite, SvelteKit, and othersmastra-framework-integration
Chat UI (AI SDK UI, assistant-ui, CopilotKit)mastra-agentic-ui
Protect the API, identify usersmastra-auth
Score output qualitymastra-evals
Datasets, experiments, CI gatesmastra-datasets-experiments
Traces, logs, metrics, costmastra-observability
Studio and the prompt Editormastra-studio-editor
Ship to a cloud or servermastra-deployment
Ship to Mastra Platformmastra-platform
Inspect or call a running server from the terminalmastra-cli-api
Fix an errormastra-troubleshooting
Upgrade versionsmastra-migrations

Workflow

  1. Verify the API. If node_modules/@mastra/ exists, read node_modules/@mastra/<package>/dist/docs/ and installed types. Otherwise fetch the live page as Markdown by appending .md (for example https://mastra.ai/docs/memory/overview.md). The full page index is https://mastra.ai/llms.txt. Trust these over memory. See references/api.md.
  2. Check for a native capability. Before designing custom infrastructure, search the routing table and docs index. Mastra often ships the feature (task tracking, web fetch, approvals, schedules, retries).
  3. Route. Open the matching skill and follow its workflow. Multi-feature requests chain skills (see references/examples.md).
  4. Build the smallest working slice. One agent or workflow, registered, callable.
  5. Test in Studio with npx mastra dev at http://localhost:4111, or call it with npx mastra api (mastra-cli-api).
  6. Add quality and visibility. Evals (mastra-evals) and tracing (mastra-observability) before production.
  7. Ship. mastra-deployment or mastra-platform.

Deep dive: choosing what goes into context

From Mastra's context engineering guide. Pick the mechanism by what the model needs to see.

NeedMechanismSkill
Stable identity, rulesAgent instructionsmastra-agents
Data from an API or DB on demandToolsmastra-tools
Current user or account dataInline in the message, or RequestContext for runtime configmastra-agents
Large stable knowledge baseRAGmastra-rag
User or org managed documentsFilesystem through a workspacemastra-workspace-sandbox
Recent conversation, durable factsMemorymastra-memory
Long-running conversationObservational memorymastra-observational-memory
Events during a runSignalsmastra-signals
Procedures needed only sometimesAgent skillsmastra-agent-skills
Too much contexttoModelOutput, ToolCallFilter, TokenLimiter, subagent messageFiltermastra-processors-guardrails, mastra-multi-agent

RequestContext values are runtime data. They are not added to the prompt automatically.


Failure patterns

  • Writing Mastra code from memory. APIs change between releases. Look up the page first.
  • Building custom infrastructure Mastra already has. Custom approval queues, cron runners, retry loops. Check the routing table and docs index first.
  • Using an agent for a fixed process. If the steps are known, a workflow is cheaper and more predictable.
  • Using a workflow for open-ended reasoning. If the steps depend on what the model finds, use an agent.
  • One giant agent with every tool. Split by responsibility into subagents.
  • Stuffing everything into instructions. Move per-request data, documents, and history into the right mechanism.
  • Unregistered primitives. Anything not on new Mastra({...}) misses storage, tracing, Studio, and the API.

Output format

A routing answer contains:

  • The feature(s) that solve the request and why
  • The skill(s) to apply, in order
  • The docs URLs to verify against
  • When code follows: the files to create and where they register in src/mastra/index.ts

Reference files

  • references/api.md - Docs lookup protocol: embedded docs, llms.txt, Markdown page URLs, packages map.
  • references/examples.md - Worked routing examples for common app types, with the skill chain for each.
  • references/checklist.md - Native-capability-first checklist before writing custom code.

Live docs

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.