CLI Overview

The pxl command-line interface provides tools for working with Pixelsrc files. Commands fall into several categories:

Core Workflow

CommandDescription
renderRender sprites to PNG, GIF, or atlas formats
importConvert PNG images to Pixelsrc format
validateCheck files for errors and common mistakes
fmtFormat files for consistent style
buildBuild all assets according to pxl.toml

Authoring Tools

CommandDescription
newCreate new assets from templates
initInitialize a new Pixelsrc project
sketchCreate sprites from simple text grids

Inspection & Debugging

CommandDescription
showDisplay sprites with colored terminal output
gridDisplay grid with row/column coordinates
inlineExpand grid with column-aligned spacing
explainExplain objects in human-readable format
diffCompare sprites semantically
analyzeExtract corpus metrics from files

AI Integration

CommandDescription
primePrint format guide for AI context injection
promptsShow GenAI prompt templates
suggestSuggest fixes for common issues
aliasExtract repeated patterns into aliases

Reference Data

CommandDescription
palettesList and inspect built-in palettes

Global Behavior

File Formats

The CLI supports two file formats:

  • .pxl - Human-readable Pixelsrc format
  • .jsonl - JSON Lines format (legacy, still supported)

Both formats can contain palettes, sprites, animations, compositions, and other objects.

Exit Codes

CodeMeaning
0Success
1General error (invalid input, missing file, etc.)
2Validation failed (with --strict mode)

See Exit Codes for the complete list.

Common Options

Many commands share common options:

  • --json - Output as JSON for scripting
  • --strict - Treat warnings as errors
  • --stdin - Read input from stdin

Quick Examples

# Render a sprite to PNG
pxl render sprite.pxl -o output.png

# Validate all files in a directory
pxl validate *.pxl

# Format files in place
pxl fmt *.pxl

# Preview a sprite in terminal
pxl show sprite.pxl

# Build a project
pxl build

# Get AI context for sprite generation
pxl prime --brief