Skip to Content
TelamonJS

CLI

Create a TelamonJS app, generate CRUD modules from Prisma, add admin-kit modules, and check modules against the conventions

@telamonjs/cli ships two binaries and no library code:

BinaryWhat it runs
create-telamonjs-apptelamonjs create with the same arguments; with no arguments, the wizard
telamonjsEvery command on this page; with no arguments, the wizard

It requires Node 22 or later.


Create an app

npx -p @telamonjs/cli create-telamonjs-app my-admin

Or install the CLI globally and use telamonjs:

npm install -g @telamonjs/cli
telamonjs create my-admin

The single-app template is a Next.js admin wired to @telamonjs/ui: an AdminShell layout with its menu, NextAuth v5, Prisma with a docker-compose.yml database, a reference CRUD module (usuarios) whose create, edit and view open in dialogs, database-backed roles and permissions (below), and pt-BR/en/es messages. Unless you pass --skip-install, the CLI installs dependencies and then sets the app up: it copies .env, starts the database container, runs the migrations and the seed. Then:

cd my-admin
pnpm dev     # http://localhost:3001, sign in as admin@example.com / 12345

If the automatic setup fails (Docker not running, for example), the CLI prints the manual steps: docker compose up -d db, cp .env.example .env, pnpm db:migrate, pnpm db:seed.

Roles and permissions in a new app

New apps ship RBAC from the database, built on @telamonjs/permissions and @telamonjs/auth:

