Skip to main content

Mastra Quickstart

The create-mastra CLI is the quickest way to start a Mastra project. It creates an agent harness with workspace tools, memory, task tracking, web access, schedules, storage, and observability.

For more control, see the manual installation guide. To add Mastra to an existing project, use mastra init.

📹 Watch

Watch the Mastra AI agent course for a guided introduction to building agents with Mastra.

Before you begin
Direct link to Before you begin

You'll need an API key from OpenAI, Anthropic, Google Gemini, or xAI. You can skip entering it during setup and add it to .env later.

Create the project
Direct link to Create the project

Run the interactive setup:

npm create mastra@latest

The command asks for a project name, model provider, and optional API key. It then installs dependencies, installs Mastra skills for your coding assistants, and creates an initial Git commit when you aren't already inside a repository.

The generated src/mastra directory contains the Mastra entry point, agent, workspace tools, and supporting code. See the project structure reference for the standard Mastra layout.

tip

Use --template <template> to start from a template, or --empty to create a minimal provider-free project. Use --no-skills or --no-git to skip automatic setup. See the create-mastra reference for all flags.

Test your agent
Direct link to Test your agent

Follow the terminal instructions to enter the project directory and start the development server:

npm run dev

Open Studio at localhost:4111, select the agent, and send a message. Add the provider API key named in .env.example to an .env file if you skipped it during setup.

Studio lets you build and test agents without creating a separate UI.

Next steps
Direct link to Next steps

On this page