axon compile command transforms AXON source code into AXON IR (Intermediate Representation), a JSON-serializable format optimized for execution by different LLM backends.
Synopsis
Description
Runs the complete compilation pipeline:- Lexer — Tokenize source code
- Parser — Build Abstract Syntax Tree
- Type Checker — Semantic validation
- IR Generator — Generate intermediate representation
- Serialization — Output as JSON
- Saved for later execution
- Inspected for debugging
- Distributed independently of source code
- Executed on any supported backend
Arguments
Path to the
.axon source file to compileOptions
Target backend for compilation. Affects prompt structure and optimization.Choices:
anthropic, openai, gemini, ollamaShort form: -bCustom output path for the IR JSON file.Default:
<filename>.ir.jsonShort form: -oPrint IR JSON to stdout instead of writing to a file. Useful for piping to other tools.
Exit Codes
| Code | Meaning |
|---|---|
0 | Success — IR generated and saved |
1 | Compilation error (lexer, parser, type checker, or IR generation) |
2 | I/O error (file not found or write failure) |
Output Format
File Output (Default)
.ir.json extension.
Stdout Output
Error Output
IR JSON Structure
The compiled IR includes:- Metadata: Source file, backend, AXON version
- Declarations: All top-level constructs (personas, flows, anchors, etc.)
- Type Information: Resolved types and epistemic annotations
- Execution Graph: Flow dependencies and data flow
Examples
Basic Compilation
Target Specific Backend
Custom Output Path
Pipe to Other Tools
Multiple Backends
CI/CD Integration
Backend Differences
Anthropic (Claude)
Optimized for:- Extended context windows
- System prompts with persona fusion
- Chain-of-thought reasoning
OpenAI (GPT)
Optimized for:- Structured outputs
- Function calling
- JSON mode
Gemini
Optimized for:- Multimodal inputs
- Safety settings
- Grounding with Google Search
Ollama
Optimized for:- Local execution
- Privacy-focused deployments
- Custom model configurations
IR Inspection
Usejq to inspect compiled IR:
Troubleshooting
IR Generation Failed
Write Permission Error
Solution: Ensure write access to the output directory:Backend Not Found
Related Commands
check
Validate before compiling
run
Compile and execute in one step
Performance Notes
- Compilation is CPU-bound (no API calls)
- Typical compile times: 50-500ms depending on program size
- IR files are typically 2-5x larger than source files
- Use
--stdoutto avoid disk I/O overhead