PieceWhere
Role, Permission, RolePermission, UserRole tables (the package's Prisma fragment); User has roles, active, accessChangedAt, sessionsRevokedAtprisma/schema.prisma
The permission catalog (users.read/write, roles.read/write) and loadAccess()src/rbac.ts
Catalog sync with diffPermissionCatalog, a built-in admin role holding every permission, the admin user with that roleprisma/seed.ts (idempotent: rerun it after adding a permission)
Roles and permission codes materialized into the JWT at sign-in; on every renewal sessionState signs out a deactivated or revoked user and recomputes the claims of a stale tokensrc/auth.ts
requirePermission('users.write') in every Route Handlersrc/lib/auth.ts, src/app/api/**
PermissionsProvider around the AdminShell, menu items with permission, CrudConfigs with permissionsLayoutProviders.tsx, src/config/menu.ts
/admin/papeis: role CRUD and a PermissionMatrix tab (built-in roles locked); /admin/usuarios: multi-role assignment, activate/deactivatesrc/app/admin/**

Changing a role's permissions, renaming or deleting it, or changing a user's roles stamps accessChangedAt on the affected users, so their next request carries fresh claims without a new sign-in; deactivating a user or changing their password stamps sessionsRevokedAt and ends their sessions. In the monorepo, src/rbac.ts moves to packages/shared (@<name>/shared/rbac) and apps/api enforces the same codes with createPermissionsGuard and @Permissions(...).

Options

telamonjs create [project-name] [options]   # alias: telamonjs new
OptionDefaultEffect
-p, --provider <provider>postgresqlDatabase: postgresql or mysql
--port <port>3001Development server port
--monorepoaskedGenerate a pnpm monorepo instead of a single app (see below)
--skip-installSkip dependency installation and the automatic setup
--skip-gitSkip git init

Without --monorepo, create asks whether you want a monorepo when it runs in a terminal, and creates a single app when it does not (CI, piped stdin).

telamonjs create my-admin --provider mysql --port 3005 --skip-git

The wizard

telamonjs with no arguments, telamonjs wizard (alias init), or npx -p @telamonjs/cli create-telamonjs-app with no arguments starts an interactive setup. It asks for:

  1. the project name
  2. the database (PostgreSQL or MySQL)
  3. the development server port (1024-65535, default 3001)
  4. monorepo or single app
  5. whether to install dependencies
  6. whether to initialize git

It shows a summary, asks for confirmation, then runs create with those answers.

--monorepo

npx -p @telamonjs/cli create-telamonjs-app my-admin --monorepo
apps/web/         Next.js + @telamonjs/ui, port <port>
apps/api/         NestJS API, prefix /v1, port <port> + 1000
apps/jobs/        BullMQ worker and scheduler on @telamonjs/queue
packages/shared/  Prisma schema and client, shared by web, api and jobs

apps/web starts from the single-app template, with Prisma, src/rbac.ts and the Route Handlers of usuarios and roles moved out to packages/shared and apps/api. The monorepo uses pnpm through corepack and does not run the database setup for you:

cd my-admin
corepack enable pnpm        # once per machine
cp .env.example .env        # fill NEXTAUTH_SECRET (openssl rand -base64 32)
docker compose up -d        # postgres + redis
pnpm db:push
pnpm db:seed
pnpm dev                    # apps/web
pnpm dev:api                # apps/api
pnpm worker                 # apps/jobs

generate crud

telamonjs generate crud [name] [options]   # alias: telamonjs g crud

Run it from the app root. It reads the Prisma schema, maps each model field to a form field type and a column, and writes a module in the standard structure. The schema is the one package.json#prisma.schema names, else prisma/schema.prisma (also database/, src/prisma/ and a multi-file prisma/schema/ folder); from a monorepo's apps/web it finds packages/shared/prisma at the workspace root. When the schema or the model is missing it stops and says where it looked, or which models exist; --no-prisma-schema generates generic fields instead.

FileContents
src/app/admin/<name>/config.tsxZod schema, columns, form sections and the CrudConfig, with create, edit and view dialogs
src/app/admin/<name>/page.tsx<ListPage config={…} />, the module's only route
src/app/admin/<name>/_components/<Model>Detail.tsxThe view dialog body
src/lib/api/<name>-client.tsTyped REST client used by the config
src/app/api/<name>/route.ts, [id]/route.tsRoute Handlers backed by Prisma

It also adds the module to menu-items.ts, writes the module's messages to messages/{pt-BR,en,es}.json when the app has i18n, and formats the files with Prettier when it is available.

OptionEffect
[name]Module name, plural: folder, route and query key
-m, --model <model>Prisma model to read (singular)
-p, --path <path>Module path (default src/app/admin/<name>)
--no-prisma-schemaSkip Prisma detection and generate generic fields
--no-update-menuDo not add the module to the menu
-f, --forceOverwrite the module's messages block if it already exists

Missing arguments are asked interactively, including a pick list of the models found in the schema.

telamonjs generate crud products --model Product
telamonjs g crud                                  # fully interactive

The output is a starting point. Fill in the loadField stubs for relationships, review the validation schema, and check that the Route Handlers match your authorization rules: none of that can be inferred from the schema. Icons are resolved by name from src/lib/icons.ts.

Monorepo apps

The generated Route Handlers import @/lib/prisma, which only exists in the single-app template. In a monorepo, the API belongs in apps/api: move the data access there and point the generated client at it.


Admin kit: add admin

telamonjs add admin <module> [--dry-run] [--cwd <dir>]

Adds a ready-made admin module to an app generated by telamonjs create. It detects the layout (single app, or a monorepo with apps/api and packages/shared/prisma) and writes the module in the app's own patterns: Prisma model, API with permission checks, permission codes, menu entry, i18n messages and an admin page.

ModulePrisma modelPermissionsAdmin page
auditAuditLog: user, impersonator, action, entity type and id, changes (JSON, secrets redacted), IP, user agent, method, path, status, date; indexed by entity, user and dateaudit.read/admin/auditoria: read-only list (when, who, action, entity, record), action filter, view dialog with AuditChangesViewer
parametersParameter: unique key, text value read through type (STRING, NUMBER, BOOLEAN, JSON), description, group, publicparameters.read, parameters.write/admin/parametros: CRUD in dialogs, the value input follows the type
invitationsInvitation: email, name, roleIds, tokenHash (sha256 of the link's token, unique), status (PENDING, ACCEPTED, REVOKED; a pending one past expiresAt reads as EXPIRED), expiresAt, acceptedAt, resendCount, invitedById, userIdinvitations.read, invitations.write/admin/convites: list (email, roles, status, expiry, inviter), invite dialog with a roles multiselect, resend and revoke row actions; plus the public /convite/<token> accept page

What each module writes besides the shared edits below:

ModuleSingle appMonorepo
auditsrc/lib/audit.ts (audit(), built on computeDiff and redactPayload), GET /api/audit and /api/audit/[id]; the users and roles Route Handlers call audit() after each create, update, (de)activation, deletion, grant and revokeapps/api/src/modules/audit (GET /v1/audit, GET /v1/audit/:id), and createAuditInterceptor registered as APP_INTERCEPTOR, so every successful, authenticated mutation is recorded
parameterssrc/lib/parameters.ts (getParameter(key, fallback)), Route Handlers under /api/parametersapps/api/src/modules/parameters (ParametersService.get(key, fallback), exported by its module), wired into AppModule
invitationssrc/lib/invitations.ts, src/lib/mail.ts (the mail port: sendMail({ to, subject, html, text })), Route Handlers under /api/invitationsapps/api/src/modules/invitations wired into AppModule, and apps/api/src/modules/mail (the mail port: the MAIL_SENDER token, a MailSender interface and ConsoleMailSender)

The audit list takes the filters entityType, entityId, userId, action, from and to (ISO dates), plus search. GET /parameters/public?keys=a,b needs no session and answers { key: value } for the requested parameters marked public, typed; private and unknown keys are absent.

Invitations: GET /invitations, POST /invitations, POST /invitations/:id/resend (a new link, the previous one stops working, a new 7-day expiry) and PUT /invitations/:id/revoke check the permissions; GET /invitations/by-token/:token and POST /invitations/accept need no session. The link carries a random 32-byte token (generateApiKey from @telamonjs/auth) and the row keeps only its sha256 (hashApiKey). Inviting an email that already has a user or a pending invitation is a 409. Accepting creates the user (active, with the invited roles that still exist) and marks the invitation accepted in one transaction; an unknown, used, revoked or expired token gets the same 410. The accept page then signs in with the new credentials. Mail goes through the port above, which only logs to the console: replace it with your provider. The link is NEXTAUTH_URL/convite/<token>, never the request's host, and the run notes it in .env.example.

Shared edits, all idempotent:

  • schema.prisma gets a block between // telamonjs:admin:<module> markers; with a multi-file schema folder (prisma/schema/), the model goes in its own <module>.prisma file.
  • The permission codes go into PERMISSIONS in src/rbac.ts (packages/shared/src/rbac.ts in the monorepo).
  • A menu entry with its permission joins the Administration group of src/config/menu.ts.
  • The module's keys are merged into messages/{pt-BR,en,es}.json; keys the app already has are never overwritten.
  • @telamonjs/data is added to the dependencies when missing.

A second run changes nothing, and a module file that already exists is kept as it is. --dry-run lists the files it would create or modify and writes nothing. A code patch whose anchor is gone (a Route Handler you changed) is skipped with a warning naming what to add by hand.

The command never touches the database. Afterwards:

pnpm install
pnpm db:migrate --name add-audit   # monorepo: or pnpm db:push
pnpm db:seed                       # syncs the catalog; the admin role gets the new permissions

Apps not generated from the templates

add admin refuses an app without src/rbac.ts and a Role model: it only edits code it knows. In an existing app, adopt the runtime pieces instead: createAuditInterceptor and @SkipAudit from @telamonjs/data/nest, computeDiff and redactPayload from @telamonjs/data, AuditChangesViewer and PermissionMatrix from @telamonjs/ui, and diffPermissionCatalog from @telamonjs/permissions.


lint

telamonjs lint [dir] [--json]

Checks admin modules against the list, dialog and hub conventions. dir defaults to src/app/admin when it exists, otherwise the current directory. Generated apps have it as a script: pnpm lint:telamonjs.

Rules on CrudConfig run on every config.tsx; page rules run on every other .tsx. A value the linter cannot resolve statically is never reported. The exit code is 1 when there is at least one error, 0 otherwise, and 2 when the directory does not exist. --json prints the report as JSON. Messages are printed in Portuguese.

RuleSeverityChecks
list-infiniteerrorlist.infiniteScroll: false: lists use infinite scroll, the default
list-title-emptywarninglist.title / list.description should be '': the shell breadcrumb names the page
list-pagesizewarninglist.defaultPageSize missing or below 50 (use 100 with infinite scroll)
actions-icon-tooltiperroractionsConfig.standard.view/edit/delete needs { icon, tooltip }, and delete also a confirmDialog
view-headererror / warningdialogs.view without headerConfig or renderHeader (error); a headerConfig without icon or title (warning)
view-contenterrordialogs.view without renderContent or portal
view-tabserrorThe view dialog body imports raw Tabs/TabsList/TabsTrigger/TabsContent instead of ContentTabs
dialog-heightwarningA view dialog body with ContentTabs and no fixed height (h-[min(600px,60vh)] overflow-y-auto)
portal-sizewarningA view dialog body with more than 5 tabs: use dialogs.view.portal
form-spanerrorA field span other than '1', '2', '3', '12' or 'full'
no-fetch-in-configerrorfetch() in config.tsx: only src/lib/api/<module>-client.ts calls fetch
no-crud-pageserroradicionar/page.tsx, [id]/page.tsx or [id]/editar/page.tsx next to a config.tsx: CRUD happens in the list's dialogs
icons-from-registryerrorconfig.tsx imports from lucide-react instead of using getIcon('Name') from @/lib/icons
no-raw-linkerrorA raw <a> or next/link <Link> for navigation instead of <Button asChild><Link /></Button> (external target='_blank', downloads, mailto: and tel: are allowed)
button-icon-sizewarningAn icon inside a Button whose className lacks h-4 w-4 or size-4
i18n-literal-in-configerrorA pt-BR literal in title, label, header, placeholder or description in config.tsx, in an app with i18n: use msg('<key>')
hub-tabswarningA page with more than 5 tabs in useTabUrlSync: use AdminPortal
i18n-untranslatedwarningA key in messages/en.json or es.json whose value is identical to pt-BR.json

To silence a deliberate exception, add a comment to the flagged file:

// telamonjs-lint-disable-file no-crud-pages

List several rules separated by commas, or name none to disable every rule in that file.


telamonjs link [--ui <path>] [--package <path>]
telamonjs unlink [--package <path>]

Switch an app between the published @telamonjs/ui and a local TelamonJS checkout, following the link recipe:

  • link sets @telamonjs/ui to an injected file: dependency on the checkout's packages/ui (dependenciesMeta["@telamonjs/ui"].injected: true) and adds pnpm.overrides["@telamonjs/logger"] as a link: to its packages/logger. The override goes in the workspace root's package.json: the nearest directory with a pnpm-workspace.yaml, or the app itself.
  • unlink restores the range committed at HEAD, or ^ plus the latest published version when HEAD has none, never the checkout's own version, which may not be on npm yet. It removes the override and the dependenciesMeta entry.
OptionDefaultEffect
--ui <path>$TELAMONJS_UI, else ../telamonjs/packages/ui from the workspace rootThe checkout's packages/ui; packages/logger must sit next to it
--package <path>apps/web/package.json when it exists, else package.jsonThe package.json that depends on @telamonjs/ui

Neither command runs pnpm install: run it afterwards. A missing checkout, or a package.json without @telamonjs/ui, exits 1 without writing anything.

In a monorepo generated with --monorepo, the root scripts pnpm telamonjs:link and pnpm telamonjs:unlink run the command and then pnpm install. Its husky hooks keep commits on the published range: pre-commit runs telamonjs unlink and updates the lockfile (a failed update aborts the commit), and post-commit runs telamonjs link again when node_modules still holds the checkout. For a checkout outside the default location, export TELAMONJS_UI so the hook relinks the same path.


db

telamonjs db dump [name]   # database/dumps/<name>_<timestamp>.sql.gz
telamonjs db restore       # pick a dump from a list, confirm, restore

Both read DATABASE_URL from .env in the current directory and use pg_dump and psql, so they need the PostgreSQL client tools on the PATH and work with PostgreSQL only. Without a name, the dump is dump_<timestamp>.sql.gz.


analyze

telamonjs analyze [--verbose] [--json]

Reads package.json in the current directory and reports the TelamonJS packages installed, the database provider, NextAuth, Docker, and the recommended scripts that are missing (dev, build, db:migrate, db:seed, and the db:dump scripts for PostgreSQL), with a snippet to add them.


stats

telamonjs stats [--verbose] [--json] [-p, --path <path>]

Git statistics for a repository (the current directory by default): lines added and removed, commits, authors, activity by time of day, and lines per commit.


On this page