The lexigram CLI
lexigram-cli ships the lexigram command — the day-to-day driver for every Lexigram project. It scaffolds new apps, runs the development server, drives database migrations, manages configuration, and exposes a plugin surface that lets installed extensions contribute their own subcommands.
For the full command reference, see the lexigram-cli package docs.
1. Install & Verify
Section titled “1. Install & Verify”pip install lexigram-cli # or: uv add lexigram-clilexigram --version # → lexigram <version>lexigram --help # full command listThe CLI is also pulled in transitively by most projects, so uv sync from a generated project is usually enough.
Global flags work on every subcommand:
| Flag | Effect |
|---|---|
--json | machine-readable output where supported |
--quiet, -q | suppress non-essential output |
--debug | print tracebacks on error |
--no-color | disable ANSI colour |
--config, -c | path to application.yaml |
2. Scaffolding a New Project
Section titled “2. Scaffolding a New Project”lexigram new project renders a project template from lexigram-cli/templates/project/:
lexigram new project my-app # default template: web-apilexigram new project my-app --template api # JSON API onlylexigram new project my-app --template full # web + db + auth + cachelexigram new project my-app --interactive # prompt for template/db/auth| Flag | Default | Notes |
|---|---|---|
--template, -t | web-api | one of api, web-api, full |
--directory, -d | . | parent directory for the new project |
--interactive, -i | false | prompts for template, database (sqlite/postgres/none), and auth (none/jwt) |
To scaffold a reusable extension package instead of an application:
lexigram new package my-feature # → lexigram-my-feature/ with src/ + provider stublexigram init writes a minimal application.yaml into an existing directory — useful when adopting Lexigram in a project that already has a pyproject.toml:
lexigram init --full # full config (web/db/auth/cache/monitor sections)lexigram init --minimal # just project + logging (default)lexigram init --force # overwrite an existing application.yamlSee Project Structure for what the templates lay down.
3. Running Locally
Section titled “3. Running Locally”Two commands launch your app — pick by intent:
lexigram run # production-shaped: --host 127.0.0.1, --reload onlexigram dev # development server, --reload on, LEX_ENV=developmentBoth auto-detect your entry point (src/main.py, create_app, etc.) using discover_entry_point and pick the best available server backend (prefers granian → uvicorn, falls back to hypercorn).
lexigram run flags:
| Flag | Default | Notes |
|---|---|---|
target (positional) | auto-detected | module:attr, e.g. my_app.app:create_app |
--host, -h | 127.0.0.1 | bind address |
--port, -p | 8000 | bind port |
--reload/--no-reload | true | hot reload |
--workers, -w | 1 | worker processes |
--profile | none | sets LEX_PROFILE for the run |
--server | auto | uvicorn, granian, or hypercorn |
--mcp-port | none | also serve MCP (SSE) on this port |
lexigram dev accepts --entry, --host, --port, --reload/--no-reload, --env, --server. For production, use lexigram dev start (binds 0.0.0.0, no reload, takes --workers) or invoke an ASGI server directly — see Deployment.
4. Database Migrations
Section titled “4. Database Migrations”lexigram db wraps lexigram-sql’s migration runner. The most common flow:
lexigram db init migrations # create migrations/ directorylexigram db create add_users_table # new empty migration filelexigram db upgrade # apply pending migrationslexigram db status # show current version + pendinglexigram db history --limit 20 # last N applied migrationslexigram db downgrade # roll back the most recentlexigram db downgrade 0003_seed # roll back to a specific versionInspection and maintenance:
lexigram db inspect # list tables + columnslexigram db inspect --table users # one table's columns + typeslexigram db shell # open psql / mysql / sqlite3 clientlexigram db validate # check applied migrations have fileslexigram db reset --force # drop & re-migrate (SQLite-optimized)lexigram db backup --output dump.sqllexigram db restore dump.sql --forceSeed scripts in seeds/*.py (each exposing a run(provider) function) are applied by lexigram db seed or as part of lexigram db reset --seed.
All db commands read DATABASE_URL from the environment (default sqlite:///./dev.db). When lexigram-sql is installed, the runner is resolved through the DI container so connection pooling and observability hooks are active.
See the Database guide for the repository pattern these migrations support.
5. Inspecting & Diagnosing
Section titled “5. Inspecting & Diagnosing”lexigram list # all available commands, groupedlexigram list --group Databaselexigram version --all # versions of every installed lexigram-* packagelexigram system info # Python version, platform, config pathlexigram system health # project + contributor health checkslexigram system doctor --fix # diagnostics with auto-fix hintslexigram system providers # provider sections in application.yamlInstalled extensions register CLI contributors — discover them with:
lexigram contrib list # all contributors + their contributionslexigram contrib inspect sql # generators/commands/health checks for onelexigram contrib check # verify every contributor loadsCode generation routes through contributors as well:
lexigram gen list # all discovered generatorslexigram gen provider MyProvider # core generator: scaffolds a provider class6. Configuration
Section titled “6. Configuration”The CLI looks for application.yaml in the current directory (and walks up to find one). Override with --config /path/to/app.yaml.
Profiles are environment-driven — set LEX_PROFILE=production and a matching application.production.yaml is overlaid on the base config. Any value can be overridden by a LEX_-prefixed env var with __ for nesting:
export LEX_PROFILE=stagingexport LEX_SQL__BACKEND__URL=postgresql+asyncpg://...Useful config commands:
lexigram config show # current resolved config (secrets masked)lexigram config show --reveal-secrets # unmaskedlexigram config validate # schema + cross-field validationlexigram config doctor --env production # environment-specific diagnosticslexigram config env # ${VAR} references and whether they're setlexigram config env --missing # exit 1 if any are unsetlexigram config env-example # generate .env.example from configlexigram config diff -c application.production.yamllexigram config schema # dump the JSON schemaSee Configuration and YAML Configuration for the full layering rules.
7. Adding Providers & Shell Completion
Section titled “7. Adding Providers & Shell Completion”lexigram add database # add lexigram-sql + db: section to YAMLlexigram add auth # add lexigram-auth + auth: sectionThe add command edits pyproject.toml (via uv add when available) and patches application.yaml with the provider’s default config block.
Generate shell completion:
lexigram completion --shell bash # also: zsh, fish, powershelleval "$(lexigram completion --shell zsh)"Next Steps
Section titled “Next Steps”- Your First App — the 60-second walkthrough using
lexigram newandlexigram run - Database & Persistence — the repository pattern these migrations feed
- Deployment & Infrastructure — running
lexigramin production lexigram-clipackage — full flag-by-flag reference and the contributor API