CLI Commands Reference
Lila Framework v2.0.0 ships a unified CLI: lila <command>.
Legacy entry points such as lila-init, lila-dev,
lila-auth, lila-admin, lila-model,
lila-crud, lila-migrate, lila-seo,
lila-worker, lila-optimize and
lila-secret-key still exist and point at the same apps.
Project & Server
lila init scaffolds main.py, app/,
public/, resources/ and .env without overwriting
existing files. lila dev and lila run read
HOST/PORT from .env.
# Scaffold a project (never overwrites existing files / .env)
lila init
# Development server with reload + dev SSE (or: lila-dev)
lila dev
lila dev --host 0.0.0.0 --port 8080
# Production server, no reload (warns with >1 worker + memory cache)
lila run
lila run -w 2
# Health check and route introspection
lila doctor
lila routes
lila dev forces the development flag in the child server, enables Jinja
auto-reload and starts an SSE watcher for .jinja, .html,
.json, CSS and JS edits. The browser reloads itself when a view or locale
changes, even when watchfiles/uvicorn[standard] is not installed;
Python edits still use Uvicorn's normal reloader. --no-reload disables
Uvicorn's reloader and the browser watcher (a manual refresh still sees new templates).
Model Generator
lila model writes a starter SQLAlchemy model that inherits from
BaseModel (id, name, active,
created_at). It only asks for the model name — it is not a column wizard.
# Prompts for the model name
lila model create
# Non-interactive: writes app/models/product.py
lila model create --name Product
# Custom database table name
lila model create --name Product --table custom_products
# List model files in app/models/
lila model list-models
Generated Model
The template includes an indexed primary key, a name column, the
active soft-delete flag and created_at. Edit the file to add
your own columns; then run lila migrate (it also adds missing columns).
Scaffold Generator
Generate a full CRUD scaffold (Pydantic API + HTML DataTable) from an existing model.
# Generate scaffold from model (alias: lila-scaffold-crud) lila crud --model Product # Custom route slug lila crud --model Product --name products
Migrations
Create missing tables and add missing columns. --refresh drops every
table first and asks for confirmation unless --yes is passed.
# Create tables and add missing columns lila migrate # Drop everything and recreate (interactive confirmation) lila migrate --refresh # Same, without the confirmation prompt (destructive!) lila migrate --refresh --yes
Authentication
Generate the Auth 2.0 system: login, register, logout, forgot/change password,
dashboard/profile, OAuth routes and templates. Existing files are backed up as
.bak.
# Generate auth system (alias: lila-auth) lila auth # Templates or routes only lila auth --no-routes lila auth --no-templates
Admin Panel
Create/update the admins table entry and link the admin routes. The admin
panel lives at /admin.
# Create/update an administrator (password generated if omitted) lila admin lila admin --user admin --password mypassword # Aliases: lila-admin, lila-create-admin, lila-create-panel-admin lila-create-admin --username admin
Security Utilities
Generate a new secure SECRET_KEY for
your .env file.
# Replace SECRET_KEY in .env with a new randomly generated token lila secret-key # The same command is available as lila-secret-key
SEO Generators
Generate public/sitemap.xml
and public/robots.txt from
the public GET routes. They are served at /sitemap.xml and
/robots.txt (site root, not /public/).
# Generate both files (base URL from APP_URL in .env) lila seo # Generate one of them with an explicit domain lila seo sitemap --domain https://mywebsite.com lila seo robots --domain https://mywebsite.com
Asset Optimizer
Minify JS/CSS and convert PNG/JPG images to WebP. Requires
rjsmin/rcssmin for JS/CSS (otherwise it skips them) and
Pillow for images. See the Minify page.
lila optimize # alias: lila-optimize
Production Deploy Generator
Generate a systemd service (plus optional Redis worker unit), an Nginx
reverse proxy for Lila's real /public, /js,
/img, /swagger and /uploads paths,
a Bash starter and a Windows Server PowerShell starter. The generated
Nginx config enables WebSocket proxying, forwarded headers and
gzip_static on for the pre-compressed assets produced by
lila optimize. See Production for the
interactive sudo lila deploy setup assistant.
# Generate deploy/start_lila.sh, deploy/<domain>.nginx.conf and systemd unit
# (service name: --service-name, else SERVICE_NAME in .env, else folder name)
lila deploy --domain example.com --port 8000
# Also generate the Redis worker unit (requires CACHE_DRIVER=redis)
lila deploy --domain example.com --with-worker
# Override Unix service user/group and output directory
lila deploy --user www-data --group www-data --out-dir deploy
# Guided install on a Linux server (asks S/N before each change):
# .env for production, systemd service, Nginx site, Certbot HTTPS, health check
sudo "$(which lila)" deploy setup
sudo "$(which lila)" deploy setup --dry-run # only print the commands
sudo "$(which lila)" deploy setup --yes # accept defaults (needs APP_URL)
SQLite Hot Backup
Create a consistent online backup with SQLite's native
sqlite3.Connection.backup() while the server keeps writing.
Retention keeps the newest --max-backups files in the target
directory. The command refuses remote MySQL/PostgreSQL databases; use
the database vendor's dump tool for those.
# Back up the active SQLite DB into backups/ (keeps 7) lila backup # Explicit source and directory, keep 14 copies lila backup --source lila.sqlite --output backups --max-backups 14 # Explicit destination file lila backup --output backups/lila_before_release.sqlite
Desktop Mode (Native Window & Executables)
Run your application inside a native OS window (pywebview, or Edge/Chrome app mode as a
fallback) or bundle it with PyInstaller. lila desktop dev loads
.env; lila desktop build bundles main,
app and Lila templates/assets into dist/<name>.
Desktop mode binds the server to 127.0.0.1, allows one
instance, and gates the session with a per-run local token (the first
navigation uses ?_dt=… and is immediately exchanged for an
HttpOnly cookie).
# Run locally in a native desktop window (pywebview or Chromium App Mode)
lila desktop dev
# Launch with custom dimensions
lila desktop dev --title "My App" --width 1280 --height 800
# Compile a standalone executable (.exe / binary) via PyInstaller
lila desktop build --name "MyDesktopApp" --onefile --windowed
Background Task Worker
Without Redis it consumes the SQLite task queue (app/data/lila_tasks.db,
see Tasks); with CACHE_DRIVER=redis (or --driver redis)
it consumes JSON tasks from Redis (lila:tasks), which requires the
[redis] extra and a reachable Redis server. Modules must be in
LILA_TASK_MODULES (default app.,lila.); failed tasks are
retried and then sent to the dead-letter queue lila:tasks:dead.
# All three forms start the worker lila worker lila worker start lila-worker start
New commands
Performance, background work and checks (see Performance, Tasks, Testing).
lila css build [--watch] # compiled Tailwind CSS (no Node.js)
lila css clean
lila bench URL -c 50 -d 10 --pid N # req/s, latency, server RSS
lila run --server granian [--max-rss 300]
lila migrate --plan | --drop-columns | history
lila worker --driver sqlite -c 4 # SQLite task queue consumer
lila tasks stats | list | retry ID | purge
lila schedule list | run NAME
lila i18n check [--strict]
lila backup --compress
lila doctor # now also checks .env values, translations and compiled CSS