Tools
CLI Reference
The xo CLI is the primary way to interact with the generator engine. Install it globally with npm install -g xocode.
xo create <generator> [options]Runs the generator's create workflow to scaffold a new project from scratch. Generators are resolved by direct GitHub reference (@github/owner/repo), registered name, or local path.
| Option | Description |
|---|---|
| --dry-run | Preview all actions without writing any files |
| -i <key>=<val> | Pre-fill an input, skipping the interactive prompt for that value. Repeatable. |
| --local | Run a generator from a local path without linking |
$xo create @github/my-org/xo-next-app$xo create flutter-app$xo create @github/betaversionio/xo-flutter$xo create ./my-template --local --dry-run
xo add <generator> [options]Applies a generator to the current project. Validates compatibility (detects, requires, conflicts) before running any steps.
| Option | Description |
|---|---|
| --dry-run | Preview all actions without writing any files |
| -i <key>=<val> | Pre-fill an input. Repeatable. |
| --local | Run from a local path without linking |
$xo add @github/my-org/xo-stripe$xo add @github/my-org/xo-ui/button$xo add @github/my-org/xo-ui/button@v1.2.0$xo add payment/stripe --dry-run$xo add ui/button -i componentName=Button -i variant=primary
Validation order
Before running, xo checks detects rules (project compatible?), then requires (prerequisites applied?), then conflicts (no clashing generators?). All three must pass.xo run <generator> [options]Triggers the generator's run workflow. Useful for task runners or one-off generators.
| Option | Description |
|---|---|
| --dry-run | Preview without writing files |
| -i <key>=<val> | Pre-fill an input |
$xo run db:migrate$xo run @github/my-org/xo-codegen
xo undoReverts the most recent xo add or xo create operation. Files that were created are deleted; files that were modified are restored from their before-snapshot.
$xo undo
File changes only
xo undo restores file content but does not reverse shell commands (like flutter pub get). Reverse those manually if needed.xo historyLists every generator applied in the current project in chronological order, with operation ID, generator name, trigger, and timestamp.
$xo history
Local development
These commands are for generator authors building and testing a generator locally.
Register the current directory as a named generator. xo reads the name field from workflow.yaml automatically — pass a name only to override. Once linked, xo add <name> from any project resolves to your local directory. Changes to workflow.yaml or templates are picked up immediately.
$cd ~/projects/xo-stripe$xo link$xo link payment/stripe
Remove the link for the current directory. Run inside the generator repo.
$cd ~/projects/xo-stripe$xo unlink
List all locally linked generators with their names, paths, and link dates.
$xo links
Registry
Register GitHub generators under short names so users don't need the @github/ prefix every time.
Register a generator from a GitHub URL. Use --path for a subdirectory in a multi-generator repo.
$xo registry add payment/stripe --url https://github.com/my-org/xo-stripe$xo registry add ui/button --url https://github.com/my-org/xo-ui --path button
List all registered generators.
$xo registry list
Remove a generator from the local registry.
$xo registry remove payment/stripe
Cache
xo caches generator files fetched from GitHub in ~/.xo/cache/. Branch refs are always re-fetched on each run. Tag refs are cached forever (immutable).
List all cached generators with their owner, repo, ref, and cache path.
$xo cache list
Clear the entire GitHub cache, or only the cache for a specific GitHub owner.
$xo cache clear$xo cache clear my-org
Generator resolution
xo resolves a generator name in this order:
Local path
Name starts with ./ or / → reads directly from that path. Requires --local flag.
Linked generators
Checks ~/.xo/links.json for a match — set by xo link inside a generator repo.
Registry
Checks ~/.xo/registry.json for a registered URL — set by xo registry add.
@github/ reference
Name starts with @github/ → fetches workflow.yaml from GitHub and caches it in ~/.xo/cache/.
@github/owner/repo/subpath to reference a generator in a subdirectory of a repo — e.g. @github/my-org/xo-ui/button.Project files written by xo
xo.config.yaml
Records the applied template and features. Used by requires/conflicts validation on subsequent runs. Commit this file.
template: flutter-app
packageManager: pnpm
features:
- payment/stripe
- auth/jwt.xo/state.json
Stores every operation with before-snapshots for undo. Commit this file so your team shares generator history.
{
"operations": [
{
"id": "a1b2c3d4-...",
"timestamp": "2025-05-04T10:32:00.000Z",
"generator": "@github/betaversionio/xo-flutter",
"type": "create",
"files": [
{ "filePath": "lib/main.dart", "action": "created" },
{ "filePath": "pubspec.yaml", "action": "modified", "before": "..." }
]
}
]
}