📦

mastra

Sûr

使用 Mastra 框架構建 AI 應用程式

Mastra 是用於構建 AI 代理和工作流程的 TypeScript 框架。本技能提供全面的文檔查詢策略和代碼模式,確保您使用當前的 API 並避免常見錯誤。

Prend en charge: Claude Codex Code(CC)
🥉 76 Bronze
1

Télécharger le ZIP du skill

2

Importer dans Claude

Allez dans Paramètres → Capacités → Skills → Importer un skill

3

Activez et commencez à utiliser

Tester

Utilisation de "mastra". How do I set up a new Mastra project?

Résultat attendu:

要設置新的 Mastra 項目:1) 運行 `npm create mastra@latest` 或使用 `npm init` 手動創建。2) 使用 ES2022 模塊配置 TypeScript(target: ES2022, module: ES2022, moduleResolution: bundler)。3) 在 package.json 中添加 'type: module'。4) 安裝 @mastra/core。有關完整設置說明,請參閱 references/create-mastra.md。

Utilisation de "mastra". What is the correct pattern for creating an agent with tools?

Résultat attendu:

正確的模式:1) 使用 createTool() 建立工具。2) 在您的 Mastra 實例的工具配置下註冊它。3) 將工具傳遞給您的 Agent 構造函數。示例:`const agent = new Agent({ id: 'my-agent', tools: { myTool } })`。有關完整代碼示例,請參閱 references/common-errors.md。

Utilisation de "mastra". How do I look up current Mastra API documentation?

Résultat attendu:

優先順序:1) 如果已安裝套件,檢查 node_modules/@mastra/*/dist/docs/ 中的嵌入文檔。2) 如果未安裝套件,從 https://mastra.ai/llms.txt 獲取遠程文檔。3) 使用 SOURCE_MAP.json 找到精確的類型定義。永遠不要依賴訓練數據——始終驗證當前的文檔。

Audit de sécurité

Sûr
v1 • 2/15/2026

This is a documentation/reference skill providing guidance on the Mastra framework. All static findings are false positives: (1) Backtick patterns are markdown code block delimiters in documentation, not shell commands. (2) Hardcoded URLs are legitimate documentation links. (3) Environment variable patterns are code examples showing configuration. (4) Cryptographic references are documentation content. No actual security risks present.

6
Fichiers analysés
1,416
Lignes analysées
0
résultats
1
Total des audits
Aucun problème de sécurité trouvé

Motifs détectés

False Positive: Markdown Code Block BackticksFalse Positive: Documentation URLsFalse Positive: Environment Variable Code ExamplesFalse Positive: Cryptographic References in Documentation
Audité par: claude

Score de qualité

45
Architecture
100
Maintenabilité
87
Contenu
50
Communauté
100
Sécurité
91
Conformité aux spécifications

Ce que vous pouvez construire

新 Mastra 開發者入職

開始使用 Mastra 的開發者使用此技能來了解文檔查詢優先順序(首先嵌入文檔,然後遠程),設置正確的 TypeScript 配置,並使用工具建立他們的第一個代理。

調試運行時錯誤

遇到「屬性 X 不存在於類型 Y」錯誤的開發者使用此技能來識別他們的知識已過時,並學習如何在嵌入的文檔中查詢當前的 API。

構建多步驟工作流程

有經驗的開發者使用此技能來了解代理(自主)和工作流程(結構化)之間的區別,並學習使用 .commit() 建立和執行工作流程的正確模式。

Essayez ces prompts

Mastra 入門
如何設置新的 Mastra 項目並使用簡單的工具建立我的第一個代理?
了解代理與工作流程的區別
Mastra 中代理和工作流程之間有什麼區別,我應該何時使用每一個?
調試類型錯誤
我在 Mastra 代碼中遇到「屬性 X 不存在於類型 Y」錯誤。如何找到正確的 API?
配置記憶和存儲
如何為我的代理設置記憶和存儲,以便它在會話之間記住對話歷史?

Bonnes pratiques

  • 始終驗證 API 使用情況與當前的文檔,而不是依賴訓練數據
  • 當已安裝套件時,使用嵌入的文檔(node_modules)作為主要來源
  • 在編寫任何 Mastra 代碼之前配置正確的 ES2022 TypeScript 設置
  • 為代理會話使用一致的 threadId 以在會話之間保持記憶

Éviter

  • 假設訓練數據知識是當前的——Mastra API 經常變化
  • 使用 CommonJS 模塊配置而不是 ES2022 模塊
  • 忘記在工作流程上調用 .commit(),導致執行失敗
  • 在將工具分配給代理之前未在 Mastra 實例中註冊它們

Foire aux questions

為什麼此技能強調檢查文檔?
Mastra 快速發展,API 經常變化。訓練數據很快就會過時,因此始終驗證當前的文檔可以防止錯誤。
嵌入文檔和遠程文檔之間有什麼區別?
嵌入的文檔來自您安裝的 node_modules,與您的精確版本匹配。來自 mastra.ai/llms.txt 的遠程文檔是最新發布的,但可能領先於您安裝的版本。
如何調試「屬性 X 不存在」錯誤?
這通常意味著您的知識已過時。檢查 node_modules/@mastra/core/dist/docs/SOURCE_MAP.json 以獲取當前的導出,或獲取遠程文檔。
何時應該使用代理而非工作流程?
將代理用於需要決策的自主任務(支持、研究)。將工作流程用於具有定義步驟的結構化序列(管道、審批、ETL)。
如何跨會話持久化代理記憶?
配置存儲後端(PostgresStore、LibSQLStore)並將其傳遞給 Memory。在調用 agent.generate() 時使用一致的 threadId。
Mastra 需要什麼 TypeScript 配置?
Mastra 需要 ES2022 模塊。在 tsconfig.json 中設置 target: ES2022, module: ES2022, moduleResolution: bundler,並在 package.json 中添加 'type: module'。

Détails du développeur