This skill provides guidance on building agents and workflows using Mastra APIs. It emphasizes the importance of verifying documentation to avoid using outdated information.
$ npx skills add https://github.com/mastra-ai/skills --skill mastraThe Mastra Framework Guide skill provides official documentation and development guidance for building AI-powered applications using Mastra, a modern TypeScript framework for agent development. It offers progressive disclosure across multiple reference files covering project setup, embedded API documentation lookup from node_modules, remote documentation fetching, troubleshooting for common errors, and version migration workflows. Developers can install the skill via NPM or leverage the `.well-known` skills discovery standard for automatic integration. This skill helps teams quickly understand Mastra's core concepts and routes queries to the appropriate documentation resources based on development needs.
Install with npm using the provided command and refer to the documentation for guidance.
Build AI agents with Mastra framework.
Set up workflows for automation and efficiency.
Verify API usage against current documentation.
Troubleshoot common installation issues.
$ npx skills add https://github.com/mastra-ai/skills --skill mastragit clone https://github.com/mastra-ai/skillsCopy the install command above and run it in your terminal.
Launch Claude Code, Cursor, or your preferred AI coding agent.
Use the prompt template or examples below to test the skill.
Adapt the skill to your specific use case and workflow.
Provide a step-by-step guide for building an AI agent using Mastra Framework for [COMPANY]'s [INDUSTRY] workflows. Focus on best practices for API integration, agent design, and workflow automation. Verify the latest Mastra documentation before proceeding and highlight any deprecated features to avoid. Include code snippets or configuration examples where applicable.
### Building an AI Agent for Customer Support with Mastra Framework
#### **Step 1: Setup and Authentication**
First, ensure you have the latest Mastra SDK installed:
```bash
pip install mastra-sdk --upgrade
```
Next, authenticate using your API key:
```python
from mastra import MastraClient
client = MastraClient(api_key="your_api_key_here")
```
*Verify the [Mastra Authentication Docs](https://docs.mastra.ai/auth) for the latest token expiration policies.*
#### **Step 2: Define the Agent Workflow**
Design a workflow for handling customer support queries. Use the `Workflow` class to structure the agent:
```python
from mastra.workflows import Workflow
support_workflow = Workflow(
name="Customer Support Agent",
description="Handles customer queries and routes to appropriate teams.",
steps=[
{"name": "intake", "type": "input", "handler": "text_input"},
{"name": "classify", "type": "llm", "model": "gpt-4", "prompt": "Classify the query as billing, technical, or general."},
{"name": "route", "type": "conditional", "conditions": {"billing": "billing_team", "technical": "tech_team"}}
]
)
```
#### **Step 3: Integrate External Tools**
Add tools like a CRM lookup or email sender. Example:
```python
from mastra.tools import HttpTool
crm_lookup = HttpTool(
name="CRM Lookup",
url="https://api.[COMPANY].com/crm",
method="GET",
auth="bearer_token"
)
support_workflow.add_tool(crm_lookup)
```
#### **Step 4: Deploy and Monitor**
Deploy the agent using Mastra’s CLI:
```bash
mastra deploy --workflow support_workflow.yaml
```
Monitor performance via the Mastra Dashboard and adjust workflows based on feedback.Take a free 3-minute scan and get personalized AI skill recommendations.
Take free scan