Skip to content

CLI Commands

The LUMOS CLI (lumos) provides commands for code generation, validation, and schema evolution.

Terminal window
cargo install lumos-cli

Verify installation:

Terminal window
lumos --version
# Output: lumos-cli 0.1.0

Generate Rust and TypeScript code from a .lumos schema file.

Terminal window
lumos generate <SCHEMA_FILE> [OPTIONS]
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)
OptionShortDescriptionDefault
--output-oOutput directory for generated filesCurrent directory
--lang-lTarget languages (comma-separated)rust,typescript
--target-tTarget framework (auto, native, anchor)auto
--watch-wWatch for changes and regeneratefalse
--dry-run-nPreview changes without writing filesfalse
--backup-bCreate backup before overwritingfalse
--show-diff-dShow diff and ask for confirmationfalse
--help-hPrint help information-

Supported languages: rust (rs), typescript (ts), python (py), go, ruby (rb)

Target frameworks:

  • auto - Detect based on #[account] attribute (default)
  • native - Force pure Borsh, no Anchor dependencies
  • anchor - Use Anchor framework (requires #[account])

Basic generation:

Terminal window
lumos generate schema.lumos

Generates:

  • ./generated.rs - Rust structs and enums
  • ./generated.ts - TypeScript interfaces + Borsh schemas

Custom output directory:

Terminal window
lumos generate schema.lumos -o ./src/generated

Multi-language generation:

Terminal window
# Generate Rust, TypeScript, and Python
lumos generate schema.lumos --lang rust,typescript,python
# Generate all supported languages
lumos generate schema.lumos --lang rust,typescript,python,go,ruby

Force native Solana mode:

Terminal window
lumos generate schema.lumos --target native

Watch mode for development:

Terminal window
lumos generate schema.lumos --watch
# Watches for changes and regenerates automatically

Safe file operations:

Terminal window
# Preview changes without writing
lumos generate schema.lumos --dry-run
# Create backup before overwriting
lumos generate schema.lumos --backup
# Show diff and confirm before writing
lumos generate schema.lumos --show-diff
CodeMeaning
0Success - files generated
1Parse error - invalid .lumos syntax
2Transform error - unsupported types or attributes
3I/O error - cannot write files

File not found:

Error: Schema file not found: schema.lumos

Fix: Check file path is correct.

Parse error:

Error: Failed to parse schema
--> schema.lumos:5:12
|
5 | level u16,
| ^ expected ':'

Fix: Add : after field name (level: u16).

Invalid type:

Error: Unsupported type 'f64' at line 10

Fix: Use supported types only. See Type System.


Check if a .lumos schema file has valid syntax.

Terminal window
lumos validate <SCHEMA_FILE>
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)

Valid schema:

Terminal window
lumos validate schema.lumos
# Output: ✓ Schema is valid
# Exit code: 0

Invalid schema:

Terminal window
lumos validate bad_schema.lumos
# Output:
# Error: Failed to parse schema
# --> bad_schema.lumos:3:5
# |
# 3 | invalid syntax here
# | ^^^^^^^ unexpected token
# Exit code: 1
  1. Pre-commit hook - Validate before committing
  2. CI/CD pipeline - Ensure schemas are valid
  3. Editor integration - Real-time syntax checking
.git/hooks/pre-commit
#!/bin/bash
# Find all .lumos files
LUMOS_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep '\\.lumos$')
if [ -n "$LUMOS_FILES" ]; then
for file in $LUMOS_FILES; do
lumos validate "$file"
if [ $? -ne 0 ]; then
echo "❌ Validation failed for $file"
exit 1
fi
done
echo "✅ All schemas valid"
fi

Initialize a new LUMOS project with example schema and configuration.

Terminal window
lumos init [PROJECT_NAME]
  • [PROJECT_NAME] - Optional directory name (defaults to current directory)

Create new project:

Terminal window
lumos init my-solana-app
cd my-solana-app

Initialize current directory:

Terminal window
mkdir my-project && cd my-project
lumos init
my-solana-app/
├── schema.lumos # Example schema
├── lumos.toml # Configuration file
└── README.md # Getting started guide

schema.lumos (example):

#[solana]
#[account]
struct PlayerAccount {
wallet: PublicKey,
level: u16,
experience: u64,
}

lumos.toml (configuration):

[generation]
rust_output = "generated.rs"
typescript_output = "generated.ts"
format = true
[imports]
rust_prelude = true

Verify that generated code is up-to-date with schema.

Terminal window
lumos check <SCHEMA_FILE>
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)

Schema and generated files match:

