Use when you have a written implementation plan to execute in a separate session with review checkpoints
npx skills add goldk3y/mastra-system-check
Or install specific skill: npx add-skill https://github.com/goldk3y/mastra-system-check
# Description
>
# SKILL.md
name: mastra-system-check
description: >
Comprehensive system check for Mastra AI agent projects. Validates configuration,
agents, workflows, memory, tools, prompts, and security across 66 rules organized
by priority. Use when setting up new projects, debugging issues, reviewing code,
or preparing for production deployment.
license: MIT
metadata:
author: stan
x: "https://x.com/goldkey"
version: "1.1.0"
Mastra System Check
Validates Mastra AI agent projects with 66 checks across 10 categories.
Finds configuration errors, missing best practices, and potential issues before they cause problems.
Trigger Keywords
Activate this skill when the user mentions:
| Category | Example Phrases |
|---|---|
| General Check | "check my mastra project", "mastra system check", "validate mastra", "review my mastra code" |
| Setup Issues | "mastra not working", "agent won't start", "can't find mastra instance" |
| Memory Issues | "memory not persisting", "conversation lost", "agent forgets context" |
| Workflow Issues | "workflow stuck", "workflow not executing", "steps not running" |
| Context Issues | "context not propagating", "requestcontext empty", "can't access user data" |
| Deployment | "prepare for production", "production checklist", "deploy mastra" |
| Debugging | "debug mastra", "troubleshoot agent", "why is my agent..." |
Quick Checks (Run First)
Before deep analysis, verify these 4 common issues that cause most failures:
1. Storage Configured?
grep "storage:" src/mastra/index.ts
If missing β Add storage: new LibSQLStore({ url: "file:./mastra.db" })
2. API Keys Set?
cat .env | grep -E "(OPENAI|ANTHROPIC|GOOGLE)_API_KEY"
If missing β Add the required API key for the model provider being used
3. Model Format Correct?
grep -r "model:" src/mastra/ | grep -v "provider/"
All models must use provider/model-name format (e.g., openai/gpt-4o)
4. Workflows Committed?
grep -r "new Workflow" src/mastra/ -A 20 | grep "\.commit()"
Every workflow chain must end with .commit()
If any quick check fails, fix it before proceeding with full analysis.
Execution Steps
When this skill activates, follow these steps IN ORDER:
Step 1: Locate Entry Point
# Find the main Mastra instance
cat src/mastra/index.ts
Verify: Named export mastra exists with proper configuration.
Step 2: Check Dependencies
# Verify required packages
cat package.json | grep -E "@mastra|zod|@ai-sdk"
Required: @mastra/core. Check Zod is v4+ for schema compatibility.
Step 3: Scan for Agents
grep -rn "new Agent" src/
For each agent found, check: id, model format, instructions, tools, memory.
Step 4: Scan for Workflows
grep -rn "new Workflow" src/
For each workflow, check: .commit() called, steps connected, schemas defined.
Step 5: Check Configuration Files
.env/.env.localβ API keys presenttsconfig.jsonβ Module ES2022+, moduleResolution bundler/node16
Step 6: Run Category Checks
Apply rules from AGENTS.md in this priority order:
1. π΄ CRITICAL (config-) - Fix immediately
2. π HIGH (agent-, workflow-, context-, prompt-) - Fix before deployment
3. π‘ MEDIUM (memory-, tool-, security-) - Fix when possible
4. π’ LOW (optimization-*) - Nice to have
Step 7: Report Findings
Present issues sorted by priority with specific file locations and fixes.
File Patterns to Check
| Pattern | Purpose | Priority |
|---|---|---|
src/mastra/index.ts |
Main Mastra instance, storage, agents | CRITICAL |
src/mastra/agents/*.ts |
Agent definitions | HIGH |
src/mastra/workflows/*.ts |
Workflow definitions | HIGH |
src/mastra/tools/*.ts |
Tool definitions | MEDIUM |
package.json |
Dependencies, versions | CRITICAL |
tsconfig.json |
TypeScript module config | CRITICAL |
.env / .env.local |
API keys, secrets | CRITICAL |
src/**/middleware*.ts |
RequestContext setup | HIGH |
Priority Legend
| Badge | Level | Meaning | Action |
|---|---|---|---|
| π΄ | CRITICAL | System won't function | Fix immediately |
| π | HIGH | Major functionality issues | Fix before deployment |
| π‘ | MEDIUM | Quality/maintainability | Fix when possible |
| π’ | LOW | Performance/cost optimization | Nice to have |
Check Categories Summary
| Category | Rules | Priority | Key Checks |
|---|---|---|---|
| Configuration | 6 | π΄ CRITICAL | Storage, env vars, TypeScript, entry point |
| Agents | 6 | π HIGH | Model format, instructions, tools, memory |
| Workflows | 6 | π HIGH | .commit(), schemas, connections, suspend |
| Context | 8 | π HIGH | RequestContext typing, propagation, access |
| Prompts | 10 | π HIGH | Token efficiency, structure, examples |
| Memory | 6 | π‘ MEDIUM | Storage, threads, vector stores |
| Tools | 6 | π‘ MEDIUM | Schemas, descriptions, error handling |
| Observability | 6 | π‘ MEDIUM* | Tracing, scorers, exporters |
| Security | 6 | π‘ MEDIUM | Auth, CORS, PII, secrets |
| Optimization | 6 | π’ LOW | Model selection, caching, timeouts |
Total: 66 rules across 10 categories
*Observability checks are conditional - only apply if telemetry/evals are configured.
Output Format
For each issue found, report in this format:
### π΄ CRITICAL Issues (count)
**[rule-id] Rule Name**
- **Location:** `file/path.ts:lineNumber`
- **Issue:** Clear description of what's wrong
- **Fix:**
```typescript
// Corrected code example
```
- **Docs:** https://mastra.ai/docs/relevant-section
Example Output
## Mastra System Check Results
**Project:** my-mastra-app
**Scanned:** 12 files
**Duration:** 2.3s
---
### π΄ CRITICAL Issues (2)
**[config-storage-provider] Missing Storage Provider**
- **Location:** `src/mastra/index.ts:8`
- **Issue:** No storage configured - memory, workflows, and traces won't persist
- **Fix:**
```typescript
import { LibSQLStore } from "@mastra/libsql";
export const mastra = new Mastra({
storage: new LibSQLStore({
url: process.env.DATABASE_URL || "file:./mastra.db",
}),
agents: { myAgent },
});
```
- **Docs:** https://mastra.ai/docs/storage
**[config-env-variables] Missing API Key**
- **Location:** `.env`
- **Issue:** OPENAI_API_KEY not set but `openai/gpt-4o` model is used
- **Fix:** Add to `.env`:
```bash
OPENAI_API_KEY=sk-your-key-here
```
---
### π HIGH Issues (1)
**[prompt-right-altitude] Under-specified Agent Instructions**
- **Location:** `src/mastra/agents/assistant.ts:12`
- **Issue:** Agent has minimal instructions: "You are a helpful assistant"
- **Fix:**
```typescript
instructions: `
<role>
You are a customer support agent for Acme Corp.
</role>
<capabilities>
- Answer product questions using search_products tool
- Check order status using order_lookup tool
</capabilities>
<guidelines>
- Be concise and helpful
- Escalate billing issues to human support
</guidelines>
`,
```
---
### π‘ MEDIUM Issues (0)
No medium-priority issues found.
---
### π’ LOW Issues (1)
**[optimization-model-selection] Expensive Model for Simple Task**
- **Location:** `src/mastra/agents/classifier.ts:6`
- **Issue:** Using `gpt-4o` for classification - `gpt-4o-mini` would be more cost-effective
- **Fix:** Change model to `openai/gpt-4o-mini` for simple classification tasks
---
### β
Summary
| Priority | Issues |
|----------|--------|
| π΄ CRITICAL | 2 |
| π HIGH | 1 |
| π‘ MEDIUM | 0 |
| π’ LOW | 1 |
**Passed: 62/66 checks**
**Next Steps:**
1. Fix CRITICAL issues immediately - system won't work without them
2. Address HIGH issues before deployment
3. Consider LOW optimizations to reduce costs
Conditional Checks
Some rules only apply in specific situations:
Observability Section (Conditional)
Only check if telemetry or observability is configured, or if evals/scorers are used.
// If you see this in the codebase, run observability checks:
telemetry: { enabled: true, ... }
// or
evals: { scorers: [...] }
If NOT configured: Skip observability section entirely - it's optional.
Memory Checks (Conditional)
Only check if agents have memory configured.
Workflow Storage (Conditional)
Only check if workflows use suspend() for human-in-the-loop.
Scope Limitations
This skill does NOT:
- β Deploy projects or run the dev server
- β Make changes without user approval
- β Check runtime behavior (static analysis only)
- β Validate external API integrations
- β Test actual LLM responses
- β Run the project's test suite
This skill DOES:
- β
Static code analysis
- β
Configuration validation
- β
Best practice review
- β
Security pattern detection
- β
Provide specific code fixes
Documentation Links
Include these when suggesting fixes:
| Topic | URL |
|---|---|
| Mastra Docs | https://mastra.ai/docs |
| Storage Setup | https://mastra.ai/docs/storage |
| Memory Guide | https://mastra.ai/docs/memory |
| Workflows | https://mastra.ai/docs/workflows |
| Agents | https://mastra.ai/docs/agents |
| Tools | https://mastra.ai/docs/tools |
| AI SDK | https://sdk.vercel.ai/docs |
Full Rules Reference
For complete details on all 66 rules with code examples and fixes, read AGENTS.md in this skill directory.
Common Fix Patterns
Missing Storage (Most Common)
import { LibSQLStore } from "@mastra/libsql";
export const mastra = new Mastra({
storage: new LibSQLStore({
url: process.env.DATABASE_URL || "file:./mastra.db",
}),
agents: { /* ... */ },
});
Wrong Model Format
// β Wrong
model: "gpt-4o"
// β
Correct
model: "openai/gpt-4o"
Missing Workflow Commit
// β Wrong
const workflow = new Workflow({ id: "my-flow" })
.step("step1", { execute: async () => ({ done: true }) });
// β
Correct
const workflow = new Workflow({ id: "my-flow" })
.step("step1", { execute: async () => ({ done: true }) })
.commit(); // Required!
Memory Without Thread/Resource
// β Wrong
await agent.generate("Hello");
// β
Correct
await agent.generate("Hello", {
memory: {
thread: `session-${sessionId}`,
resource: `user-${userId}`,
},
});
Version History
- 1.1.0 - Enhanced triggering, quick checks, execution steps, example output
- 1.0.0 - Initial release with 66 rules across 10 categories
# README.md
Mastra System Check

