This file provides guidance to coding agents when working with code in this repository.
IMPORTANT: Unless explicitly mentioned in the user's prompt, do NOT check, search, read, or reference files in the examples/ folder. Only include examples when the user specifically asks about them.
- This directory is a Git monorepo containing a
pnpmworkspace. pnpm is used for package management, and Turborepo is used for build orchestration. - The monorepo spans multiple folders:
@auth/@client-sdks/@deployers/@docs/@integrations/@observability/@packages/@pubsub/@server-adapters/@stores/@voice/@workflows/@workspaces/
- The
@docs/folder contains the documentation and needs specific instructions which are covered in@docs/AGENTS.md - All packages use TypeScript with strict type checking
- Vitest is used for testing, with test files co-located with source code
pnpm run setup- Install dependencies and build all packages (required first step)pnpm build- Build all packages (excludes examples and docs)pnpm build:packages- Build onlypackages/directorypnpm build:core,pnpm build:memory,pnpm build:rag,pnpm build:evals- Build individual packagespnpm build:cli- Build CLI packagepnpm build:combined-stores- Build all storage adapterspnpm build:deployers- Build deployment adapters
pnpm dev:services:up/pnpm dev:services:down- Start/stop Docker services (required for integration tests)- Integration test folders and
/examplesfolders need to runpnpm i --ignore-workspace - Package-specific tests:
pnpm test:core,pnpm test:cli,pnpm test:memory,pnpm test:rag, etc. - For faster iteration: build from root first, then
cdinto a package and runpnpm testthere - Core tests take a long time to run, for targeted changes, run the appropriate individual test suites.
pnpm typecheck- TypeScript checks across all packagespnpm prettier:format- Format code with Prettierpnpm format- Lint all packages with auto-fix (excludes examples, docs, playground)
The @docs/ directory contains the source code and contents of the documentation site.
Whenever you change or add code, you MUST update/add related documentation for those changes. You always need to follow @docs/styleguides/DOC.md when writing documentation. The @docs/styleguides/ folder also contains styleguides for specific types of documentation. Read @docs/AGENTS.md to learn more about how to work with documentation.
After making changes to the codebase, you MUST create a changeset. Follow @.claude/commands/changeset.md for guidelines on how to create a changeset and write effective changelog messages.
Mastra is a modular AI framework built around central orchestration with pluggable components.
- Mastra Class (
mastra/) - Central configuration hub with dependency injection - Agents (
agent/) - AI interaction abstraction with tools, memory, and voice - Tools (
tools/) - Dynamic tool composition from multiple sources (assigned, memory, toolsets, MCP) - Memory (
memory/) - Thread-based conversation persistence with semantic recall and working memory - Workflows (
workflows/) - Step-based execution with suspend/resume - Storage (
storage/) - Pluggable backends with standardized interfaces
- Dependency Injection - Components register with central Mastra instance
- Plugin Architecture - Pluggable storage, vectors, memory, deployers
- Request Context - Request-scoped context propagation for dynamic configuration
- Message List Abstraction - Unified message handling across formats