Terminal window
lumos check schema.lumos
# Output: ✓ Generated files are up-to-date
# Exit code: 0

Schema changed, need regeneration:

Terminal window
lumos check schema.lumos
# Output: ⚠️ Generated files are outdated
# Run: lumos generate schema.lumos
# Exit code: 1

Generated files missing:

Terminal window
lumos check schema.lumos
# Output: ⚠️ Generated files not found
# Run: lumos generate schema.lumos
# Exit code: 1
  1. CI/CD Pipeline - Ensure developers ran generate before committing
  2. Build Scripts - Automatically regenerate if needed
  3. Pre-build Hook - Verify code is current
{
"scripts": {
"prebuild": "lumos check schema.lumos || lumos generate schema.lumos",
"build": "anchor build"
}
}
name: Check LUMOS Schemas
on: [push, pull_request]
jobs:
check-schemas:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install LUMOS CLI
run: cargo install lumos-cli
- name: Check schemas are up-to-date
run: |
for schema in $(find . -name "*.lumos"); do
lumos check "$schema"
done

These commands help you manage schema changes and migrations between versions.

Compare two schema files and show differences.

Terminal window
lumos diff <SCHEMA1> <SCHEMA2> [OPTIONS]
  • <SCHEMA1> - Path to the first (older) schema file
  • <SCHEMA2> - Path to the second (newer) schema file
OptionShortDescriptionDefault
--format-fOutput format (text or json)text
--help-hPrint help information-

Compare two versions:

Terminal window
lumos diff schema-v1.lumos schema-v2.lumos

Output (text):

Schema Differences
==================
+ Added struct: PlayerStats
- level: u16
- experience: u64
~ Modified struct: PlayerAccount
+ Added field: stats (PlayerStats)
- Removed field: score (u32)
- Removed enum: OldStatus

JSON output for scripting:

Terminal window
lumos diff schema-v1.lumos schema-v2.lumos --format json
{
"added": [
{ "type": "struct", "name": "PlayerStats" }
],
"modified": [
{
"type": "struct",
"name": "PlayerAccount",
"changes": {
"added_fields": ["stats"],
"removed_fields": ["score"]
}
}
],
"removed": [
{ "type": "enum", "name": "OldStatus" }
]
}

Check backward compatibility between two schema versions.

Terminal window
lumos check-compat <FROM_SCHEMA> <TO_SCHEMA> [OPTIONS]
  • <FROM_SCHEMA> - Path to the old schema file (v1)
  • <TO_SCHEMA> - Path to the new schema file (v2)
OptionShortDescriptionDefault
--format-fOutput format (text or json)text
--verbose-vShow detailed explanationsfalse
--strict-sTreat warnings as errorsfalse
--help-hPrint help information-

Check compatibility:

Terminal window
lumos check-compat schema-v1.lumos schema-v2.lumos

Output (compatible):

✓ Schema is backward compatible
Changes detected:
- Added optional field: PlayerAccount.nickname (Option<String>)
- Added struct: AchievementData
These changes are safe for existing on-chain accounts.

Output (breaking changes):

✗ Schema has breaking changes
Breaking changes detected:
✗ Changed field type: PlayerAccount.score (u32 → u64)
Reason: Different byte size (4 → 8 bytes)
Impact: Existing accounts cannot be deserialized
✗ Removed field: PlayerAccount.legacy_data
Reason: Field removal changes Borsh layout
Impact: Data corruption on deserialization
Run 'lumos migrate' to generate migration code.

Verbose mode for CI/CD:

Terminal window
lumos check-compat old.lumos new.lumos --verbose --strict
  1. Pre-merge check - Validate schema changes in PR
  2. Release validation - Ensure new version won’t break production
  3. CI/CD pipeline - Automated compatibility testing
- name: Check Schema Compatibility
run: |
lumos check-compat main-schema.lumos pr-schema.lumos --strict

Generate migration code from one schema version to another.

Terminal window
lumos migrate <FROM_SCHEMA> <TO_SCHEMA> [OPTIONS]
  • <FROM_SCHEMA> - Path to the old schema file (v1)
  • <TO_SCHEMA> - Path to the new schema file (v2)
OptionShortDescriptionDefault
--output-oOutput file pathstdout
--language-lTarget language (rust, typescript, both)both
--dry-run-nShow changes without generating codefalse
--force-fForce generation for unsafe migrationsfalse
--help-hPrint help information-

Preview migration (dry run):

Terminal window
lumos migrate schema-v1.lumos schema-v2.lumos --dry-run

Output:

