Master Guides

Command Reference

The full Master CLI surface (2.1.0).

Run master help any time. Every command supports the obvious aliases.

master new <name>#

Scaffold a new full-stack app (alias n).

terminal
$ master new my-app
$ master new my-app --db postgres # sqlite | mysql | postgres
$ master new my-app --skip-frontend # backend only
$ master new my-app --skip-install # don't run npm install
$ master new my-app --skip-git # don't init a repo

The generated backend pins mastercontroller ^2.11 and masterrecord ^1.22 and ships with layered configuration, a request-scoped database context, health endpoints, OpenAPI + Swagger UI, response compression, graceful shutdown and opt-in JWT auth — see Project Structure.

master dev / build / start#

The Next.js-style lifecycle commands.

terminal
$ master dev # run backend + frontend together (watch mode) [alias: s]
$ master build # build the frontend for production
$ master start # run backend + frontend in production mode

master generate <type> <name>#

Generate code (alias g). See Generators.

terminal
$ master g scaffold post title:string body:text # model + validated REST API + page
$ master g controller users index show # API controller + routes
$ master g model Comment body:text # MasterRecord entity (+ registered)
$ master g page about # Next.js App Router page
$ master g socket chat message # WebSocket controller
$ master g middleware auth # request-pipeline middleware
$ master g component billing # mountable backend component

Scaffolded controllers use the request-scoped this.db, static schemas (model binding + validation → this.model, automatic 400 ValidationProblemDetails), typed results (this.ok / created / noContent / notFound) and typed :id(int) routes. Plain controllers reply with this.ok(...).

master db <action> [name]#

Run migrations via MasterRecord — the dotnet ef equivalent. Migrations are enabled automatically on first use. See Database.

terminal
$ master db migrate # apply pending migrations
$ master db new AddPosts # create a migration from your models
$ master db rollback # revert the latest migration
$ master db status # applied / pending migrations
$ master db script -o up.sql # SQL for pending migrations, nothing applied
$ master db remove # delete the latest migration file
$ master db remove --force # ... reverting it first if it was applied
$ master db list # list migration files
$ master db ensure # create the database if missing
$ master db enable # create the context snapshot (automatic otherwise)
$ master db migrate --env production
OptionMeaning
--env <env>Environment to run against (default: NODE_ENV, else development).
-f, --forcedb remove: revert the migration if it was applied, then remove it.
-o, --output <file>db script: write the SQL to a file instead of stdout.

master secrets <action> [key] [value]#

Development secrets stored outside the repo — the dotnet user-secrets equivalent. See Secrets.

terminal
$ master secrets set Auth:JwtSecret "$(openssl rand -hex 32)"
$ master secrets get Auth:JwtSecret
$ master secrets list # values masked
$ master secrets list --reveal
$ master secrets remove Auth:JwtSecret
$ master secrets clear
$ master secrets path # ~/.master/usersecrets/<id>/secrets.json

--id <id> overrides the secrets id (defaults to the backend package name).

master test#

Run the backend test suite (npm testnode --test) with NODE_ENV=test. See Testing.

terminal
$ master test # backend tests
$ master test --frontend # also run the frontend test script
$ master test --env staging # a different NODE_ENV for the run

master routes / info#

terminal
$ master routes # print the registered API routes (method, path, controller#action)
$ master info # banner + Node/platform/project details
$ master --version
master routes
METHOD  PATH              CONTROLLER#ACTION
  GET     /health           health#index
  GET     /posts            posts#index
  GET     /posts/:id(int)   posts#show
  POST    /posts            posts#create
  PUT     /posts/:id(int)   posts#update
  DELETE  /posts/:id(int)   posts#destroy
Easter egg
Try master power. By the power of Grayskull. ⚡