@balazsbarta/mp-skills 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/.agents/skills/brainstorming/SKILL.md +201 -0
  2. package/.agents/skills/brainstorming/references/option-evaluation.md +64 -0
  3. package/.agents/skills/brainstorming/references/questioning-playbook.md +57 -0
  4. package/.agents/skills/brainstorming/references/repo-analysis.md +60 -0
  5. package/.agents/skills/conventional-commits/SKILL.md +124 -0
  6. package/.agents/skills/conventional-commits/references/commit-types-scopes.md +75 -0
  7. package/.agents/skills/conventional-commits/references/semantic-release.md +71 -0
  8. package/.agents/skills/jest/SKILL.md +219 -0
  9. package/.agents/skills/jest/references/common-errors.md +274 -0
  10. package/.agents/skills/jest/references/configuration.md +175 -0
  11. package/.agents/skills/jest/references/embedded-docs.md +44 -0
  12. package/.agents/skills/jest/references/mocking.md +206 -0
  13. package/.agents/skills/jest/references/remote-docs.md +19 -0
  14. package/.agents/skills/jest/references/snapshot-testing.md +181 -0
  15. package/.agents/skills/jest/references/transforms.md +216 -0
  16. package/.agents/skills/maestro/SKILL.md +230 -0
  17. package/.agents/skills/maestro/references/assertions-commands.md +259 -0
  18. package/.agents/skills/maestro/references/common-errors.md +273 -0
  19. package/.agents/skills/maestro/references/eas-ci-integration.md +219 -0
  20. package/.agents/skills/maestro/references/flow-authoring.md +224 -0
  21. package/.agents/skills/maestro/references/remote-docs.md +23 -0
  22. package/.agents/skills/mastra/SKILL.md +159 -0
  23. package/.agents/skills/mastra/references/common-errors.md +535 -0
  24. package/.agents/skills/mastra/references/create-mastra.md +220 -0
  25. package/.agents/skills/mastra/references/embedded-docs.md +123 -0
  26. package/.agents/skills/mastra/references/migration-guide.md +180 -0
  27. package/.agents/skills/mastra/references/remote-docs.md +193 -0
  28. package/.agents/skills/next-js/SKILL.md +209 -0
  29. package/.agents/skills/next-js/references/api-routes.md +213 -0
  30. package/.agents/skills/next-js/references/app-router.md +206 -0
  31. package/.agents/skills/next-js/references/caching-revalidation.md +211 -0
  32. package/.agents/skills/next-js/references/common-errors.md +251 -0
  33. package/.agents/skills/next-js/references/embedded-docs.md +43 -0
  34. package/.agents/skills/next-js/references/metadata-seo.md +257 -0
  35. package/.agents/skills/next-js/references/remote-docs.md +22 -0
  36. package/.agents/skills/playwright/SKILL.md +218 -0
  37. package/.agents/skills/playwright/references/ci-configuration.md +208 -0
  38. package/.agents/skills/playwright/references/common-errors.md +258 -0
  39. package/.agents/skills/playwright/references/embedded-docs.md +41 -0
  40. package/.agents/skills/playwright/references/fixtures-assertions.md +208 -0
  41. package/.agents/skills/playwright/references/page-objects.md +167 -0
  42. package/.agents/skills/playwright/references/remote-docs.md +23 -0
  43. package/.agents/skills/playwright/references/visual-regression.md +206 -0
  44. package/.agents/skills/pull-request-lifecycle/SKILL.md +116 -0
  45. package/.agents/skills/pull-request-lifecycle/references/changelog-versioning.md +72 -0
  46. package/.agents/skills/pull-request-lifecycle/references/merge-strategies.md +33 -0
  47. package/.agents/skills/pull-request-lifecycle/references/pr-description-template.md +72 -0
  48. package/.agents/skills/pull-request-lifecycle/references/review-process.md +54 -0
  49. package/.agents/skills/pull-request-lifecycle/scripts/code_review.py +220 -0
  50. package/.agents/skills/react-native-expo/SKILL.md +212 -0
  51. package/.agents/skills/react-native-expo/references/common-errors.md +251 -0
  52. package/.agents/skills/react-native-expo/references/eas-build-submit.md +238 -0
  53. package/.agents/skills/react-native-expo/references/embedded-docs.md +42 -0
  54. package/.agents/skills/react-native-expo/references/native-modules.md +181 -0
  55. package/.agents/skills/react-native-expo/references/navigation-setup.md +229 -0
  56. package/.agents/skills/react-native-expo/references/remote-docs.md +23 -0
  57. package/.agents/skills/supabase/SKILL.md +216 -0
  58. package/.agents/skills/supabase/references/auth-setup.md +206 -0
  59. package/.agents/skills/supabase/references/common-errors.md +285 -0
  60. package/.agents/skills/supabase/references/edge-functions.md +178 -0
  61. package/.agents/skills/supabase/references/embedded-docs.md +43 -0
  62. package/.agents/skills/supabase/references/migrations.md +193 -0
  63. package/.agents/skills/supabase/references/remote-docs.md +24 -0
  64. package/.agents/skills/supabase/references/rls-policies.md +187 -0
  65. package/.agents/skills/supabase/references/storage.md +182 -0
  66. package/.agents/skills/task-breakdown/SKILL.md +179 -0
  67. package/.agents/skills/task-breakdown/references/acceptance-criteria.md +165 -0
  68. package/.agents/skills/task-breakdown/references/epic-story-format.md +209 -0
  69. package/.agents/skills/task-breakdown/references/estimation-guide.md +140 -0
  70. package/.agents/skills/vitest/SKILL.md +219 -0
  71. package/.agents/skills/vitest/references/common-errors.md +271 -0
  72. package/.agents/skills/vitest/references/component-testing.md +182 -0
  73. package/.agents/skills/vitest/references/configuration.md +184 -0
  74. package/.agents/skills/vitest/references/coverage.md +179 -0
  75. package/.agents/skills/vitest/references/embedded-docs.md +43 -0
  76. package/.agents/skills/vitest/references/mocking.md +182 -0
  77. package/.agents/skills/vitest/references/remote-docs.md +22 -0
  78. package/README.md +235 -0
  79. package/package.json +20 -0
  80. package/scripts/skills.mjs +849 -0