A comprehensive Claude Code skill for validating Mastra AI agent projects. This skill performs 66 checks across 10 categories to identify configuration issues, missing best practices, and potential problems before they cause runtime errors.
Installation
Option 1: npx (Recommended)
npx mastra-system-check
Option 2: One-line install
curl -fsSL https://raw.githubusercontent.com/goldk3y/mastra-system-check/main/install.sh | bash
Option 3: Git clone
git clone https://github.com/goldk3y/mastra-system-check.git ~/.claude/skills/mastra-system-check
Option 4: Manual
Download and copy this directory to:
~/.claude/skills/mastra-system-check/
Verification
The skill will automatically activate when working with Mastra projects. You can verify installation by asking Claude Code to perform a system check on your Mastra project.
What It Checks
Priority Levels
| Badge | Level | Description | Action |
|---|---|---|---|
| π΄ | CRITICAL | System won't function | Fix immediately |
| π | HIGH | Major functionality issues | Fix before deployment |
| π‘ | MEDIUM | Quality and maintainability | Fix when possible |
| π’ | LOW | Performance and cost | Nice to have |
Check Categories
| # | Category | Rules | Priority | Key Checks |
|---|---|---|---|---|
| 1 | Configuration & Setup | 6 | π΄ CRITICAL | Storage, env vars, TypeScript, entry points |
| 2 | Agent Configuration | 6 | π HIGH | Model format, instructions, tools, memory |
| 3 | Workflow Configuration | 6 | π HIGH | .commit(), schemas, steps, error handling |
| 4 | Context & Data Flow | 8 | π HIGH | Type safety, middleware, propagation |
| 5 | Prompt Engineering | 10 | π HIGH | Structure, token efficiency, examples |
| 6 | Memory Configuration | 6 | π‘ MEDIUM | Storage, threads, vector stores |
| 7 | Tool Configuration | 6 | π‘ MEDIUM | Schemas, descriptions, error handling |
| 8 | Observability & Evals | 6 | π‘ MEDIUM* | Tracing, exporters, scorers |
| 9 | Security & Guardrails | 6 | π‘ MEDIUM | Auth, CORS, PII, prompt injection |
| 10 | Performance & Optimization | 6 | π’ LOW | Model selection, caching, batching |
*Observability checks are conditional - only run if telemetry/evals are configured.
Usage
Trigger Keywords
The skill activates when you say any of these phrases:
| Category | Example Phrases |
|---|---|
| General Check | "check my mastra project", "mastra system check", "validate mastra" |
| Setup Issues | "mastra not working", "agent won't start", "can't find mastra instance" |
| Memory Issues | "memory not persisting", "conversation lost", "agent forgets context" |
| Workflow Issues | "workflow stuck", "workflow not executing", "steps not running" |
| Context Issues | "context not propagating", "requestcontext empty" |
| Deployment | "prepare for production", "production checklist", "deploy mastra" |
Quick Check Commands
Ask Claude to run specific checks:
Run a Mastra system check on this project
Check my Mastra agent configurations
Validate my workflow setup
Review my memory configuration for issues
Is my Mastra project ready for production?
Output Format
For each issue found:
### π΄ CRITICAL Issues (count)
**[rule-id] Rule Name**
- **Location:** `file/path.ts:lineNumber`
- **Issue:** Clear description of what's wrong
- **Fix:**
```typescript
// Corrected code example
```
- **Docs:** https://mastra.ai/docs/relevant-section
Quick Checks (Run First)
Before deep analysis, the skill verifies these 4 common issues that cause most failures:
| Check | Command | Fix |
|---|---|---|
| Storage configured? | grep "storage:" src/mastra/index.ts |
Add LibSQLStore |
| API keys set? | cat .env \| grep API_KEY |
Add to .env |
| Model format correct? | All models use provider/model-name |
Fix format |
| Workflows committed? | Every workflow ends with .commit() |
Add .commit() |
Most Common Issues
These are the issues most frequently caught by the system check:
- Missing storage provider - Memory and workflows won't persist
- Missing API keys - Agent calls fail at runtime
- Wrong model format - Should be
provider/model-name(e.g.,openai/gpt-4o) - No thread/resource in memory calls - Messages aren't tracked
- Untyped RequestContext - No type safety across components
- Security processors not first - PII stored before redaction
- Missing .commit() on workflows - Workflow won't execute
Quick Fixes
Essential Setup
// src/mastra/index.ts
import { Mastra } from "@mastra/core";
import { LibSQLStore } from "@mastra/libsql";
export const mastra = new Mastra({
storage: new LibSQLStore({
id: "mastra-storage",
url: process.env.DATABASE_URL || "file:./mastra.db",
}),
agents: { /* your agents */ },
});
Environment Variables
# .env
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
DATABASE_URL=file:./mastra.db
TypeScript Configuration
{
"compilerOptions": {
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "bundler",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true
}
}
Model Format
// β Wrong
model: "gpt-4o"
// β
Correct
model: "openai/gpt-4o"
Workflow Commit
// β Wrong - missing .commit()
const workflow = new Workflow({ id: "my-flow" })
.step("step1", { execute: async () => ({ done: true }) });
// β
Correct
const workflow = new Workflow({ id: "my-flow" })
.step("step1", { execute: async () => ({ done: true }) })
.commit(); // Required!
File Structure
mastra-system-check/
βββ SKILL.md # Skill metadata, triggers, and execution steps
βββ AGENTS.md # Complete 66-rule guide with examples
βββ metadata.json # Version and feature info
βββ README.md # This file
βββ assets/
β βββ banner.png # Header image
βββ bin/
β βββ install.js # npx installer
βββ install.sh # Shell installer
βββ rules/
βββ _sections.md # Category hierarchy
βββ _template.md # Template for new rules
βββ config-*.md # Configuration checks (CRITICAL)
βββ agent-*.md # Agent checks (HIGH)
βββ workflow-*.md # Workflow checks (HIGH)
βββ context-*.md # Context checks (HIGH)
βββ prompt-*.md # Prompt checks (HIGH)
βββ memory-*.md # Memory checks (MEDIUM)
βββ tool-*.md # Tool checks (MEDIUM)
βββ observability-*.md # Observability checks (MEDIUM)
βββ security-*.md # Security checks (MEDIUM)
βββ optimization-*.md # Optimization checks (LOW)
Version History
| Version | Changes |
|---|---|
| 1.1.0 | Enhanced skill activation with keyword triggers, quick checks, explicit execution steps, improved output format with examples |
| 1.0.0 | Initial release with 66 rules across 10 categories |
Contributing
To add new rules:
- Copy
rules/_template.mdto a new file with the appropriate prefix - Fill in the frontmatter (title, impact, tags, category)
- Write clear "What to Check", "Incorrect", "Correct", and "How to Fix" sections
- Update
rules/_sections.mdif adding a new category
References
License
MIT
# Supported AI Coding Agents
This skill is compatible with the SKILL.md standard and works with all major AI coding agents:
Learn more about the SKILL.md standard and how to use these skills with your preferred AI coding agent.