← Back to list

mastra-agent-creation
by ffMathy
My digital assistant that runs the house.
⭐ 2🍴 0📅 Jan 24, 2026
SKILL.md
name: mastra-agent-creation description: Guide for creating new Mastra agents in the Hey Jarvis MCP project. Use this when asked to create a new agent or vertical.
Creating Mastra Agents
Use the Hey Jarvis factory pattern for creating all agents.
Factory Function
CRITICAL: ALWAYS use createAgent() from ../../utils/agent-factory
Never use Mastra's constructors directly.
Basic Pattern
// In verticals/[vertical]/agent.ts
import { createAgent } from '../../utils/agent-factory';
import { myTools } from './tools';
export async function getMyAgent(): Promise<Agent> {
return createAgent({
name: 'MyAgent',
instructions: 'You are a helpful agent that...',
tools: myTools,
// memory and model (gemini-flash-latest) automatically provided
});
}
What the Factory Provides
The factory automatically includes:
- Model:
gemini-flash-latestfrom Google - Memory: Shared LibSQL storage
- Error Reporting: Automatic GitHub issue creation on errors
- Observability: AI tracing and token usage tracking
- Scorers: Quality evaluation (answer-relevancy, hallucination, etc.)
File Structure
When creating a new vertical:
mastra/verticals/[vertical-name]/
├── agent.ts # Single agent (if simple)
├── agents.ts # Multiple agents (if complex)
├── tools.ts # All tools for this vertical
├── workflows.ts # All workflows
└── index.ts # Export everything
Naming Conventions
- General agents:
[vertical]Agent(e.g.,weatherAgent) - Specialized agents:
[vertical][Purpose]Agent(e.g.,mealPlanSelectorAgent) - Export function:
get[Agent](e.g.,getWeatherAgent)
Steps to Add New Agent
- Create vertical directory:
mkdir -p mastra/verticals/[name] - Create tools: Define tools in
tools.ts - Create agent: Use factory in
agent.ts - Export: Add exports to
index.ts - Register: Update
mastra/verticals/index.ts - Register in Mastra: Add to
mastra/index.ts - Document: Update
mcp/AGENTS.md
Example Registration
// In mastra/index.ts
import { getMyAgent } from './verticals';
export const mastra = new Mastra({
agents: {
myAgent: await getMyAgent(),
},
});
What NOT to Do
❌ Never import from @mastra/core/agent directly
❌ Never create agents without the factory
❌ Never skip memory or model configuration
Score
Total Score
60/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon