Commands Reference#
All Lokio commands with their options and usage examples.
lokio init#
Initialize Lokio in your project. Run once at the start.
lokio init
lokio init --enterprise <code> # activate Enterprise at the same timeWhat gets created:
lokio.yaml— project metadatalokio.local.yaml— API key placeholder (auto-added to.gitignore)lokio/configs.yaml— templates, check config, and AI config (pre-filled with defaults)lokio/templates/— folder for.lokiofiles with an example template.gitignore—lokio.local.yamlis automatically added
Enterprise flag (
--enterprise <code>): Creates a minimallokio.yaml+lokio/configs.yamlwithout templates. Runlokio pullafter this to pull templates from the Hub.
lokio doctor#
Diagnose your entire Lokio setup and display the status of each component.
lokio doctorWhat gets checked:
| Section | Check |
|---|---|
| Project Config | lokio.yaml exists and is valid |
| Templates & Config | lokio/configs.yaml exists, every .lokio template file is available, no parameters override built-in helpers |
| AI Integration | ai: section configured, API key available (env/local), standards: defined |
| Security | lokio.local.yaml is in .gitignore |
| Lock File | Files in lokio.lock still exist on disk, no output claimed by two templates |
Example output:
Project Config
✓ lokio.yaml project: my-app v2.0.14
Templates & Config
✓ lokio/configs.yaml 2 template(s)
✓ template: service lokio/templates/service.lokio
✗ template: screen file missing: lokio/templates/screen.lokio
⚠ check config not configured
AI Integration
✓ AI config provider: gemini, model: gemini-2.0-flash
✗ AI api_key not set — add api_key to lokio.local.yaml
Security
✓ .gitignore lokio.local.yaml is listed
Lock File
✓ lokio.lock 3 generation(s) tracked, all files present
Status:
✓OK⚠Warning — works but needs attention✗Error — needs to be fixed–Skip — component not yet configured
lokio add / lokio a#
Create a new template interactively.
lokio add
lokio add service # provide template name directly
lokio add screen --multi # directly use multi-file mode
lokio a api -m # alias + short flagFlow:
- Template name
- Template description
- Single-file or multi-file?
- Output path (where generated files are saved)
- Blueprint filename (name of the
.lokiofile) - Additional parameters (optional)
lokio edit / lokio e#
Edit an existing template's configuration (not the .lokio content, but its metadata in configs.yaml).
lokio edit service
lokio e screenEdit options:
- Description
- Path & Output (single-file) or Files (multi-file)
- Parameters — add, edit, or delete parameters
- Convert single ↔ multi-file
To edit the template content (
.lokiofile), open it directly in your editor.
lokio remove / lokio rm#
Remove a template from configs.yaml.
lokio remove service
lokio rm screenYou will be asked whether the
.lokiofile should also be deleted.
lokio gen / lokio g#
Generate code from a template.
# Interactive — choose template, fill in all parameters one by one
lokio gen
lokio g
# Specify template
lokio gen service
lokio g screen
# Specify template + first parameter (name) at once
lokio gen service UserProfile
lokio g screen Home
# Re-generate a single file (update file from the latest template)
lokio gen --update src/services/UserService.ts
# Batch generate from a JSON file
lokio gen service --batch entities.jsonParameter collision: If your parameter name matches a built-in helper (
camelCase,plural, etc.), Lokio will display a warning because the helper will be overridden.
--update <file>#
Re-generate a single file that was previously generated. Uses 3-way merge so your manual changes are not lost.
lokio gen --update src/services/UserService.ts--batch <file>#
Generate multiple files at once from a JSON file. The JSON file must be an array of parameter objects.
lokio gen service --batch entities.jsonExample entities.json:
[
{ "name": "User" },
{ "name": "Order", "type": "repository" },
{ "name": "Product" }
]lokio diff#
Preview what will change if lokio sync is run — without writing anything.
lokio diffExample output:
✓ src/services/UserService.ts — no changes
~ src/services/OrderService.ts — +3 -1 (your edits preserved)
✗ src/services/TokenService.ts — conflict (resolve markers manually)
2 changed, 1 up to date — run lokio sync to apply
lokio sync#
Apply template changes to already-generated files. Uses 3-way merge to preserve manual changes.
lokio syncFlow:
- Scan all files in
lokio.lock - Re-render each file from the latest template
- Compare with the git version (HEAD) as the merge base
- Display a change summary
- Ask: Apply all / Review each / Cancel
Status types:
| Icon | Status | Meaning |
|---|---|---|
✓ | up to date | No changes |
~ | changed | Changes available, can be applied |
~ | your edits preserved | Template changes applied, your manual edits are safe |
✗ | conflict | Both you and the template changed the same lines |
lokio check#
Validate files in the repo against the structural rules defined in templates.
lokio checkDifferent from
lokio diff/lokio sync:checkdoesn't care whether a file was generated with Lokio. It scans the entire repo and matches files based on the template output path pattern.
Rules can be defined with annotations in .lokio files:
<%# @lokio required danger "Must have @Injectable()" @Injectable %>
<%# @lokio forbidden warning "Do not use any" : any %>Configuration in lokio/configs.yaml:
check:
danger_mode: block # "block" = exit code 1 (fits pre-commit hook)
# "warn" = display only, no exit 1
# templates: # optional — omit to check all templates
# - service
# - controllerAs a pre-commit hook:
# .git/hooks/pre-commit
#!/bin/sh
lokio checklokio ai#
Validate team standards using AI. AI analyzes files in the repo and compares them against the standards you defined.
lokio aiFirst-time setup (if not yet configured), an interactive wizard will appear:
⚠ AI config not found in lokio/configs.yaml.
? Set up AI config now? › Yes
◇ Select AI provider:
│ Gemini ← free tier
◇ Model name:
│ gemini-2.0-flash
◇ Add sample standards (unit-test, no-console-log)?
│ Yes
✓ AI config written to lokio/configs.yaml
✓ Created lokio.local.yaml (gitignored)
╭─ Next step ───────────────────────────────────╮
│ Fill in your API key in lokio.local.yaml: │
│ │
│ ai: │
│ api_key: YOUR_KEY_HERE │
│ │
│ Then run 'lokio ai' again. │
╰───────────────────────────────────────────────╯
Configuration in lokio/configs.yaml (safe to commit — contains no secrets):
ai:
provider: gemini # openai | anthropic | gemini | ollama | openrouter
model: gemini-2.0-flash
standards:
- id: unit-test
description: "Every service must have a unit test file"
severity: danger # danger | warning
- id: no-console-log
description: "No console.log in production code"
severity: warningAPI key in lokio.local.yaml (gitignored — do not commit):
# lokio.local.yaml
ai:
api_key: YOUR_API_KEY_HEREOr use an environment variable:
export LOKIO_AI_API_KEY=your-keySupported providers:
| Provider | Recommended model | Notes |
|---|---|---|
gemini | gemini-2.0-flash | Free tier available |
openai | gpt-4o-mini | Affordable |
anthropic | claude-haiku-4-5-20251001 | — |
openrouter | meta-llama/llama-3.3-70b-instruct:free | Free models available |
ollama | llama3.2 | Local / VPS, no API key needed |
Example output:
✓ unit-test PASS All services have corresponding test files
✗ no-console-log FAIL Found console.log in production code
└─ src/services/UserService.ts
──────────────────────────────────────────────────────────
Summary: 1 pass / 1 fail — 2 standard(s) checked
✗ Danger standards failed. Fix before merging.
lokio run#
Execute a predefined sequence of shell commands (steps) defined in lokio/configs.yaml.
lokio run --id <id>
# Examples
lokio run --id install-docker
lokio run --id setup-vmConfiguration in lokio/configs.yaml:
runs:
- id: install-docker
description: Install Docker & Docker Compose (Ubuntu/Debian)
steps:
- name: Update apt
run: sudo apt update -y
- name: Install Docker Engine
run: sudo apt install -y docker-ce docker-ce-cli containerd.io
- name: Verify Docker
run: docker --versionStep fields:
| Field | Required | Description |
|---|---|---|
name | yes | Label shown while the step runs |
run | yes | Shell command(s) to execute |
continue_on_error | no | If true, continue to the next step even if this one fails |
Multi-line commands use the YAML block scalar (|):
- name: Add Docker GPG key
run: |
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
| sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgcontinue_on_error — useful when a step may fail non-fatally (e.g. container already running):
- name: Run Redis container
run: docker run -d --name redis -p 6379:6379 redis:7-alpine
continue_on_error: trueExample output:
Running: install-docker
● Update apt
✓ Update apt
● Install Docker Engine
✓ Install Docker Engine
● Verify Docker
✓ Verify Docker
✓ Done — 3 step(s) completed
lokio pull#
Pull templates from the Enterprise Hub (requires Enterprise activation).
lokio pulllokio --help#
Display a list of all commands.
lokio --help
lokio gen --help # help for a specific commandlokio --version / lokio -V#
Display the installed Lokio version.
lokio -V