CLI overview
The selfauth CLI is a development tool. It writes files into your project, checks them, and helps you update them later. Nothing it generates calls it at runtime, so you could delete it from your machine and the app would carry on working.
Running it
There's nothing to install:
bash
npx selfauth <command>Or add it to a project as a dev dependency, so the whole team uses the same version:
bash
npm install -D @selfauth/cli
npx selfauth --versiontext
0.15.0selfauth and @selfauth/cli are the same tool. It needs Node.js 22.18 or newer.
All commands
| Command | What it does | Writes files? |
|---|---|---|
init [dir] | Create a new project (Express, Fastify or Gin) | yes |
add [dir] | Add SelfAuth to an existing Express or Fastify project | yes (new files only) |
add-frontend [dir] | Add the auth module to an existing Vue or React app | yes (new files only) |
detect [dir] | Inspect a project and recommend the right command | no |
list | List the supported integrations | no |
doctor [dir] | Configuration and production-readiness checks | no |
validate [dir] | Check the configuration, generated files and the schema | no |
diff [dir] | Show what a newer version would change | no |
upgrade [dir] | Update generated files you have not edited | yes |
db status|plan|migrate|validate|rollback|generate | Review and apply database migrations | database |
skill install [dir] | Install the agent skill for Claude Code, Codex or Cursor | yes |
Ask any command for help:
bash
npx selfauth --help
npx selfauth init --helpConventions
[dir]is the project folder. Leave it out to use the current one.--dry-runshows what would be written and writes nothing. Use it first wherever it exists.-yor--yesanswers "yes" to every question, so commands can run in scripts and CI.--json(ondetect,list,doctorandvalidate) prints machine-readable output for scripts and coding agents.- Exit code
0means success. Anything else means a problem was found or the command failed.doctorandvalidateexit non-zero when they report errors, so they can fail a CI job. init,addandadd-frontendonly create files. They never overwrite one that exists.
In a full-stack project
At the root of a project with server/ and client/, doctor, validate, diff and upgrade cover both packages. The db commands find server/ on their own.
Using the CLI in CI
yaml
- run: npx selfauth validate
- run: npx selfauth doctorThe first fails the build if the configuration is invalid or the schema and manifest disagree. The second reports production readiness warnings.