Medusa CLI
$ medusa Official Med RiskMedusa CLI (medusa / @medusajs/medusa-cli) drives Medusa v2 commerce backends—running local dev servers (develop), executing database and data migrations (db:migrate), syncing module links (--execute-safe-links), and creating admin users. Optimized as a project-local build and migration runner.
npm install @medusajs/medusa-cli medusa executes local MikroORM schema migrations, builds commerce admin bundles, and runs project code locally.
Agent-Readiness Checklist
Static evaluation (not yet probed on this host). Run npm run data:probe locally to capture live verification.
FCRS-1.0 6-Dimension Breakdown
Supports --execute-safe-links and --skip-scripts for headless migrations, though runtime output is human-formatted logger text rather than --json.
db:migrate --execute-safe-linksavoids interactive link sync prompts- No
--jsonoutput across runtime/migration commands
Pauses on unsafe module link deletions unless --execute-all-links is passed, protecting against accidental database drops.
--execute-safe-linksonly applies non-destructive link updates
Installable via npm/npx across macOS, Linux, and Windows, though useful only inside a Medusa project with PostgreSQL.
- Runs via
npx medusain Node.js commerce projects
Coordinates dev server, production builds, migrations, and user provisioning in one command interface.
- Handles
develop,build,db:migrate,db:generate, anduser
Official Medusa monorepo (medusajs/medusa) under MIT license.
- Maintained by the Medusa core team
Documented in Medusa v2 CLI reference, though some legacy v1 flags differ from v2.
- Official docs at
docs.medusajs.com/resources/medusa-cli
Security, Auth & Guardrails
Reads PostgreSQL DATABASE_URL, Redis, and JWT secrets from project .env and medusa-config.ts; does not store cloud user tokens.
MIT open-source CLI and commerce framework; free to self-host.
# Medusa CLI (medusa) Agent Rules - Run `npx medusa` from a Medusa project root with a valid `.env` database connection. - Pass `--execute-safe-links` (or `--skip-links`) on `medusa db:migrate` in CI so link prompts do not hang. - Back up PostgreSQL before running `db:migrate` or `db:rollback` on staging/production databases.
Agent-Ready Command Recipes
Safe Read-Only Queries
npx medusa --help
Lists available project-local Medusa commands including develop, build, and db:migrate.
Controlled Writes & Previews
npx medusa db:migrate --execute-safe-links
Applies pending schema migrations and automatically executes safe module link updates without interactive prompts.
Strengths for Agents
- +
--execute-safe-linkslets CI and agents run safe schema migrations without blocking on prompts. - + Cleanly separates safe link updates from destructive schema changes.
Caveats & Pitfalls
- ! Project-local tool requiring a configured PostgreSQL database; no
--jsonlog mode fordb:migrateordevelop. - ! Commands differ significantly between Medusa v1 and v2.