Commands - nself-org/nchat GitHub Wiki

nself CLI - Commands Reference

Version: v1.0.9 Last Updated: April 18, 2026 Complete command reference for nself CLI


Table of Contents

  1. Global Options
  2. Project Commands
  3. Service Commands
  4. Database Commands
  5. Development Commands
  6. Utility Commands
  7. Advanced Commands
  8. Environment Variables

Global Options

Available for all commands:

nself [command] [options]

Global Flags:
  --help, -h          Show help for any command
  --version, -v       Show nself CLI version
  --verbose           Enable verbose output
  --quiet, -q         Suppress non-error output
  --config FILE       Use custom config file
  --project-dir DIR   Specify project directory (default: .backend)

Project Commands

nself init

Initialize a new nself project.

Syntax:

nself init [PROJECT_NAME] [options]

Options:

--template, -t TEMPLATE    Use project template (default, minimal, full)
--demo                     Initialize with demo data
--no-ssl                   Skip SSL certificate generation
--domain DOMAIN           Set custom domain (default: localhost)
--env ENV                 Set environment (dev, staging, prod)

Examples:

# Basic initialization
nself init my-app

# Initialize with demo data
nself init my-app --demo

# Minimal setup (core services only)
nself init my-app --template minimal

# Full setup (all services enabled)
nself init my-app --template full

# Custom domain
nself init my-app --domain myapp.local

# Production environment
nself init my-app --env prod

Generated Structure:

PROJECT_NAME/
└── .backend/
    ├── .env                      # Environment variables
    ├── docker-compose.yml        # Service definitions
    ├── hasura/
    │   ├── metadata/            # Hasura metadata
    │   └── migrations/          # Database migrations
    ├── nginx/
    │   ├── nginx.conf           # Nginx config
    │   └── conf.d/              # Site configs
    ├── postgres/
    │   └── init/                # Init scripts
    └── ssl/
        └── certificates/        # SSL certs

nself build

Generate or update docker-compose.yml file.

Syntax:

nself build [options]

Options:

--update                Update existing configuration
--force                 Overwrite without confirmation
--services SERVICES     Enable specific services (comma-separated)
--monitoring           Enable monitoring bundle
--output FILE          Output to specific file

Examples:

# Regenerate docker-compose.yml
nself build

# Update with new services
nself build --update --services redis,minio

# Enable monitoring
nself build --monitoring

# Force overwrite
nself build --force

Service Commands

nself start

Start all or specific services.

Syntax:

nself start [SERVICE...] [options]

Options:

--detach, -d           Run in background (default)
--build               Build images before starting
--force-recreate      Recreate containers
--no-deps             Don't start linked services
--scale SERVICE=NUM   Scale service to NUM instances
--wait                Wait for services to be healthy

Examples:

# Start all services
nself start

# Start specific services
nself start postgres hasura

# Start with rebuild
nself start --build

# Start and wait for healthy
nself start --wait

# Scale Hasura to 3 instances
nself start --scale hasura=3

# Start in foreground (view logs)
nself start --no-detach

Service Names:

  • postgres - PostgreSQL database
  • hasura - Hasura GraphQL Engine
  • auth - Nhost Auth service
  • nginx - Nginx reverse proxy
  • minio - MinIO object storage
  • storage - Hasura Storage service
  • redis - Redis cache
  • mailpit - Email testing
  • functions - Serverless functions
  • meilisearch - Full-text search
  • mlflow - ML tracking

nself stop

Stop all or specific services.

Syntax:

nself stop [SERVICE...] [options]

Options:

--timeout, -t SECONDS   Shutdown timeout (default: 10)

Examples:

# Stop all services
nself stop

# Stop specific services
nself stop hasura auth

# Stop with 30s timeout
nself stop --timeout 30

# Stop immediately (force)
nself stop --timeout 0

nself restart

Restart all or specific services.

Syntax:

nself restart [SERVICE...] [options]

Options:

--timeout, -t SECONDS   Shutdown timeout
--no-deps              Don't restart linked services

Examples:

# Restart all services
nself restart

# Restart specific service
nself restart hasura

# Restart with quick timeout
nself restart --timeout 5

nself status

Show status of all services.

Syntax:

nself status [options]

Options:

--format FORMAT    Output format (table, json, yaml)
--watch, -w        Continuously watch status

Examples:

# Show status (default table format)
nself status

