create-factory
Create a Mastra Factory project with an interactive wizard. By default, create-factory installs dependencies and connects the project to the Mastra platform resources.
- npm
- pnpm
- Yarn
- Bun
npx create-factory@latestpnpm dlx create-factory@latestyarn dlx create-factory@latestbun x create-factory@latestCreation modes
Default template
The command downloads the Software Factory template. Provide a project name or enter one when prompted:
- npm
- pnpm
- Yarn
- Bun
npx create-factory@latest my-mastra-factorypnpm dlx create-factory@latest my-mastra-factoryyarn dlx create-factory@latest my-mastra-factorybun x create-factory@latest my-mastra-factoryPlatform setup uses your existing Mastra credentials or opens a browser sign-in flow. It resolves the organization and prompts for a project region. Use --org and --region to supply those choices:
- npm
- pnpm
- Yarn
- Bun
npx create-factory@latest my-mastra-factory --org my-org --region eupnpm dlx create-factory@latest my-mastra-factory --org my-org --region euyarn dlx create-factory@latest my-mastra-factory --org my-org --region eubun x create-factory@latest my-mastra-factory --org my-org --region euThese flags don't bypass authentication.
Without platform setup
Use --no-platform to skip sign-in and resource provisioning:
- npm
- pnpm
- Yarn
- Bun
npx create-factory@latest my-mastra-factory --no-platformpnpm dlx create-factory@latest my-mastra-factory --no-platformyarn dlx create-factory@latest my-mastra-factory --no-platformbun x create-factory@latest my-mastra-factory --no-platformThe command still downloads the template and installs dependencies. It copies .env.example to .env without filling in platform credentials. Configure .env before starting the project.
Automatic setup
The command performs these steps in order:
- Downloads the template into a new directory and updates the package name.
- Copies
.env.exampleto.envand attempts to restrict its permissions to the current user. - Installs dependencies using the detected package manager, falling back to npm.
- Provisions platform resources unless
--no-platformis set. - Ensures
.envis ignored by Git, then initializes a repository and creates an initial commit.
For the default template, start the development server from the generated directory:
- npm
- pnpm
- Yarn
- Bun
cd my-mastra-factory
npm run devcd my-mastra-factory
pnpm run devcd my-mastra-factory
yarn devcd my-mastra-factory
bun run devThe Factory UI is available at http://localhost:4111.
Platform provisioning
Platform setup creates a project with Factory enabled and an organization API key. It also ensures a production environment exists and attaches a Neon Postgres database. The selected project region determines the database region:
| Project region | Neon region |
|---|---|
eu | aws-eu-central-1 |
us | aws-us-west-2 |
Successful provisioning writes these values to .env, preserving unrelated entries:
| Variable | Value |
|---|---|
MASTRA_ORGANIZATION_ID | Selected organization ID |
MASTRA_PROJECT_ID | Created platform project ID |
MASTRA_PLATFORM_SECRET_KEY | Newly minted organization API key |
MASTRA_ENVIRONMENT_ID | Production environment ID |
DATABASE_URL | Neon database connection string |
If provisioning fails, the command warns and preserves the local project. Values obtained before the failure are still written to .env, so you can complete the remaining configuration manually. Skipping browser sign-in also allows local setup to continue without provisioning.
Arguments and flags
Environment variables
These variables configure the CLI process, rather than the generated Factory server:
Telemetry
The CLI collects usage information, including the package manager and whether platform provisioning succeeds. Command telemetry records whether you use the default template or supply an organization, rather than the custom template URL or organization value. Sensitive argument values are redacted from failure telemetry.
To opt out:
- npm
- pnpm
- Yarn
- Bun
MASTRA_TELEMETRY_DISABLED=1 npx create-factory@latest my-mastra-factory --no-platformMASTRA_TELEMETRY_DISABLED=1 pnpm dlx create-factory@latest my-mastra-factory --no-platformMASTRA_TELEMETRY_DISABLED=1 yarn dlx create-factory@latest my-mastra-factory --no-platformMASTRA_TELEMETRY_DISABLED=1 bun x create-factory@latest my-mastra-factory --no-platform