CLI¶
Command-line interface for Aksara development.
Overview¶
The Aksara CLI provides commands for:
| Category | Commands |
|---|---|
| Project | startproject, startapp |
| Database | dbsetup, makemigrations, migrate, shell |
| Development | dev, run, routes, info |
| Codegen | generate sdk |
| AI | ai query, ai generate, ai doctor |
Quick Start¶
Installation¶
The CLI is included with Aksara:
Basic Usage¶
# Show help
aksara --help
# Show version
aksara --version
# Start development server
aksara dev
# Suppress non-error Aksara UI output
aksara --quiet dev
Project Commands¶
startproject¶
Create a new Aksara project:
Creates:
myproject/
├── myproject/
│ ├── __init__.py
│ ├── settings.py
│ ├── app.py
│ └── models.py
├── tests/
│ └── __init__.py
└── pyproject.toml
Options:
aksara startproject myproject --directory /path/to/dir
aksara startproject myproject --template minimal # or "full", "api"
startapp¶
Create a new app within your project:
Creates:
Database Commands¶
dbsetup¶
Interactively set up a PostgreSQL database for the current project:
This checks for PostgreSQL, prompts for credentials, tests the connection, creates the database, and writes DATABASE_URL to .env.
Options:
makemigrations¶
Generate migrations from model changes:
Output:
Options:
aksara makemigrations --app app.models # Specify models module
aksara makemigrations --name add_slug # Custom name
aksara makemigrations --output dir # Custom output directory
aksara makemigrations --stdout # Preview to stdout
migrate¶
Apply pending migrations from the project migrations/ directory:
Output:
Applying 0001_auto_initial... ✓ Applied successfully
Applying 0002_auto_add_post_slug... ✓ Applied successfully
Options:
aksara migrate --dry-run # Preview without applying
aksara migrate --fake # Mark as applied without running
aksara migrate --migrations-dir dir # Custom migrations directory
aksara migrate --database-url URL # Specify database
shell¶
Interactive Python shell with models loaded:
Options:
aksara shell --database-url postgresql://postgres:password@localhost:5432/myapp
aksara shell --no-ipython
Development Commands¶
dev¶
Preferred development server with the rich startup banner:
You can also reach the same path with the alias:
Options:
aksara dev --port 3000
aksara dev --host 0.0.0.0
aksara dev --no-reload
aksara dev myproject.main:app --log-level debug
run¶
Start a specific ASGI app path directly with Uvicorn-style options:
Output:
Options:
aksara run main:app --port 3000
aksara run main:app --host 0.0.0.0
aksara run main:app --reload # Auto-reload on changes
aksara run myproject.main:app --workers 4 # Multiple workers
routes¶
List all registered routes:
Output:
Method Path Name
-------- ------------------------ ----------------
GET /api/posts/ posts-list
POST /api/posts/ posts-create
GET /api/posts/{id}/ posts-detail
PUT /api/posts/{id}/ posts-update
DELETE /api/posts/{id}/ posts-delete
POST /api/posts/{id}/publish/ posts-publish
Options:
generate sdk¶
Generate a TypeScript client from discovered ModelViewSet classes:
Print the generated SDK to stdout:
Target a specific views module instead of auto-discovery from installed apps:
The generated SDK includes resolved create, update, and read interfaces, typed list parameters, and a fetch-based AksaraClient with CRUD methods.
info¶
Show project information:
Output:
Aksara Project Information
==========================
Version: 0.5.46
Python: 3.11.0
Database: postgresql://localhost/mydb
Apps:
- blog (3 models)
- users (2 models)
Models:
- blog.Post
- blog.Comment
- blog.Tag
- users.User
- users.Profile
Migrations:
- 5 applied
- 0 pending
AI Commands¶
See AI Commands for detailed documentation.
ai query¶
Query data using natural language:
ai generate¶
Generate code from descriptions:
ai doctor¶
Analyze schema for issues:
ai plan¶
Create multi-step plans:
Configuration¶
Settings File¶
The CLI looks for settings in:
AKSARA_SETTINGSenvironment variablesettings.pyin current directory{project}/settings.py
Environment Variables¶
export AKSARA_SETTINGS=myproject.settings
export AKSARA_DEBUG=true
export DATABASE_URL=postgresql://localhost/mydb
Output Formatting¶
JSON Output¶
Many commands support JSON output:
Global Output Controls¶
These flags apply to the entire CLI, so place them before the command name:
--quiet suppresses non-error Aksara UI output such as banners, progress lines, and success summaries. It does not suppress subprocess or Uvicorn logs. --plain disables Rich rendering and animation. --no-color removes ANSI color, and --force-color forces colored output when supported.
Exit Codes¶
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | General error |
| 2 | Invalid arguments |
| 3 | Configuration error |
| 4 | Database error |
| 5 | Migration error |
Use in scripts:
Aliases¶
Create shell aliases for common commands:
# ~/.bashrc or ~/.zshrc
alias vr='aksara run'
alias vm='aksara migrate'
alias vmm='aksara makemigrations'
alias vs='aksara shell'
Related Documentation¶
- Commands Reference — All commands
- Dev Tools — Development utilities
- AI Commands — AI features
- Extending — Custom commands