Command line interface for Medusa Commerce platform with project creation, development server, and database management capabilities
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
The Medusa CLI provides comprehensive project creation capabilities, allowing developers to bootstrap new Medusa Commerce projects with automated setup processes including database configuration, environment setup, and dependency installation.
Creates a new Medusa project from a starter template with full automated setup.
medusa new [root] [starter]Parameters:
root (optional): Project directory path. Defaults to current directory if not specifiedstarter (optional): Starter template name or Git URL. Defaults to medusajs/medusa-starter-defaultOptions:
--seed: Seed the database with sample data after setup--y, --useDefaults: Use default database credentials without interactive prompts--skip-db: Skip database setup entirely--skip-migrations: Skip running database migrations--skip-env: Skip creating .env file with database configuration--db-user <string>: Database username for connection--db-database <string>: Database name to use--db-pass <string>: Database password for connection--db-port <number>: Database port (default: 5432)--db-host <string>: Database host (default: localhost)Usage Examples:
# Interactive project creation
medusa new
# Prompts for project name and starter selection
# Create project with specific name and default starter
medusa new my-store
# Create with custom starter from GitHub
medusa new my-store https://github.com/medusajs/medusa-starter-contentful
# Create with custom database settings
medusa new my-store --db-user admin --db-pass secret --db-host localhost
# Create project without database setup
medusa new my-store --skip-db
# Create and seed with sample data
medusa new my-store --seedWhen no arguments are provided, the CLI enters interactive mode:
medusa-starter-default (default option)(Use a different starter) for custom URL entryInteractive Prompts:
// Project creation prompts
interface ProjectPrompts {
path: string; // Project directory name
starter: string; // Starter template selection
}
// Database credential prompts (when not using defaults)
interface DatabasePrompts {
continueWithDefault: "Continue" | "Change credentials" | "Skip database setup";
user?: string; // Database username
password?: string; // Database password (hidden input)
port?: number; // Database port
host?: string; // Database host
}The project creation process includes sophisticated database management:
Automatic Database Creation:
medusa-db-{5-character-string})pg-god library for database creationInteractive Credential Collection:
Environment Configuration:
.env.template to .env if template existsDATABASE_URL configurationpostgres://user:password@host:port/databasepostgres://host:port/databaseThe CLI executes these steps during project creation:
hosted-git-info for URL parsingnpm_config_user_agent and lock files--useDefaults specified).env.template to .env if existsDATABASE_URL to .env filemedusa migrations run in project directory--seed flag provided):
clearProject utility.git directoryDefault Starters:
medusa-starter-default: Basic Medusa storefront with essential featuresTemplate Sources:
The project creation process includes comprehensive error handling:
Validation Errors:
is-valid-path validation)hosted-git-info)Specific Error Scenarios:
enum PanicId {
InvalidProjectName = "INVALID_PROJECT_NAME",
InvalidPath = "INVALID_PATH",
AlreadyNodeProject = "ALREADY_NODE_PROJECT"
}Recovery Mechanisms:
The CLI automatically detects and integrates with package managers: