Skip to Content
DocsLocal DevAdd to an Existing Project

Adding to an Existing Project

You can add Mastra to an existing project using the CLI:

npm install -g mastra@latest mastra init

Changes made to project:

  1. Creates src/mastra directory with entry point
  2. Adds required dependencies
  3. Configures TypeScript compiler options

Interactive Setup

Running commands without arguments starts a CLI prompt for:

  1. Component selection
  2. LLM provider configuration
  3. API key setup
  4. Example code inclusion

Non-Interactive Setup

To initialize mastra in non-interactive mode use the following command arguments:

Arguments: --components Specify components: agents, tools, workflows --llm-provider LLM provider: openai, anthropic, or groq --add-example Include example implementation --llm-api-key Provider API key --dir Directory for Mastra files (defaults to src/)

For more details, refer to the mastra init CLI documentation.