CLI
Use the CLI to set up a workspace, apply migrations and administer modules from a terminal. Select the command that matches the app and workspace you are working in.
Open Mercato bundles CLI commands for project setup, tenant administration, and module scaffolding. Top-level helpers are exposed as Yarn scripts (yarn initialize, yarn db:generate, …) while module-specific utilities live under the umbrella command:
yarn mercato <module> <command> [options]
Run yarn mercato --help to list modules and yarn mercato <module> --help to drill in.
--help and -h are answered by the dispatcher before the command is invoked, at every level:
yarn mercato --help # list modules
yarn mercato db --help # list the db module's commands
yarn mercato db generate --help # print usage for one command — generates nothing
A help invocation is always a no-op: it never runs the command it is asking about, and it never creates .env from .env.example. This matters most for the destructive commands – yarn mercato db migrate --help describes the command instead of applying every pending migration.
A ModuleCli descriptor in your module's cli.ts – the same shape mercato module add registers for you – takes two optional fields that control this behavior:
import type { ModuleCli } from '@open-mercato/shared/modules/registry'
const cli: ModuleCli[] = [
{
command: 'sync',
help: 'Usage: mercato inventory sync [--since <iso-date>]\nPulls stock levels from the configured provider.',
run: async (argv) => { /* … */ },
},
]
export default cli
help?: string – usage text the dispatcher prints under the generic Usage: mercato <module> <command> [args] line. Omit it and the dispatcher still prints the usage line plus the module's command list, so help works with no work on your part.
handlesHelp?: boolean – set this when your run() parses --help/-h itself and prints richer usage than a single string can carry. The dispatcher then forwards the flag through instead of intercepting it. mercato configs cache uses this. It is also the escape hatch if your command means something other than "help" by -h.
Opting out moves the guarantee above onto your command: the dispatcher no longer stands between a help flag and your run(), so your handler must answer it before doing any work – including when the flag follows a subcommand, as in configs cache purge --help. Check for it across the whole argument list rather than only in the first position, or a help request lands on the destructive path you were describing.
yarn initialize – full app bootstrap with optional reinstall mode (wraps mercato init).yarn db:generate – per-module migration diffing (alias for mercato db generate).yarn db:migrate – apply migrations and refresh generated metadata.yarn db:greenfield – destructive reset that regenerates a clean schema.yarn dev – start the compact development runtime with splash-based startup progress on the default local backend port, plus ready-state splash actions such as coding-tool launchers and standalone GitHub publish helpers when enabled.yarn dev:classic – start the legacy raw passthrough runtime with no splash screen.yarn dev:verbose – start the same runtime in raw passthrough mode for debugging.yarn dev:greenfield:classic – run the greenfield boot flow with raw passthrough output and no splash screen.yarn dev:ephemeral – start a dev server on a free port, open browser automatically, and register active instances in .ai/dev-ephemeral-envs.json.yarn dev:ephemeral:classic – run the ephemeral flow with raw passthrough output and no splash screen.--database-name[=<name>] to rewrite the database segment of DATABASE_URL for the run. Examples: yarn dev --database-name=client_a (explicit), yarn dev --database-name (derive from process.cwd()), yarn dev --database-name=temp --no-update-env (current run only). Without the flag, behavior is unchanged. See the monorepo and standalone installation guides for the full walkthrough.mercato generate or mercato generate all – run all generators (entity IDs, registry, entities, DI, API client).mercato generate entity-ids – generate entity ID mappings.mercato generate registry – generate module registry.mercato generate entities – generate ORM entity aggregation.mercato generate di – generate dependency injection registrars.mercato generate api-client – generate typed API client.mercato db generate – generate per-module migrations.mercato db migrate – apply pending migrations.mercato db greenfield --yes – destructive reset and regenerate schema.mercato deploy railway – provision or update a Railway project using Git or local source, with managed PostgreSQL, Redis, an optional worker, and tracked deployment state.mercato api_keys add – mint scoped API keys for automations.mercato events emit <event> [payload] [-p] – emit an event (optionally persistent).mercato events clear – clear the events queue.mercato queue worker <name> – run a queue worker (e.g., queue worker events).mercato queue status <name> – show queue job counts.mercato queue clear <name> – clear all jobs from a queue.mercato scaffold module <name> – create a new module skeleton.mercato scaffold entity – interactive entity creation wizard.mercato scaffold crud <module> <Entity> [route] – generate CRUD route for an entity.mercato configs cache – inspect cache segments and purge by segment, tag, key, identifier token, pattern, or structural navigation scope.mercato module add <packageSpec> - install and register a module package: official @open-mercato/* packages, or any scope with --allow-third-party. Find packages and their exact install commands on modules.openmercato.com.mercato module add <packageSpec> --eject – copy module source into src/modules/ for local ownership.mercato module enable <packageName> - register an already-installed module package (no dependency install).mercato module enable <packageName> --eject – copy an already-installed package into src/modules/ and enable it as @app.mercato module eject <moduleId> – alias for mercato eject <moduleId>.mercato eject --list – list modules available for ejection.mercato eject <moduleId> – copy a core module into your local src/modules/ for full customization.yarn test:integration:ephemeral – run Playwright tests in disposable app+DB containers.yarn test:integration:ephemeral:interactive – keep one disposable app+DB running and choose tests from an interactive menu.yarn test:integration:ephemeral:start – start disposable app+DB only for QA/MCP exploration.Each linked page provides usage syntax, option breakdowns, sample output, and troubleshooting notes so you can copy commands directly into your terminal.