Migration: schema-v1.lumos → schema-v2.lumos
Required migrations:
1. PlayerAccount.score: u32 → u64
- Requires account reallocation (+4 bytes)
- Safe: value range expansion
2. PlayerAccount.stats: (new field)
- Requires account reallocation (+10 bytes)
- Default value needed
Generated files (dry run):
- migration.rs (Rust migration instruction)
- migration.ts (TypeScript client helper)

Generate Rust migration:

Terminal window
lumos migrate schema-v1.lumos schema-v2.lumos -l rust -o migration.rs

Generated migration.rs:

use anchor_lang::prelude::*;
/// Migration from v1 to v2
pub fn migrate_player_account(
old_data: &[u8],
new_account: &mut PlayerAccountV2,
) -> Result<()> {
// Read old format
let old = PlayerAccountV1::try_from_slice(old_data)?;
// Transform to new format
new_account.wallet = old.wallet;
new_account.score = old.score as u64; // Safe upcast
new_account.stats = PlayerStats::default(); // New field
Ok(())
}

Generate TypeScript migration:

Terminal window
lumos migrate schema-v1.lumos schema-v2.lumos -l typescript -o migration.ts

Force unsafe migration:

Terminal window
lumos migrate schema-v1.lumos schema-v2.lumos --force

Analyze account sizes and check against Solana limits.

Terminal window
lumos check-size <SCHEMA_FILE> [OPTIONS]
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)
OptionShortDescriptionDefault
--format-fOutput format (text or json)text
--help-hPrint help information-

Check account sizes:

Terminal window
lumos check-size schema.lumos

Output:

Account Size Analysis
=====================
PlayerAccount
wallet: PublicKey 32 bytes
level: u16 2 bytes
experience: u64 8 bytes
username: String 36 bytes (4 + 32 max)
─────────────────────────────────
Total: 78 bytes
Status: ✓ Within Solana limit (10,240 bytes)
GameState (enum)
Discriminant: 1 byte
Active: 0 bytes (unit variant)
Paused: 0 bytes (unit variant)
Finished { winner }: 32 bytes (PublicKey)
─────────────────────────────────
Max size: 33 bytes

JSON output for tooling:

Terminal window
lumos check-size schema.lumos --format json
{
"accounts": [
{
"name": "PlayerAccount",
"size": 78,
"fields": [
{ "name": "wallet", "type": "PublicKey", "size": 32 },
{ "name": "level", "type": "u16", "size": 2 },
{ "name": "experience", "type": "u64", "size": 8 },
{ "name": "username", "type": "String", "size": 36 }
],
"within_limit": true
}
]
}
  1. Pre-deployment check - Verify accounts fit within Solana’s 10KB limit
  2. Cost estimation - Calculate rent costs based on size
  3. Optimization - Identify fields consuming most space

Analyze schema for common Solana vulnerabilities.

Terminal window
lumos security analyze <SCHEMA_FILE> [OPTIONS]
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)
OptionShortDescriptionDefault
--format-fOutput format (text or json)text
--strict-sEnable strict mode (more aggressive warnings)false
--help-hPrint help information-

Basic security analysis:

Terminal window
lumos security analyze schema.lumos

Output:

Security Analysis
=================
⚠️ WARNING: PlayerAccount
Missing signer field - consider adding owner/authority
Recommendation: Add `authority: PublicKey` for access control
⚠️ WARNING: TransferInstruction
Large integer field `amount: u128` - potential overflow risk
Recommendation: Validate bounds in program logic
✓ GameState: No issues found
Summary: 2 warnings, 0 errors

Strict mode for production:

Terminal window
lumos security analyze schema.lumos --strict

JSON output for CI/CD:

Terminal window
lumos security analyze schema.lumos --format json
{
"warnings": [
{
"type": "MissingSignerField",
"account": "PlayerAccount",
"message": "Missing signer field",
"recommendation": "Add authority: PublicKey for access control"
}
],
"errors": [],
"summary": { "warnings": 2, "errors": 0 }
}
IssueDescriptionSeverity
Missing signerNo authority/owner fieldMedium
Integer overflowLarge integers without boundsMedium
Unchecked ownerAccount lacks ownership validationHigh
PDA seed issuesInsecure PDA derivation patternsHigh
Reentrancy riskState changes before external callsHigh

Generate security audit checklist from schema.

Terminal window
lumos audit generate <SCHEMA_FILE> [OPTIONS]
  • <SCHEMA_FILE> - Path to the .lumos schema file (required)
OptionShortDescriptionDefault
--output-oOutput file pathSECURITY_AUDIT.md
--format-fOutput format (markdown or json)markdown
--help-hPrint help information-

