This file provides guidance to Claude Code (claude.ai/code) 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.
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 targetted 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)
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
- packages/ - Core framework (core, cli, server, deployer, rag, memory, evals, mcp, mcp-docs-server, auth, agent-builder, create-mastra, playground, playground-ui, schema-compat, fastembed, loggers, codemod)
- stores/ - Storage and vector adapters (pg, chroma, pinecone, libsql, mongodb, qdrant, etc.)
- deployers/ - Platform deployment adapters (vercel, netlify, cloudflare, cloud)
- server-adapters/ - Server framework adapters (hono, express)
- voice/ - Voice synthesis and recognition packages
- client-sdks/ - Client libraries (ai-sdk, client-js, react)
- auth/ - Authentication providers (auth0, better-auth, clerk, firebase, supabase, workos)
- observability/ - Observability integrations
- communications/ - Communication channel packages
- pubsub/ - Pub/sub packages
- workflows/ - Workflow packages
- examples/ - Demo applications
- e2e-tests/ - End-to-end test suites
- templates/ - Project templates
- 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
- Main docs in
docs/, course content indocs/src/course/, dev guide inDEVELOPMENT.md - Follow
.cursor/rules/writing-documentation.mdcfor writing style: avoid marketing language ("powerful", "production-ready", "makes it easy"), focus on technical details, write for engineers
Changelogs are authored via changesets in .changeset/. Follow .claude/commands/changeset.md for guidelines.
- pnpm (v10.18.0+) for package management, Turborepo for build orchestration
- All packages use TypeScript with strict type checking
- Vitest for testing, test files co-located with source code