@@ -0,0 +1,159 @@
1
+ ---
2
+ name: mastra
3
+ description: "Comprehensive Mastra framework guide. Teaches how to find current documentation, verify API signatures, and build agents and workflows. Covers documentation lookup strategies (embedded docs, remote docs), core concepts (agents vs workflows, tools, memory, RAG), TypeScript requirements, and common patterns. Use this skill for all Mastra development to ensure you're using current APIs from the installed version or latest documentation."
4
+ license: MIT
5
+ metadata:
6
+ author: Mastra
7
+ version: "2.0.0"
8
+ repository: https://github.com/mastra-ai/skills
9
+ ---
10
+
11
+ # Mastra Framework Guide
12
+
13
+ Build AI applications with Mastra. This skill teaches you how to find current documentation and build agents and workflows.
14
+
15
+ ## ⚠️ Critical: Do not trust internal knowledge
16
+
17
+ **Everything you know about Mastra is likely outdated or wrong. Never rely on memory. Always verify against current documentation.**
18
+
19
+ Your training data contains obsolete APIs, deprecated patterns, and incorrect usage. Mastra evolves rapidly - APIs change between versions, constructor signatures shift, and patterns get refactored.
20
+
21
+ ## Prerequisites
22
+
23
+ **Before writing any Mastra code**, check if packages are installed:
24
+
25
+ ```bash
26
+ ls node_modules/@mastra/
27
+ ```
28
+
29
+ - **If packages exist:** Use embedded docs first (most reliable)
30
+ - **If no packages:** Install first or use remote docs
31
+
32
+ ## Documentation lookup guide
33
+
34
+ ### Quick Reference
35
+
36
+ | User Question | First Check | How To |
37
+ | ----------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------- |
38
+ | "Create/install Mastra project" | [`references/create-mastra.md`](references/create-mastra.md) | Setup guide with CLI and manual steps |
39
+ | "How do I use Agent/Workflow/Tool?" | [`references/embedded-docs.md`](references/embedded-docs.md) | Look up in `node_modules/@mastra/*/dist/docs/` |
40
+ | "How do I use X?" (no packages) | [`references/remote-docs.md`](references/remote-docs.md) | Fetch from `https://mastra.ai/llms.txt` |
41
+ | "I'm getting an error..." | [`references/common-errors.md`](references/common-errors.md) | Common errors and solutions |
42
+ | "Upgrade from v0.x to v1.x" | [`references/migration-guide.md`](references/migration-guide.md) | Version upgrade workflows |
43
+
44
+ ### Priority order for writing code
45
+
46
+ ⚠️ **Never write code without checking current docs first**
47
+
48
+ 1. **Embedded docs first** (if packages installed)
49
+
50
+ ```bash
51
+ # Check what's available
52
+ cat node_modules/@mastra/core/dist/docs/SOURCE_MAP.json | grep '"Agent"'
53
+
54
+ # Read the actual type definition
55
+ cat node_modules/@mastra/core/dist/[path-from-source-map]
56
+ ```
57
+
58
+ - **Why:** Matches your EXACT installed version
59
+ - **Most reliable source of truth**
60
+ - **See:** [`references/embedded-docs.md`](references/embedded-docs.md)
61
+
62
+ 2. **Remote docs second** (if packages not installed)
63
+
64
+ ```bash
65
+ # Fetch latest docs
66
+ # https://mastra.ai/llms.txt
67
+ ```
68
+
69
+ - **Why:** Latest published docs (may be ahead of installed version)
70
+ - **Use when:** Packages not installed or exploring new features
71
+ - **See:** [`references/remote-docs.md`](references/remote-docs.md)
72
+
73
+ ## Core concepts
74
+
75
+ ### Agents vs workflows
76
+
77
+ **Agent**: Autonomous, makes decisions, uses tools
78
+ Use for: Open-ended tasks (support, research, analysis)
79
+
80
+ **Workflow**: Structured sequence of steps
81
+ Use for: Defined processes (pipelines, approvals, ETL)
82
+
83
+ ### Key components
84
+
85
+ - **Tools**: Extend agent capabilities (APIs, databases, external services)
86
+ - **Memory**: Maintain context (message history, working memory, semantic recall)
87
+ - **RAG**: Query external knowledge (vector stores, graph relationships)
88
+ - **Storage**: Persist data (Postgres, LibSQL, MongoDB)
89
+
90
+ ## Critical requirements
91
+
92
+ ### TypeScript config
93
+
94
+ Mastra requires **ES2022 modules**. CommonJS will fail.
95
+
96
+ ```json
97
+ {
98
+ "compilerOptions": {
99
+ "target": "ES2022",
100
+ "module": "ES2022",
101
+ "moduleResolution": "bundler"
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### Model format
107
+
108
+ Always use `"provider/model-name"`:
109
+
110
+ - `"openai/gpt-4o"`
111
+ - `"anthropic/claude-3-5-sonnet-20241022"`
112
+ - `"google/gemini-2.5-pro"`
113
+
114
+ ## When you see errors
115
+
116
+ **Type errors often mean your knowledge is outdated.**
117
+
118
+ **Common signs of outdated knowledge:**
119
+
120
+ - `Property X does not exist on type Y`
121
+ - `Cannot find module`
122
+ - `Type mismatch` errors
123
+ - Constructor parameter errors
124
+
125
+ **What to do:**
126
+
127
+ 1. Check [`references/common-errors.md`](references/common-errors.md)
128
+ 2. Verify current API in embedded docs
129
+ 3. Don't assume the error is a user mistake - it might be your outdated knowledge
130
+
131
+ ## Development workflow
132
+
133
+ **Always verify before writing code:**
134
+
135
+ 1. **Check packages installed**
136
+
137
+ ```bash
138
+ ls node_modules/@mastra/
139
+ ```
140
+
141
+ 2. **Look up current API**
142
+ - If installed → Use embedded docs [`references/embedded-docs.md`](references/embedded-docs.md)
143
+ - If not → Use remote docs [`references/remote-docs.md`](references/remote-docs.md)
144
+
145
+ 3. **Write code based on current docs**
146
+
147
+ 4. **Test in Studio**
148
+ ```bash
149
+ npm run dev # http://localhost:4111
150
+ ```
151
+
152
+ ## Resources
153
+
154
+ - **Setup**: [`references/create-mastra.md`](references/create-mastra.md)
155
+ - **Embedded docs lookup**: [`references/embedded-docs.md`](references/embedded-docs.md) - Start here if packages are installed
156
+ - **Remote docs lookup**: [`references/remote-docs.md`](references/remote-docs.md)
157
+ - **Common errors**: [`references/common-errors.md`](references/common-errors.md)
158
+ - **Migrations**: [`references/migration-guide.md`](references/migration-guide.md)
159
+ - **Official site**: https://mastra.ai (verify against embedded docs first)
@@ -0,0 +1,535 @@
1
+ # Common Errors and Troubleshooting
2
+
3
+ Comprehensive guide to common Mastra errors and their solutions.
4
+
5
+ ## Build and configuration errors
6
+
7
+ ### "Cannot find module" or import errors
8
+
9
+ **Symptoms**:
10
+
11
+ ```bash
12
+ Error: Cannot find module '@mastra/core'
13
+ SyntaxError: Cannot use import statement outside a module
14
+ ```
15
+
16
+ **Causes**:
17
+
18
+ - CommonJS configuration in `tsconfig.json`
19
+ - Missing `"type": "module"` in `package.json`
20
+ - Incorrect module resolution
21
+
22
+ **Solutions**:
23
+
24
+ 1. Update `tsconfig.json`:
25
+
26
+ ```json
27
+ {
28
+ "compilerOptions": {
29
+ "target": "ES2022",
30
+ "module": "ES2022",
31
+ "moduleResolution": "bundler"
32
+ }
33
+ }
34
+ ```
35
+
36
+ 2. Add to `package.json`:
37
+
38
+ ```json
39
+ {
40
+ "type": "module"
41
+ }
42
+ ```
43
+
44
+ 3. Ensure imports use `.js` extensions for local files (if needed by your bundler)
45
+
46
+ ### "Property X does not exist on type Y"
47
+
48
+ **Symptoms**:
49
+
50
+ ```bash
51
+ Property 'tools' does not exist on type 'Agent'
52
+ Property 'memory' does not exist on type 'AgentConfig'
53
+ ```
54
+
55
+ **Causes**:
56
+
57
+ - Outdated API usage (Mastra is actively developed)
58
+ - Incorrect import or type
59
+ - Version mismatch between docs and installed package
60
+
61
+ **Solutions**:
62
+
63
+ 1. Check embedded docs (see `embedded-docs.md`) to check current API
64
+ 2. Check `node_modules/@mastra/core/dist/docs/SOURCE_MAP.json` for current exports
65
+ 3. Verify package versions: `npm list @mastra/core`
66
+ 4. Update dependencies: `npm update @mastra/core`
67
+
68
+ ## Agent errors
69
+
70
+ ### Agent not using assigned tools
71
+
72
+ **Symptoms**:
73
+
74
+ - Agent responds "I don't have access to that tool"
75
+ - Tools never get called despite being relevant
76
+
77
+ **Causes**:
78
+
79
+ - Tools not registered in Mastra instance
80
+ - Tools not passed to Agent constructor
81
+ - Tool IDs don't match
82
+
83
+ **Solutions**:
84
+
85
+ **Correct pattern**:
86
+
87
+ ```typescript
88
+ // 1. Create tool
89
+ const weatherTool = createTool({
90
+ id: "get-weather",
91
+ // ... tool config
92
+ });
93
+
94
+ // 2. Register in Mastra instance
95
+ const mastra = new Mastra({
96
+ tools: {
97
+ weatherTool, // or 'weatherTool': weatherTool
98
+ },
99
+ });
100
+
101
+ // 3. Assign to agent
102
+ const agent = new Agent({
103
+ id: "weather-agent",
104
+ tools: { weatherTool }, // Reference the tool
105
+ // ... other config
106
+ });
107
+ ```
108
+
109
+ **Alternative pattern (direct assignment)**:
110
+
111
+ ```typescript
112
+ const agent = new Agent({
113
+ id: "weather-agent",
114
+ tools: {
115
+ weatherTool: createTool({ id: "get-weather" /* ... */ }),
116
+ },
117
+ });
118
+ ```
119
+
120
+ ### Agent memory not persisting
121
+
122
+ **Symptoms**:
123
+
124
+ - Agent doesn't remember previous messages
125
+ - Conversation history is lost between calls
126
+
127
+ **Causes**:
128
+
129
+ - No storage backend configured
130
+ - Missing or inconsistent `threadId`
131
+ - Memory not assigned to agent
132
+
133
+ **Solutions**:
134
+
135
+ ```typescript
136
+ // 1. Configure storage
137
+ const storage = new PostgresStore({
138
+ connectionString: process.env.DATABASE_URL,
139
+ });
140
+
141
+ // 2. Create memory with storage
142
+ const memory = new Memory({
143
+ id: "chat-memory",
144
+ storage,
145
+ options: {
146
+ lastMessages: 10, // How many messages to retrieve
147
+ },
148
+ });
149
+
150
+ // 3. Assign memory to agent
151
+ const agent = new Agent({
152
+ id: "chat-agent",
153
+ memory,
154
+ });
155
+
156
+ // 4. Use consistent threadId
157
+ await agent.generate("Hello", {
158
+ threadId: "user-123-conversation", // Same threadId for entire conversation
159
+ resourceId: "user-123",
160
+ });
161
+ ```
162
+
163
+ ## Workflow errors
164
+
165
+ ### "Cannot read property 'then' of undefined"
166
+
167
+ **Symptoms**:
168
+
169
+ ```bash
170
+ TypeError: Cannot read property 'then' of undefined
171
+ Workflow execution fails immediately
172
+ ```
173
+
174
+ **Causes**:
175
+
176
+ - Forgot to call `.commit()` on workflow
177
+ - Step returns undefined
178
+
179
+ **Solutions**:
180
+
181
+ **Correct pattern**:
182
+
183
+ ```typescript
184
+ const workflow = createWorkflow({
185
+ id: "my-workflow",
186
+ inputSchema: z.object({ data: z.string() }),
187
+ outputSchema: z.object({ result: z.string() }),
188
+ })
189
+ .then(step1)
190
+ .then(step2)
191
+ .commit(); // REQUIRED!
192
+
193
+ // Then execute
194
+ const run = await workflow.createRun();
195
+ const result = await run.start({ inputData: { data: "test" } });
196
+ ```
197
+
198
+ ### Workflow state not updating
199
+
200
+ **Symptoms**:
201
+
202
+ - State changes don't persist across steps
203
+ - `getStepResult()` returns undefined
204
+
205
+ **Causes**:
206
+
207
+ - Not using `setState` to update state
208
+ - Accessing state before step completes
209
+
210
+ **Solutions**:
211
+
212
+ ```typescript
213
+ const step1 = createStep({
214
+ id: "step1",
215
+ execute: async ({ state, setState }) => {
216
+ // Update state
217
+ await setState({ ...state, counter: (state.counter || 0) + 1 });
218
+ return { result: "done" };
219
+ },
220
+ });
221
+
222
+ // Access state in subsequent steps
223
+ const step2 = createStep({
224
+ id: "step2",
225
+ execute: async ({ state }) => {
226
+ console.log(state.counter); // Access updated state
227
+ return { result: "complete" };
228
+ },
229
+ });
230
+ ```
231
+
232
+ ## Memory errors
233
+
234
+ ### "Storage is required for Memory"
235
+
236
+ **Symptoms**:
237
+
238
+ ```bash
239
+ Error: Storage is required for Memory
240
+ Memory instantiation fails
241
+ ```
242
+
243
+ **Causes**:
244
+
245
+ - Memory created without storage backend
246
+
247
+ **Solutions**:
248
+
249
+ ```typescript
250
+ // Always provide storage when creating Memory
251
+ const memory = new Memory({
252
+ id: "my-memory",
253
+ storage: postgresStore, // REQUIRED
254
+ options: {
255
+ lastMessages: 10,
256
+ },
257
+ });
258
+ ```
259
+
260
+ ### Semantic recall not working
261
+
262
+ **Symptoms**:
263
+
264
+ - Memory doesn't retrieve semantically similar messages
265
+ - Only recent messages are returned
266
+
267
+ **Causes**:
268
+
269
+ - No vector store configured
270
+ - No embedder configured
271
+ - `semanticRecall` not enabled
272
+
273
+ **Solutions**:
274
+
275
+ ```typescript
276
+ const memory = new Memory({
277
+ id: "semantic-memory",
278
+ storage: postgresStore,
279
+ vector: chromaVectorStore, // REQUIRED for semantic recall
280
+ embedder: openaiEmbedder, // REQUIRED for semantic recall
281
+ options: {
282
+ lastMessages: 10,
283
+ semanticRecall: true, // REQUIRED
284
+ },
285
+ });
286
+ ```
287
+
288
+ ## Tool errors
289
+
290
+ ### "Tool validation failed"
291
+
292
+ **Symptoms**:
293
+
294
+ ```bash
295
+ Error: Input validation failed for tool 'my-tool'
296
+ ZodError: Expected string, received number
297
+ ```
298
+
299
+ **Causes**:
300
+
301
+ - Input doesn't match inputSchema
302
+ - Missing required fields
303
+ - Type mismatch
304
+
305
+ **Solutions**:
306
+
307
+ ```typescript
308
+ const tool = createTool({
309
+ id: "my-tool",
310
+ inputSchema: z.object({
311
+ name: z.string(),
312
+ age: z.number().optional(), // Make optional fields explicit
313
+ }),
314
+ execute: async (input) => {
315
+ // input is validated and typed
316
+ return { result: `Hello ${input.name}` };
317
+ },
318
+ });
319
+
320
+ // Correct usage
321
+ await tool.execute({ name: "Alice" }); // Works
322
+ await tool.execute({ name: "Bob", age: 30 }); // Works
323
+ await tool.execute({ age: 30 }); // ERROR: name is required
324
+ ```
325
+
326
+ ### Tool suspension not resuming
327
+
328
+ **Symptoms**:
329
+
330
+ - Tool suspends but never resumes
331
+ - resumeData is undefined
332
+
333
+ **Causes**:
334
+
335
+ - Not calling workflow.resume() or agent.generate() with resumeData
336
+ - Incorrect resumeSchema
337
+
338
+ **Solutions**:
339
+
340
+ ```typescript
341
+ const approvalTool = createTool({
342
+ id: "approval",
343
+ inputSchema: z.object({ request: z.string() }),
344
+ outputSchema: z.object({ approved: z.boolean() }),
345
+ suspendSchema: z.object({ requestId: z.string() }),
346
+ resumeSchema: z.object({ approved: z.boolean() }),
347
+ execute: async (input, context) => {
348
+ if (!context.resumeData) {
349
+ // First call - suspend
350
+ const requestId = generateId();
351
+ context.suspend({ requestId });
352
+ return; // Execution pauses here
353
+ }
354
+
355
+ // Resumed - use resumeData
356
+ return { approved: context.resumeData.approved };
357
+ },
358
+ });
359
+
360
+ // Resume the workflow/agent
361
+ await run.resume({
362
+ resumeData: { approved: true },
363
+ });
364
+ ```
365
+
366
+ ## Storage errors
367
+
368
+ ### "Connection refused" or "Database does not exist"
369
+
370
+ **Symptoms**:
371
+
372
+ ```bash
373
+ Error: connect ECONNREFUSED 127.0.0.1:5432
374
+ Error: database "mastra" does not exist
375
+ ```
376
+
377
+ **Causes**:
378
+
379
+ - Database not running
380
+ - Incorrect connection string
381
+ - Database not created
382
+
383
+ **Solutions**:
384
+
385
+ 1. Start database (Postgres example):
386
+
387
+ ```bash
388
+ docker run -d \
389
+ --name mastra-postgres \
390
+ -e POSTGRES_PASSWORD=password \
391
+ -e POSTGRES_DB=mastra \
392
+ -p 5432:5432 \
393
+ postgres:16
394
+ ```
395
+
396
+ 2. Verify connection string:
397
+
398
+ ```env
399
+ DATABASE_URL=postgresql://postgres:password@localhost:5432/mastra
400
+ ```
401
+
402
+ 3. Initialize storage:
403
+
404
+ ```typescript
405
+ const storage = new PostgresStore({
406
+ connectionString: process.env.DATABASE_URL,
407
+ });
408
+ await storage.init(); // Creates tables if needed
409
+ ```
410
+
411
+ ## Environment variable errors
412
+
413
+ ### "API key not found"
414
+
415
+ **Symptoms**:
416
+
417
+ ```bash
418
+ Error: OPENAI_API_KEY environment variable is not set
419
+ 401 Unauthorized
420
+ ```
421
+
422
+ **Causes**:
423
+
424
+ - Missing .env file
425
+ - Environment variables not loaded
426
+ - Incorrect variable name
427
+
428
+ **Solutions**:
429
+
430
+ 1. Create .env file:
431
+
432
+ ```env
433
+ OPENAI_API_KEY=sk-...
434
+ ANTHROPIC_API_KEY=sk-ant-...
435
+ GOOGLE_GENERATIVE_AI_API_KEY=...
436
+ ```
437
+
438
+ 2. Load environment variables (for Node.js):
439
+
440
+ ```typescript
441
+ import "dotenv/config"; // At top of entry file
442
+ ```
443
+
444
+ 3. Verify variable is loaded:
445
+
446
+ ```typescript
447
+ if (!process.env.OPENAI_API_KEY) {
448
+ throw new Error("OPENAI_API_KEY is required");
449
+ }
450
+ ```
451
+
452
+ ## Model errors
453
+
454
+ ### "Model not found" or "Invalid model"
455
+
456
+ **Symptoms**:
457
+
458
+ ```bash
459
+ Error: Model 'gpt-4' not found
460
+ Error: Invalid model format
461
+ ```
462
+
463
+ **Causes**:
464
+
465
+ - Incorrect model format (should be `provider/model`)
466
+ - Unsupported model
467
+ - Missing provider API key
468
+
469
+ **Solutions**:
470
+
471
+ **Correct model format**:
472
+
473
+ ```typescript
474
+ const agent = new Agent({
475
+ model: "openai/gpt-4o", // ✅ Correct
476
+ // NOT: model: 'gpt-4o' // ❌ Missing provider
477
+ });
478
+ ```
479
+
480
+ **Common models**:
481
+
482
+ - OpenAI: `openai/gpt-4o`, `openai/gpt-4o-mini`, `openai/gpt-4-turbo`
483
+ - Anthropic: `anthropic/claude-sonnet-4-5-20250929`, `anthropic/claude-opus-4-5`
484
+ - Google: `google/gemini-2.0-pro`, `google/gemini-2.0-flash`
485
+
486
+ **Use embedded docs to verify**:
487
+
488
+ ```bash
489
+ # Check supported models
490
+ ls node_modules/@mastra/core/dist/docs/
491
+ # See embedded-docs.md for lookup instructions
492
+ ```
493
+
494
+ ## Debugging tips
495
+
496
+ ### Enable verbose logging
497
+
498
+ ```typescript
499
+ const mastra = new Mastra({
500
+ logger: new PinoLogger({
501
+ name: "mastra",
502
+ level: "debug", // or 'trace' for even more detail
503
+ }),
504
+ });
505
+ ```
506
+
507
+ ### Test in Studio
508
+
509
+ ```bash
510
+ npm run dev
511
+ # Open http://localhost:4111
512
+ # Test agents and workflows interactively
513
+ ```
514
+
515
+ ### Check package versions
516
+
517
+ ```bash
518
+ npm list @mastra/core
519
+ npm list @mastra/memory
520
+ npm list @mastra/rag
521
+ ```
522
+
523
+ ### Validate TypeScript config
524
+
525
+ ```bash
526
+ npx tsc --showConfig
527
+ # Verify target: ES2022, module: ES2022
528
+ ```
529
+
530
+ ## Getting help
531
+
532
+ 1. **Check embedded docs**: Check embedded docs (see `embedded-docs.md`)
533
+ 2. **Search documentation**: [mastra.ai/docs](https://mastra.ai/docs)
534
+ 3. **Check version compatibility**: Ensure all @mastra packages are same version
535
+ 4. **File an issue**: [github.com/mastra-ai/mastra](https://github.com/mastra-ai/mastra)