paramour
Reference@paramour-js/nextCLI

paramour generate

Generate paramour-env.d.ts from the app and pages directories.

Scans the route directories and writes the registry artifact — the paramour-env.d.ts file that narrows route constructors to paths that actually exist:

npx paramour generate
paramour: wrote paramour-env.d.ts (3 app routes)

The write is deterministic and idempotent: byte-identical output is a skipped write (reported as unchanged), so timestamps don't churn and watchers don't loop.

Flags

FlagDefaultDescription
--app-dir <dir>discovered app/ or src/app/App directory.
--pages-dir <dir>discovered pages/ or src/pages/Pages directory.
--out-file <file>paramour-env.d.tsArtifact path, relative to the project root.
--page-extensions <list>tsx,ts,jsx,jsComma-separated, no leading dots.
--checkoffVerify the artifact is current; exit 1 on drift, never writes.
--watchoffRegenerate on route-directory changes.
--help, -hShow usage.

--check and --watch are mutually exclusive — passing both exits 2. Flag values take precedence over paramour.config, which takes precedence over discovery; an explicitly given directory must exist or the command exits 2. Discovery only runs for directories you didn't pass, so passing both --app-dir and --pages-dir bypasses it entirely.

The artifact workflow

generate writes the file; committing it is what makes it useful. The artifact is generated and committed — treat it like a lockfile:

  1. Add, move, or delete a route, then run paramour generate (the "paramour" package script init adds runs exactly this).
  2. Commit the regenerated file — route changes show up in review as a small readable diff.
  3. Let paramour check prove the committed file honest in CI.

During next dev, the withTypedRoutes wrapper keeps the artifact current automatically, so manual runs mostly matter outside the dev server.

--watch

Regenerates on route-directory changes, for workflows outside next dev — an editor companion while you restructure routes, say:

npx paramour generate --watch
paramour: watching /home/you/my-app/app

A pidfile lock makes watchers single-writer: if another live watcher already owns the artifact (usually a running next dev with withTypedRoutes), the command prints the owning pid and exits 0 — initial generation has already run, so nothing is stale. A failed initial generation warns and keeps watching; a route collision mid-watch (usually a file mid-move) logs on every rescan, keeps the last good artifact on disk, and keeps running.

Exit codes

CodeWhen
0Wrote the artifact, or it was already up to date; --watch declined by an existing watcher.
1--check found drift — only that.
2Usage/config errors, no route directories, route collisions, I/O failures.

On this page