# JSON output
nself status --format json

# Watch status (refresh every 2s)
nself status --watch

# YAML output
nself status --format yaml

Output:

Service     Status    Health    Port    Uptime
─────────────────────────────────────────────────
postgres    running   healthy   5432    2h 15m
hasura      running   healthy   8080    2h 14m
auth        running   healthy   4000    2h 14m
nginx       running   healthy   80/443  2h 14m
redis       running   healthy   6379    2h 14m
minio       running   healthy   9000    2h 14m
storage     running   healthy   5001    2h 13m
mailpit     running   healthy   8025    2h 13m

nself logs

View service logs.

Syntax:

nself logs [SERVICE...] [options]

Options:

--follow, -f          Follow log output
--tail LINES          Number of lines to show (default: 100)
--since TIME          Show logs since timestamp
--until TIME          Show logs until timestamp
--timestamps, -t      Show timestamps
--no-color            Disable colored output

Examples:

# View all logs
nself logs

# Follow specific service
nself logs -f hasura

# Last 50 lines
nself logs --tail 50

# Multiple services
nself logs postgres hasura auth

# Since 1 hour ago
nself logs --since 1h

# With timestamps
nself logs -f -t hasura

# Last 30 minutes
nself logs --since 30m --until now

nself ps

List running containers.

Syntax:

nself ps [options]

Options:

--all, -a        Show all containers (including stopped)
--quiet, -q      Only show container IDs
--services       Show service names

Examples:

# List running containers
nself ps

# Show all (including stopped)
nself ps --all

# Just container IDs
nself ps --quiet

# Service names only
nself ps --services

nself down

Stop and remove containers.

Syntax:

nself down [options]

Options:

--volumes, -v          Remove volumes
--remove-orphans       Remove orphaned containers
--timeout SECONDS      Shutdown timeout

Examples:

# Stop and remove containers
nself down

# Also remove volumes (WARNING: deletes data!)
nself down --volumes

# Remove orphaned containers
nself down --remove-orphans

# Quick shutdown
nself down --timeout 0

nself exec

Execute command in a running service.

Syntax:

nself exec [SERVICE] [COMMAND]

Options:

--user, -u USER     Run as user
--workdir DIR       Working directory
--env KEY=VALUE     Set environment variable
--detach, -d        Detached mode
--interactive, -i   Interactive mode
--tty, -t          Allocate pseudo-TTY

Examples:

# Open PostgreSQL shell
nself exec postgres psql -U postgres

# Run Hasura console command
nself exec hasura hasura-cli console

# Interactive shell
nself exec -it postgres bash

# Run as specific user
nself exec --user postgres postgres psql

# Execute with environment variable
nself exec --env DEBUG=true hasura node index.js

Database Commands

nself db:migrate

Run database migrations.

Syntax:

nself db:migrate [DIRECTION] [options]

Directions:

  • up - Apply migrations (default)
  • down - Rollback migrations
  • status - Show migration status
  • version - Show current version

Options:

--step, -s NUMBER     Number of migrations to apply/rollback
--version VERSION     Migrate to specific version
--all                Apply all pending migrations
--dry-run            Show what would be executed

Examples:

# Apply all pending migrations
nself db:migrate up

# Rollback last migration
nself db:migrate down

# Rollback 3 migrations
nself db:migrate down --step 3

# Migrate to specific version
nself db:migrate --version 20260101120000

# Show migration status
nself db:migrate status

# Dry run
nself db:migrate up --dry-run

nself db:create

Create new database migration.

Syntax:

nself db:create [NAME] [options]

Options:

--sql FILE          Use SQL file
--type TYPE         Migration type (sql, hasura)
--timestamp         Add timestamp to name

Examples:

# Create migration
nself db:create create_users_table

# From SQL file
nself db:create --sql schema.sql add_users

# Hasura migration
nself db:create --type hasura add_permissions

nself db:seed

Seed database with data.

Syntax:

nself db:seed [FILE] [options]

Options:

--env ENV          Environment (dev, staging, prod)
--force           Overwrite existing data

Examples:

# Run default seed file
nself db:seed

# Specific seed file
nself db:seed seeds/users.sql

# Force seed (clear existing)
nself db:seed --force

nself db:reset

Reset database (WARNING: destructive!).

Syntax:

nself db:reset [options]

Options:

--force          Skip confirmation
--seed          Run seeds after reset