Generate audit checklist:

Terminal window
lumos audit generate schema.lumos
# Creates: SECURITY_AUDIT.md

Custom output file:

Terminal window
lumos audit generate schema.lumos -o docs/audit-checklist.md

Generated SECURITY_AUDIT.md:

# Security Audit Checklist
Generated from: schema.lumos
Date: 2025-12-08
## Account: PlayerAccount
### Access Control
- [ ] Verify owner validation in all instructions
- [ ] Check signer requirements for mutations
- [ ] Validate authority field matches expected signer
### Data Validation
- [ ] Validate `level` bounds (u16: 0-65535)
- [ ] Validate `experience` doesn't overflow
- [ ] Sanitize `username` string input
### State Management
- [ ] Check for reentrancy vulnerabilities
- [ ] Verify account initialization logic
- [ ] Validate account closure cleanup
## Enum: GameState
- [ ] Verify all variant transitions are valid
- [ ] Check discriminant handling

Generate fuzz testing targets for types.

Terminal window
lumos fuzz generate <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--output-oOutput directory for fuzz targetsfuzz/
--type-name-tSpecific type to generate target forAll types
--help-hPrint help information-

Generate fuzz targets for all types:

Terminal window
lumos fuzz generate schema.lumos

Output:

Generated fuzz targets:
fuzz/fuzz_targets/player_account.rs
fuzz/fuzz_targets/game_state.rs
fuzz/Cargo.toml

Generate for specific type:

Terminal window
lumos fuzz generate schema.lumos --type-name PlayerAccount

Run fuzzing for a specific type.

Terminal window
lumos fuzz run <SCHEMA_FILE> --type-name <TYPE> [OPTIONS]
OptionShortDescriptionDefault
--type-name-tType to fuzz (required)-
--jobs-jNumber of parallel jobs1
--max-time-mMaximum run time in secondsUnlimited
--help-hPrint help information-

Run fuzzing:

Terminal window
lumos fuzz run schema.lumos --type-name PlayerAccount

Parallel fuzzing with timeout:

Terminal window
lumos fuzz run schema.lumos -t PlayerAccount -j 4 --max-time 3600

Generate corpus files for fuzzing.

Terminal window
lumos fuzz corpus <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--output-oOutput directory for corpusfuzz/corpus/
--type-name-tSpecific type to generate corpus forAll types
--help-hPrint help information-

Generate corpus for all types:

Terminal window
lumos fuzz corpus schema.lumos

Output:

Generated corpus files:
fuzz/corpus/player_account/
seed_1.bin
seed_2.bin
seed_3.bin
fuzz/corpus/game_state/
seed_1.bin

Commands for Anchor framework integration.

Generate complete Anchor program from LUMOS schema.

Terminal window
lumos anchor generate <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--output-oOutput directoryCurrent directory
--name-nProgram nameDerived from schema
--version-VProgram version0.1.0
--address-aProgram address (optional)-
--typescriptGenerate TypeScript clientfalse
--dry-runPreview without writing filesfalse
--help-hPrint help information-

Generate Anchor program:

Terminal window
lumos anchor generate schema.lumos

Output:

Generated Anchor program:
programs/my_program/
src/lib.rs # Program with #[derive(Accounts)]
src/state.rs # Account structs with space constants
Cargo.toml
target/idl/
my_program.json # Anchor IDL

Full project with TypeScript client:

Terminal window
lumos anchor generate schema.lumos \
--name my_defi_app \
--version 1.0.0 \
--address "MyProgram111111111111111111111111111111111" \
--typescript

Preview generation:

Terminal window
lumos anchor generate schema.lumos --dry-run
  • #[derive(Accounts)] contexts for each instruction
  • Account LEN constants for space calculation
  • Anchor IDL JSON for client generation
  • Optional TypeScript client with typed methods

Generate Anchor IDL from LUMOS schema.

Terminal window
lumos anchor idl <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--output-oOutput file pathtarget/idl/<program>.json
--name-nProgram nameDerived from schema
--version-VProgram version0.1.0
--address-aProgram address (optional)-
--pretty-pPretty print JSONfalse
--help-hPrint help information-

Generate IDL:

Terminal window
lumos anchor idl schema.lumos

Pretty printed with custom name:

Terminal window
lumos anchor idl schema.lumos --name my_program --pretty

Generated IDL structure:

{
"version": "0.1.0",
"name": "my_program",
"instructions": [...],
"accounts": [...],
"types": [...],
"errors": [...]
}

