admin-kit

CLI#

The package ships one binary, admin-kit, with two commands.

admin-kit init [options]     # scaffold config, middleware, panels and routes
admin-kit docs [options]     # generate markdown docs from your admin config
admin-kit --version
admin-kit --help

Run it with npx admin-kit … (or pnpm exec admin-kit …) from your project root. It adds nothing to your install: the flag parser is about eighty lines, because two commands and eight flags do not justify a dependency, and a CLI shipped inside a library should not grow a consumer's node_modules.

admin-kit init#

npx admin-kit init
npx admin-kit init --router pages --name "Axiomkit"
npx admin-kit init --force
FlagDefaultMeaning
--router <app\|pages>appRouter flavour to scaffold for
--name <name>AdminApp name written into the config
--forceoffOverwrite files that already exist

It writes:

  • admin.config.ts — the serializable config
  • admin.server.ts — the server-only config, with the secret
  • middleware.ts — the sign-in redirect
  • the login route
  • one page per panel

Without --force it refuses to overwrite anything and reports what it skipped, so running it inside an existing project is safe.

Afterwards: set JWT_SECRET in .env.local, point the config at your real API endpoints, and run admin-kit docs.

admin-kit docs#

npx admin-kit docs
npx admin-kit docs --out docs/admin --format md
npx admin-kit docs --config src/admin.config.ts
npx admin-kit docs --check
FlagDefaultMeaning
--config <path>auto-detectPath to the admin config
--out <dir>docs/adminOutput directory
--format <md\|mdx>mdOutput extension
--checkoffCompare instead of writing; exit non-zero when stale

What it generates#

FileContent
README.mdAn index, with a summary of what this install is
getting-started.mdCopy-paste snippets using your paths, your names
auth.mdYour endpoint table, session storage and its exposure, env vars
access.mdThe three gates as configured, plus a role → permission matrix
navigation.mdTiles, dock and sidebar, annotated with what each requires
resources.mdPer resource: endpoints, verbs, permissions, fields, snippets
configuration.mdEvery value set and every default inherited, secrets redacted

Generated from your config, not from a template — so it describes your installation rather than the package. See examples/app-router/docs for real output.

Auto-detection#

With no --config, it looks for, in order:

admin.config.ts
admin.config.mts
admin.config.js
admin.config.mjs
src/admin.config.ts
app/admin.config.ts
config/admin.config.ts

The config must be exported as adminConfig or as the default export.

TypeScript is transpiled through jiti, an optional peer dependency — so only CLI users pay for it, and a missing install produces a clear instruction rather than a module-resolution stack trace.

This is also why the core entry point stays free of React and DOM code: a config that transitively imports a client component cannot be read by a CLI in plain Node, and then no tool can generate documentation, scaffolding or checks from it.

--check in CI#

Documentation that describes endpoints and permission matrices goes stale the first time someone adds a resource. A diff that fails the build is the only thing that reliably prevents it.

- name: Check generated docs are current
  run: npx admin-kit docs --out docs/admin --check

It prints the files that would change and tells you to run admin-kit docs and commit the result. This repository runs exactly that against the example app.

Exit codes#

CodeMeaning
0Success, or --check found everything current
1Unknown command, no command, a config that could not be loaded, or --check found stale files

Errors print a message rather than a stack trace.

Edit this page on GitHub