Skip to main content

Kysera CLI

Command-line interface for Kysera - database management, migrations, code generation, and more.

Installation

npm install -g @kysera/cli
# or
npx @kysera/cli <command>

Quick Start

# Initialize new project
kysera init my-app -d postgres

# Create a migration
kysera migrate create add_users_table

# Run migrations
kysera migrate up

# Generate CRUD for a table
kysera generate crud User

# Check database health
kysera health check

Global Options

All commands support these flags:

-v, --version          Show CLI version
--verbose Detailed output
-q, --quiet Minimal output
--dry-run Preview without executing
--config <path> Custom configuration file
--json Output as JSON
--no-color Disable colors
--env <environment> Set environment (default: development)
--stats Show CLI performance stats

Command Groups

init

Initialize new Kysera projects with interactive setup.

kysera init my-app
kysera init my-app -d postgres -t api

migrate

Database migration management.

kysera migrate create <name>
kysera migrate up
kysera migrate down
kysera migrate status

generate

Code generation from database schema.

kysera generate model User
kysera generate repository User
kysera generate crud User

db

Database utilities.

kysera db seed
kysera db tables
kysera db dump
kysera db restore

health

Health monitoring.

kysera health check
kysera health check --watch
kysera health metrics

test

Test environment management.

kysera test setup
kysera test seed
kysera test teardown

audit

Audit logging and history tracking.

kysera audit logs              # View audit logs
kysera audit history <id> # View entity history
kysera audit restore <id> # Restore from audit
kysera audit stats # Audit statistics
kysera audit cleanup # Clean old logs

debug

Debug and performance analysis tools.

kysera debug sql               # SQL query debugging
kysera debug profile # Performance profiling
kysera debug errors # Error analysis
kysera debug circuit-breaker # Circuit breaker status
kysera debug analyzer # Query analyzer

query

Database query utilities.

kysera query by-timestamp      # Query by timestamp range
kysera query soft-deleted # Manage soft-deleted records
kysera query analyze # Analyze query performance
kysera query explain # Show execution plan

repository

Repository introspection and management.

kysera repository list         # List all repositories
kysera repository inspect <n> # Inspect repository
kysera repository validate # Validate schemas
kysera repository methods # Show available methods

plugin

Plugin management and configuration.

kysera plugin list             # List available plugins
kysera plugin enable <name> # Enable a plugin
kysera plugin disable <name> # Disable a plugin
kysera plugin config <name> # Configure plugin

hello

Test command to verify CLI setup and configuration.

kysera hello                   # Basic greeting
kysera hello --name John # Custom greeting

stats

Show CLI performance statistics including command load times, cache hit rates, and usage patterns.

kysera stats                   # Display performance stats

Configuration

Create kysera.config.ts in your project root:

import { defineConfig } from '@kysera/cli'

export default defineConfig({
database: {
dialect: 'postgres',
host: process.env.DB_HOST || 'localhost',
port: parseInt(process.env.DB_PORT || '5432'),
database: process.env.DB_NAME || 'myapp',
user: process.env.DB_USER || 'postgres',
password: process.env.DB_PASSWORD
},
migrations: {
directory: './migrations',
tableName: 'kysera_migrations'
},
generation: {
outputDir: './src/generated',
typescript: true
}
})

See Configuration for full options.

Environment Support

  • Node.js 20+
  • Bun 1.0+
  • Database: PostgreSQL, MySQL, SQLite