Calculate Anchor account space constants.

Terminal window
lumos anchor space <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--format-fOutput format (text or rust)text
--account-aSpecific account typeAll accounts
--help-hPrint help information-

Calculate space for all accounts:

Terminal window
lumos anchor space schema.lumos

Output (text):

Account Space Constants
=======================
PlayerAccount:
DISCRIMINATOR: 8 bytes
wallet: 32 bytes
level: 2 bytes
experience: 8 bytes
username: 36 bytes (4 + 32)
─────────────────────────
TOTAL (LEN): 86 bytes

Rust constants output:

Terminal window
lumos anchor space schema.lumos --format rust
impl PlayerAccount {
pub const LEN: usize = 8 // discriminator
+ 32 // wallet: Pubkey
+ 2 // level: u16
+ 8 // experience: u64
+ 36; // username: String (4 + 32)
}

Specific account:

Terminal window
lumos anchor space schema.lumos --account PlayerAccount

Commands for Metaplex Token Metadata integration.

Validate schema against Metaplex Token Metadata standards.

Terminal window
lumos metaplex validate <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--format-fOutput format (text or json)text
--verbose-vShow all validationsfalse
--help-hPrint help information-

Validate NFT metadata schema:

Terminal window
lumos metaplex validate nft-schema.lumos

Output:

Metaplex Validation
===================
✓ NftMetadata.name: Valid (length ≤ 32)
✓ NftMetadata.symbol: Valid (length ≤ 10)
✓ NftMetadata.uri: Valid (length ≤ 200)
⚠️ NftMetadata.seller_fee_basis_points: Warning
Value should be 0-10000 (0% - 100%)
Creators validation:
✓ Max 5 creators: Valid (3 defined)
✓ Shares sum to 100: Valid (100%)
Summary: 0 errors, 1 warning
FieldConstraint
nameMax 32 characters
symbolMax 10 characters
uriMax 200 characters
seller_fee_basis_points0-10000 (0% - 100%)
creatorsMax 5, shares must sum to 100

Generate Metaplex-compatible code from schema.

Terminal window
lumos metaplex generate <SCHEMA_FILE> [OPTIONS]
OptionShortDescriptionDefault
--output-oOutput directoryCurrent directory
--typescriptGenerate TypeScript codefalse
--rustGenerate Rust codetrue
--dry-runPreview without writing filesfalse
--help-hPrint help information-

Generate Metaplex types:

Terminal window
lumos metaplex generate nft-schema.lumos

Generate both Rust and TypeScript:

Terminal window
lumos metaplex generate nft-schema.lumos --typescript

Show standard Metaplex type definitions.

Terminal window
lumos metaplex types [OPTIONS]
OptionShortDescriptionDefault
--format-fOutput format (lumos or json)lumos
--help-hPrint help information-

Show LUMOS format:

Terminal window
lumos metaplex types

Output:

// Standard Metaplex Token Metadata types
#[solana]
struct Creator {
address: PublicKey,
verified: bool,
share: u8,
}
#[solana]
struct Collection {
verified: bool,
key: PublicKey,
}
#[solana]
struct Metadata {
name: String,
symbol: String,
uri: String,
seller_fee_basis_points: u16,
creators: Option<[Creator]>,
collection: Option<Collection>,
}

JSON format for tooling:

Terminal window
lumos metaplex types --format json

Available for all commands:

OptionShortDescription
--help-hPrint help information
--version-VPrint version information
--verbose-vEnable verbose output
--quiet-qSuppress non-error output

Verbose mode:

Terminal window
lumos generate schema.lumos -v
# Output:
# [DEBUG] Parsing schema file...
# [DEBUG] Transforming AST to IR...
# [DEBUG] Generating Rust code...
# [DEBUG] Generating TypeScript code...
# ✓ Generated 2 files

Quiet mode:

Terminal window
lumos generate schema.lumos -q
# No output on success, only errors

Configure LUMOS CLI behavior via environment variables:

VariableDescriptionDefault
LUMOS_OUTPUT_DIRDefault output directoryCurrent directory
LUMOS_FORMATEnable/disable formattingtrue
LUMOS_COLOREnable/disable colored outputAuto-detect
Terminal window
# Disable colored output
export LUMOS_COLOR=never
lumos generate schema.lumos
# Change default output directory
export LUMOS_OUTPUT_DIR=./generated
lumos generate schema.lumos

CodeMeaningCommands
0SuccessAll
1Parse/validation errorgenerate, validate, check
2Transform errorgenerate
3I/O errorgenerate, init
4Outdated filescheck