Examples:

# Reset database (will ask confirmation)
nself db:reset

# Reset and seed
nself db:reset --seed

# Force reset (no confirmation)
nself db:reset --force

nself db:dump

Backup database to file.

Syntax:

nself db:dump [FILE] [options]

Options:

--format FORMAT      Output format (sql, custom, tar)
--compress          Compress output
--schema-only       Only dump schema
--data-only         Only dump data

Examples:

# Dump to default file
nself db:dump

# Dump to specific file
nself db:dump backup.sql

# Compressed backup
nself db:dump backup.sql.gz --compress

# Schema only
nself db:dump schema.sql --schema-only

nself db:restore

Restore database from backup.

Syntax:

nself db:restore [FILE] [options]

Options:

--force          Drop existing database
--clean         Clean before restore

Examples:

# Restore from file
nself db:restore backup.sql

# Force restore (drop existing)
nself db:restore backup.sql --force

# Clean restore
nself db:restore backup.sql --clean

Development Commands

nself console

Open Hasura Console.

Syntax:

nself console [options]

Options:

--port PORT         Console port (default: 9695)
--no-browser       Don't open browser

Examples:

# Open console
nself console

# Custom port
nself console --port 9696

# Don't auto-open browser
nself console --no-browser

nself urls

Show all service URLs.

Syntax:

nself urls [options]

Options:

--format FORMAT    Output format (table, json, list)

Examples:

# Show URLs (table format)
nself urls

# JSON format
nself urls --format json

# Simple list
nself urls --format list

Output:

Service          URL
────────────────────────────────────────────────
GraphQL API      http://api.localhost/v1/graphql
Hasura Console   http://localhost:8080/console
Auth API         http://auth.localhost/v1/auth
Storage API      http://storage.localhost/v1/storage
MinIO Console    http://localhost:9001
Email Testing    http://localhost:8025
PostgreSQL       localhost:5432
Redis            localhost:6379

nself doctor

Diagnose common issues.

Syntax:

nself doctor [options]

Options:

--fix             Attempt to fix issues
--verbose        Show detailed diagnostics

Examples:

# Run diagnostics
nself doctor

# Fix issues automatically
nself doctor --fix

# Verbose output
nself doctor --verbose

Checks:

  • Docker installation
  • Docker Compose version
  • Port availability
  • Disk space
  • Memory available
  • Service health
  • Network connectivity
  • Configuration validity

nself dev

Start development mode with hot reload.

Syntax:

nself dev [options]

Options:

--watch           Watch for file changes
--reload          Auto-reload on changes

Examples:

# Start dev mode
nself dev

# With file watching
nself dev --watch

# Auto-reload services
nself dev --reload

Utility Commands

nself config

Manage configuration.

Syntax:

nself config [SUBCOMMAND] [options]

Subcommands:

get KEY             Get configuration value
set KEY VALUE       Set configuration value
list                List all configuration
edit                Edit configuration file
validate            Validate configuration
reset               Reset to defaults

Examples:

# List all config
nself config list

# Get specific value
nself config get PROJECT_NAME

# Set value
nself config set REDIS_ENABLED true

# Edit config file
nself config edit

# Validate config
nself config validate

# Reset to defaults
nself config reset

nself env

Manage environment variables.

Syntax:

nself env [SUBCOMMAND]

Subcommands:

list                List all variables
get KEY             Get variable value
set KEY VALUE       Set variable value
unset KEY           Remove variable
export              Export to .env file
import FILE         Import from file

Examples:

# List all env vars
nself env list

# Get value
nself env get DATABASE_URL

# Set value
nself env set REDIS_ENABLED true

# Export to file
nself env export > .env.backup

# Import from file
nself env import .env.backup

nself backup

Create backup of project.

Syntax:

nself backup [options]

Options:

--output DIR        Output directory
--compress         Compress backup
--database-only    Only backup database
--config-only      Only backup configuration

Examples:

# Full backup
nself backup

# Backup to specific directory
nself backup --output backups/

# Compressed backup
nself backup --compress

# Database only
nself backup --database-only

nself restore

Restore from backup.

Syntax:

nself restore [BACKUP_FILE] [options]

Options:

--force           Overwrite existing
--database-only   Only restore database
--config-only     Only restore config

Examples:

# Restore from backup
nself restore backup-2026-02-01.tar.gz

