ZinTrust CLI - Quick Start Guide
Installation
The ZinTrust CLI is distributed on npm as @zintrust/core.
# Install globally from npm
npm install -g @zintrust/core
# Verify installation
zin --versionDevelopment (from source)
If you are working on the framework itself:
# Install dependencies
npm install
npm run build
# Make available globally
npm linkBasic Commands
Create New Project
zin new my-appNew projects ship with an .env generated during scaffolding. If values are missing/empty, the CLI backfills safe defaults:
HOST=localhostPORT=7777LOG_LEVEL=debug
Database Migrations
zin migrate # Run pending migrations
zin migrate --fresh # Drop all & re-run
zin migrate --rollback # Undo last batch
zin migrate --reset # Undo allAdd Components
The add command scaffolds various components for your application:
zin add model User # Create a model
zin add controller UserController # Create a controller
zin cm user # Create create_users_table migration
zin am bio user # Create add_bio_users_table migration (requires create_users_table)
zin add migration custom_name # Create a custom migration (advanced)
zin add service auth # Create a microservice
zin add workflow # Create deployment workflowsFor a full list of types, see the CLI Reference.
List Routes
To print a table of every registered route (including middleware/validation metadata), run:
zin routesIf you want the URL column to be fully qualified, set BASE_URL and PORT:
BASE_URL=http://127.0.0.1 PORT=7777 zin routesYou can also group and filter:
zin routes --group-by service --filter auth
zin routes --method GET,POST
zin routes --jsonDebug Mode
zin debug # Start debug server
zin debug --port 3001 # Custom port
zin debug --enable-profiling # Enable memory profiling
zin debug --enable-tracing # Enable request tracingConfiguration
zin config list # Show all settings
zin config get user.email # Get specific setting
zin config set user.email user@example.com
zin config reset # Reset to defaultsSecurity
zin key:generate # Generate APP_KEY
zin key:generate --show # Show key without saving
# Mint a dev JWT for testing protected routes (prints a token)
zin jwt:dev --sub 1 --email dev@example.com --role admin
zin jwt:dev --json --expires 30mPlugin Management
Manage framework extensions and database adapters.
zin plugin list # List available plugins
zin plugin install a:sqlite # Install SQLite adapter
zin p -i a:postgres # Short syntax for installing Postgres
# Modular adapter/driver shortcut (delegates to plugin installer)
zin add db:sqlite
zin add db:postgres
zin add queue:redis
zin add broadcast:redis
zin add cache:redis
zin add mail:nodemailer
# Choose a package manager explicitly (optional)
zin add db:sqlite --package-manager pnpmSee Plugin System for more details.
Quality Assurance
zin fix # Run automated code fixes
zin qa # Run full QA suite
zin qa --no-sonar # Skip Sonar analysis
zin qa --report # Generate HTML reportHelp System
# Main help
zin --help
zin -h
zin help
# Command-specific help
zin new --help
zin migrate --help
zin debug --help
# Alternative help syntax
zin help new
zin help migrateVersion
zin --version
zin -vExit Codes
| Code | Meaning | Example |
|---|---|---|
| 0 | Success | zin new my-app succeeds |
| 1 | Runtime error | Database connection fails |
| 2 | Usage error | Missing required argument |
Interactive Mode
All commands support interactive prompts:
zin new my-app
# Will prompt for:
# - Project name (if not provided)
# - Database type (PostgreSQL, MySQL, SQLite)
# - Server port (default 7777)
# - Git initialization (yes/no)Non-Interactive Mode (CI/CD)
# Skip all prompts, use defaults
zin new my-app --no-interactive
zin new my-app --database postgres --port 7777 --no-gitGlobal Options (All Commands)
--verbose, -v # Enable verbose output
--help, -h # Show helpExample:
zin new my-app -v # Create project with verbose loggingCommand Reference
zin new
Create a new ZinTrust project
Usage: zin new <name> [options]
Arguments:
<name>- Project directory name
Options:
--database <type>- Database (postgresql, mysql, sqlite)--port <number>- Server port (default: 7777)--no-interactive- Skip prompts--no-git- Skip git initialization-v, --verbose- Verbose output
Examples:
zin new my-app
zin new my-app --database mysql --port 3001
zin new my-app --no-interactive --no-gitzin add
Add components (generators) and install plugins
Usage: zin add <type> [name] [options]
Arguments:
<type>- Generator type (model, controller, migration, service, workflow, etc) OR plugin id/alias (db:sqlite,queue:redis, ...)[name]- Name for generators that require it (omit for plugin ids likedb:sqlite)
Examples:
zin add auth
zin add payments
# Plugin-style installs via `zin add <domain>:<driver>`
zin add db:sqlite
zin add queue:redis --package-manager pnpmzin migrate
Run database migrations
Usage: zin migrate [options]
Options:
--fresh- Drop all tables and re-run migrations--rollback- Rollback last migration batch--reset- Rollback all migrations--status- Show migration status--all- Run migrations for all configured database connections--service <domain/name>- Run global + service-local migrations--only-service <domain/name>- Run only service-local migrations--step <number>- Number of batches to rollback (for--rollback)--force- Allow running migrations in production without prompts--no-interactive- Skip interactive prompts--local- D1 only: run migrations against local D1 database--remote- D1 only: run migrations against remote D1 database--database <name>- D1 only: D1 database name
Notes:
- If
DB_CONNECTIONisd1/d1-remote,zin migratesupports apply-only (it compiles TS migrations to Wrangler SQL and then applies via Wrangler). For rollback/reset/status, use Wrangler subcommands (orzin d1:migratefor apply).
Examples:
zin migrate
zin migrate --status
zin migrate --fresh
zin migrate --rollback
zin migrate --rollback --step 2
# D1 (local by default)
zin migrate --local --database zintrust_db
# Run for all connections
zin migrate --all
# CI / non-interactive production deploys
zin migrate --force --no-interactivezin debug
Launch debug mode with profiling
Usage: zin debug [options]
Options:
--port <number>- Debug server port (default: 3000)--enable-profiling- Enable memory profiling--enable-tracing- Enable request tracing
Examples:
zin debug
zin debug --port 3001
zin debug --enable-profiling --enable-tracingzin config
Manage ZinTrust configuration
Usage: zin config <subcommand> [args]
Subcommands:
list- Show all configurationget [key]- Get specific configuration valueset <key> <value>- Set configuration valuereset [key]- Reset to defaults
Examples:
zin config list
zin config get user.email
zin config set user.email user@example.com
zin config resetzin start
Start the application in development (watch), production, or Wrangler mode.
Usage: zin start [options]
Options:
-w, --wrangler- Start with Wrangler dev mode (Cloudflare Workers)--wg- Alias for--wrangler--deno- Start a local server using the Deno runtime adapter--lambda- Start a local server using the AWS Lambda runtime adapter--watch- Force watch mode (Node only)--no-watch- Disable watch mode (Node only)--mode <development|production|testing>- Override app mode--runtime <nodejs|cloudflare|lambda|deno|auto>- SetRUNTIMEfor spawned Node process--port <number>- Override server port (setsPORT)
Examples:
zin start
zin start --mode production
zin start --no-watch --port 3001
zin start -w
zin start --wg
zin start --deno
zin start --lambdaWhich start mode should I use?
zin start(default) - Runs the app in Node.js. Use this for day-to-day development and local debugging.zin start --wg/zin start -w- Runs the app in Cloudflare Workers via Wrangler dev. Use this when your deployment target is Workers or you want to catch Workers-only constraints early (no native Node addons, limited filesystem, and no disallowed global-scope side effects).zin start --lambda- Runs the app using the AWS Lambda runtime adapter. Use this when your deployment target is Lambda and you want to validate Lambda-style request handling.zin start --deno- Runs the app using the Deno runtime adapter. Use this when deploying on Deno or when you want to ensure your code avoids Node-only assumptions.
When NOT to use
- Don’t use
--wg/--wranglerif your request path depends on Node-only features (e.g. local filesystem writes, raw TCP sockets, or native modules likebetter-sqlite3). - Don’t use
--lambdaor--denounless you are targeting those runtimes; they exist primarily to catch runtime-specific differences.
Notes:
--runtimeaffects the spawned Node process only; it does not change Wrangler’s runtime.- If you see “Address already in use”, pass a different port:
zin start --wg --port 8787.
Troubleshooting
Command not found
# Make sure to install globally
npm link
# Or verify npm install completed
npm installPermission denied
# Make scripts executable
chmod +x bin/zintrust.ts bin/zin.ts bin/z.tsPort already in use
# Use different port
zin debug --port 3001
zin start --port 3001Interactive prompts in CI/CD
# Use --no-interactive flag
zin new my-app --no-interactive --database postgres --port 3000Environment Variables
Configure ZinTrust via environment variables:
# Database
export DB_CONNECTION=postgresql
export DB_HOST=localhost
export DB_DATABASE=zintrust_dev
# Server
export APP_PORT=3000
export APP_DEBUG=true
# Logging
export LOG_LEVEL=debug
export LOG_PATH=./logs
# Microservices
export MICROSERVICES=true
export MICROSERVICES_TRACING=trueConfiguration File
Project configuration at .zintrust.json:
{
"project": {
"name": "my-app",
"port": 3000
},
"database": {
"connection": "postgresql",
"host": "localhost",
"database": "zintrust_dev"
},
"features": ["auth", "payments"]
}Global configuration at ~/.zintrust/config.json:
{
"user": {
"email": "user@example.com"
},
"defaults": {
"database": "postgresql",
"port": 3000
}
}For more information, see the full documentation or run zin --help.