Requirements
Section titled “Requirements”| Package | Required | Purpose |
|---|---|---|
quadkit | Yes | Core framework |
quadkit-contracts | Yes | Protocol definitions |
quadkit-web | Yes | Web UI support |
The Problem quadkit-cli Solves
Section titled “The Problem quadkit-cli Solves”Building a Quadkit application involves repeated setup: project scaffolding, code generation, database migrations, and runtime inspection. quadkit-cli automates these tasks through a single quadkit command, using a contributor-based plugin system where packages extend the CLI via quadkit.cli.contributors entry points.
Mental model: Think of quadkit-cli as the framework’s toolbox — one command to create, build, run, and introspect your application.
Core Concepts
Section titled “Core Concepts”- Command groups — commands are organized as sub-Typer apps (
new,run,dev,db,gen,inspect,shell, etc.) - Contributors — packages advertise commands, generators, health checks, shell context, and hooks via
quadkit.cli.contributors; discovered at import with automatic conflict resolution - CLIContext — per-invocation shared state holding config, output mode (Rich/JSON/Quiet), and flags
OutputManager— centralized output with support for Rich formatting, JSON serialization, and debug modes
Full Command Walkthrough
Section titled “Full Command Walkthrough”Scaffolding (new, add)
Section titled “Scaffolding (new, add)”# Create a new project from a templatequadkit new project my-app --template web-api -d ./projects
# Create a project interactivelyquadkit new project my-app -i
# Scaffold a new quadkit-* extension packagequadkit new package my-feature
# Add a provider to an existing projectquadkit add webquadkit add sqlAvailable templates: web-api, full, api.
Dev Server (run, dev)
Section titled “Dev Server (run, dev)”# Auto-detect create_app() and start the serverquadkit run
# Explicit entry pointquadkit run my_app.app:create_app --port 9000 --no-reload
# Development server with hot-reloadquadkit dev --entry src/main.py --port 8000 --env development
# Use a specific server backendquadkit run --server granian
# Run with an MCP SSE server alongsidequadkit run --mcp-port 8080The CLI auto-detects the server backend, preferring Granian → Uvicorn → Hypercorn based on availability.
Database Management (db)
Section titled “Database Management (db)”# Create/upgrade a database and generate an initial migrationquadkit db init
# Auto-generate a migration from schema changesquadkit db migrate -m "add email to users"
# Apply pending migrationsquadkit db upgrade
# Rollback the last migrationquadkit db rollback
# View migration statusquadkit db status
# Seed test dataquadkit db seed
# View migration historyquadkit db listDatabase commands need the package that provides the database provider. No public package ships one yet, so db reports ProviderNotInstalledError.
Code Generation (gen)
Section titled “Code Generation (gen)”# List all available generatorsquadkit gen list
# Generate codequadkit gen domain Userquadkit gen service UserServicequadkit gen repository UserRepositoryquadkit gen controller UserControllerGenerators are contributed by installed packages. Each generator creates files in the current project’s source tree.
Runtime Inspection (inspect)
Section titled “Runtime Inspection (inspect)”# List registered container providersquadkit inspect providers
# Show HTTP routesquadkit inspect routes
# Display container bindingsquadkit inspect container
# Run health checksquadkit inspect health
# View service listquadkit inspect servicesInteractive Shell (shell)
Section titled “Interactive Shell (shell)”# Start a REPL with the application context pre-loadedquadkit shell
# Plain Python REPL without app bootstrapquadkit shell --no-app
# Use IPython if availablequadkit shell --ipythonThe shell provides app, container, config, db, cache, and events as pre-loaded objects.
Other Commands
Section titled “Other Commands”# System informationquadkit system infoquadkit version
# Configuration managementquadkit config showquadkit config schemaquadkit config init --output application.yaml
# Contributor discoveryquadkit contrib checkquadkit contrib list
# Meta commandsquadkit list # list all commandsquadkit completion # generate shell completionquadkit test # run project testsquadkit lint # run project lintersIntegration with the DI Container
Section titled “Integration with the DI Container”from quadkit import Applicationfrom quadkit.cli import CLIModule, CLIConfigfrom quadkit.cli.di.provider import CLIProvider
# Via module (recommended)app = Application(name="my-app")app.add_module(CLIModule.configure(CLIConfig(color=False)))
# Via provider directlyprovider = CLIProvider(config=CLIConfig(color=False))app.add_provider(provider)The CLIProvider has priority APPLICATION (40) — it boots after infrastructure but before domain services.
Best Practices
Section titled “Best Practices”- ✅ Run
quadkit gen listto see all available generators from installed packages - ✅ Use
quadkit project test/lintas a pre-commit gate - ✅ Run
quadkit contrib checkto verify contributors load cleanly after adding packages - ✅ Use
--jsonflag for machine-readable output (useful in CI scripts) - ❌ Don’t manually edit generated file headers — re-run the generator instead
- ❌ Don’t use
quadkit runin production — deploy through your ASGI server directly