# Force restore
nself restore backup.tar.gz --force

# Database only
nself restore backup.tar.gz --database-only

nself clean

Clean up Docker resources.

Syntax:

nself clean [options]

Options:

--all              Remove all resources
--volumes          Remove volumes
--images           Remove images
--force            Skip confirmation

Examples:

# Clean stopped containers
nself clean

# Clean everything (WARNING!)
nself clean --all

# Remove volumes
nself clean --volumes

# Force clean
nself clean --all --force

nself upgrade

Upgrade nself CLI.

Syntax:

nself upgrade [options]

Options:

--version VERSION    Upgrade to specific version
--check             Only check for updates

Examples:

# Upgrade to latest
nself upgrade

# Check for updates
nself upgrade --check

# Upgrade to specific version
nself upgrade --version v0.4.2

Advanced Commands

nself network

Manage Docker networks.

Syntax:

nself network [SUBCOMMAND]

Subcommands:

create              Create network
remove              Remove network
inspect             Inspect network
list                List networks

Examples:

# List networks
nself network list

# Inspect network
nself network inspect

# Recreate network
nself network remove
nself network create

nself volume

Manage Docker volumes.

Syntax:

nself volume [SUBCOMMAND]

Subcommands:

list                List volumes
inspect VOLUME      Inspect volume
remove VOLUME       Remove volume
prune              Remove unused volumes

Examples:

# List volumes
nself volume list

# Inspect postgres volume
nself volume inspect postgres_data

# Remove specific volume
nself volume remove redis_data

# Remove unused volumes
nself volume prune

nself metrics

View service metrics.

Syntax:

nself metrics [SERVICE] [options]

Options:

--interval SECONDS   Update interval (default: 5)
--format FORMAT     Output format (table, json)

Examples:

# View all metrics
nself metrics

# Specific service
nself metrics postgres

# JSON output
nself metrics --format json

# Update every 2 seconds
nself metrics --interval 2

Environment Variables

Configuration Variables

# Project Settings
PROJECT_NAME=my-app
BASE_DOMAIN=localhost
ENV=dev

# Service Ports
POSTGRES_PORT=5432
HASURA_PORT=8080
REDIS_PORT=6379
MINIO_PORT=9000

# Optional Services
REDIS_ENABLED=true
MINIO_ENABLED=true
MAILPIT_ENABLED=true
MEILISEARCH_ENABLED=false
FUNCTIONS_ENABLED=false
MONITORING_ENABLED=false
NSELF_ADMIN_ENABLED=false

# Database
POSTGRES_DB=myapp_dev
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres-dev-password

# Hasura
HASURA_GRAPHQL_ADMIN_SECRET=hasura-admin-secret-dev
HASURA_GRAPHQL_ENABLE_CONSOLE=true
HASURA_GRAPHQL_DEV_MODE=true

# Auth
AUTH_JWT_REFRESH_TOKEN_EXPIRES_IN=2592000
AUTH_JWT_ACCESS_TOKEN_EXPIRES_IN=900

# Storage
MINIO_ROOT_USER=minioadmin
MINIO_ROOT_PASSWORD=minioadmin

# Development
AUTO_FIX=true
COMPOSE_PROJECT_NAME=${PROJECT_NAME}

Exit Codes

0   Success
1   General error
2   Misuse of shell command
126 Command cannot execute
127 Command not found
130 Script terminated by Ctrl+C

Tips and Tricks

Command Aliases

Add to your shell rc file (.bashrc, .zshrc):

# Short aliases
alias ns='nself'
alias nss='nself status'
alias nsl='nself logs -f'
alias nsr='nself restart'

# Quick commands
alias nsup='nself start'
alias nsdown='nself stop'
alias nslogs='nself logs -f --tail 100'

Watch Status

# Continuously monitor status
watch -n 2 nself status

# Or use built-in watch
nself status --watch

Quick Database Access

# Create shell function
db() {
  nself exec postgres psql -U postgres -d ${PROJECT_NAME}_dev
}

# Usage
db

Log Multiple Services

# View logs from multiple services
nself logs -f postgres hasura auth | grep ERROR

Backup Before Changes

# Always backup before major changes
nself db:dump backup-before-change.sql
nself db:migrate up

Next Steps


Need help? Run nself --help or nself [command] --help for detailed information.

⚠️ **GitHub.com Fallback** ⚠️