/ir-examples

PVM L2+ Production low usage

/ir-examples

Overview

/ir-examples is a production command in the PVM category of the Prismatic Platform that provides interactive examples, ready-to-use templates, and structured learning resources for Intermediate Representation (IR) workflows. This command serves as the primary onboarding tool for developers and agents who need to understand IR syntax, semantics, and best practices before building production workflows.

The Prismatic IR layer is the bridge between high-level intent expressed in natural language or structured specifications and the low-level PVM bytecode that executes within the platform's agent runtime. Understanding IR is fundamental to building efficient, correct, and maintainable agent workflows. The /ir-examples command addresses the learning curve by providing categorized examples that progress from basic constructs to advanced patterns including DAG composition, conditional branching, parallel execution, and error recovery.

This command operates under the L2+ authority level and is executed by the ir-generator agent, which possesses comprehensive knowledge of IR syntax, semantics, and idiomatic patterns. It is part of the platform's 216-command slash command registry, built on the AIAD (Autonomous Intelligence Agent Design) standard. The generator agent curates examples from the platform's production workflows, ensuring that all examples reflect real-world usage patterns rather than synthetic toy scenarios.

Beyond static code samples, the command supports an interactive mode where users can modify example parameters, observe the effects on IR structure and validation, and experiment with alternative approaches. This interactive learning environment is backed by the same validation engine used in production, so learners receive immediate feedback on correctness and quality.

Architecture

The example delivery system is structured around a content repository with indexed access and interactive execution capabilities.

+---------------------+     +-------------------+     +---------------------+
|  Example Repository | --> | Category Indexer  | --> | Interactive Runner  |
| (Versioned Content) |     | (Tag + Difficulty)|     | (Live IR Execution) |
+---------------------+     +-------------------+     +---------------------+
         |                          |                           |
         v                          v                           v
+---------------------+     +-------------------+     +---------------------+
| Template Engine     |     | Search Engine     |     | Validation Feedback |
| (Parameterized IR)  |     | (Full-Text + Tags)|     | (Real-Time Checks)  |
+---------------------+     +-------------------+     +---------------------+

The Example Repository stores versioned IR examples organized by category, difficulty level, and applicable patterns. The Category Indexer maintains a searchable index with tags for quick discovery. The Template Engine supports parameterized examples where users can substitute values to generate customized IR workflows. The Interactive Runner executes examples in a sandboxed environment with real-time validation feedback.

Usage

Browsing Examples

# List all available example categories
/ir-examples --list

# Show examples in a specific category
/ir-examples --category basics

# Show examples filtered by difficulty level
/ir-examples --difficulty beginner

# Search examples by keyword
/ir-examples --search "parallel execution"

Viewing and Running Examples

# Display a specific example with full documentation
/ir-examples --show data-pipeline-basic

# Run an example in the interactive sandbox
/ir-examples --run data-pipeline-basic

# Run with modified parameters
/ir-examples --run data-pipeline-basic --param source=api --param format=json

# Show example with validation annotations
/ir-examples --show dag-composition --annotate

Template Generation

# Generate a new IR workflow from a template
/ir-examples --template etl-pipeline --output my_pipeline.ir

# List available templates
/ir-examples --templates

# Generate with custom parameters
/ir-examples --template agent-workflow --param agents=3 --param retry=true --output agent_flow.ir

# Generate and immediately validate
/ir-examples --template etl-pipeline --output my_pipeline.ir --validate

Learning Paths

# Start the beginner learning path
/ir-examples --learning-path beginner

# Continue from a specific lesson
/ir-examples --learning-path intermediate --lesson 5

# Show learning path progress
/ir-examples --learning-path --progress

Options & Parameters

OptionTypeDefaultDescription
--listbooleanfalseList all example categories with counts
--categorystringallFilter by category: basics, dag, parallel, error-handling, optimization, advanced
--difficultystringallFilter by difficulty: beginner, intermediate, advanced, expert
--searchstring-Full-text search across example names, descriptions, and content
--showstring-Display a specific example by name with documentation
--runstring-Execute an example in the interactive sandbox
--paramkey=value-Parameter substitution for templates and parameterized examples
--templatestring-Generate IR from a named template
--templatesbooleanfalseList all available templates
--outputstringstdoutOutput file for generated templates
--validatebooleanfalseValidate generated output immediately
--annotatebooleanfalseShow validation and type annotations on examples
--learning-pathstring-Start or continue a structured learning path
--lessoninteger1Starting lesson number within a learning path
--progressbooleanfalseShow learning path completion progress
--formatstringcoloredOutput format: colored, plain, markdown, json
--verbosebooleanfalseInclude detailed explanations with each example

Execution Flow

  1. Command Parsing: The command parser validates all provided options and resolves any conflicts between mutually exclusive flags (e.g., --list and --run cannot be combined).

  2. Repository Loading: The example repository is loaded from the platform's bundled content. If a project-local .ir-examples/ directory exists, custom examples are merged into the repository with project-local examples taking precedence.

  3. Index Consultation: The category indexer is queried with the specified filters (category, difficulty, search terms) to produce a filtered set of matching examples.

  4. Content Resolution: For --show and --run operations, the specific example content is resolved from the repository. Template parameters are substituted if --param options are provided.

  5. Interactive Execution (for --run): The example is executed in a sandboxed IR environment. The sandbox provides full IR parsing, validation, and type-checking capabilities but prevents side effects. Execution results including timing, validation status, and generated PVM bytecode statistics are displayed.

  6. Template Generation (for --template): The template engine processes the selected template with provided parameters, generating a complete IR workflow file. If --validate is specified, the generated file is passed through /ir-validate before writing.

  7. Output Rendering: Results are formatted according to the --format option and written to the specified output destination.

Integration Points

ComponentIntegration TypeDescription
Prismatic AgentsExecutionExecuted by the ir-generator agent
IR ValidatorValidationReal-time validation of examples and generated templates
IR LinterQualityLinting annotations shown in --annotate mode
PVM CompilerCompilationExamples can be compiled to PVM bytecode for inspection
Quality GatesEnforcementGenerated templates must pass quality gates
TelemetryObservabilityExample usage tracked for popularity and learning analytics
AIAD RegistryDiscoveryCommand registered via AIAD standard

Example Categories

CategoryCountDescriptionDifficulty Range
basics12IR syntax fundamentals, node declarations, edge definitionsBeginner
dag8DAG composition patterns, topological ordering, dependency managementBeginner - Intermediate
parallel6Parallel execution, fan-out/fan-in, work distributionIntermediate
error-handling7Error recovery, retry strategies, circuit breakers in IRIntermediate - Advanced
optimization5IR optimization hints, node fusion, dead code eliminationAdvanced
advanced9Meta-programming in IR, dynamic workflow generation, conditional compilationExpert
templates15Production-ready parameterized templates for common patternsAll levels

Best Practices

Start with the beginner learning path before attempting to build production IR workflows. The learning path is structured to introduce concepts incrementally, and each lesson builds on previous ones. Skipping lessons often leads to misunderstanding of foundational concepts that manifest as subtle bugs in complex workflows.

Use templates for production workflows. Rather than writing IR from scratch, start with the closest matching template and customize it. Templates encode best practices, error handling patterns, and optimization hints that are easy to miss when writing from scratch.

Annotate examples when studying them. The --annotate flag adds validation status, type information, and quality scores to each node and edge in the example, providing deeper insight into why the IR is structured the way it is.

Create project-local examples for patterns specific to your domain. Place them in a .ir-examples/ directory at your project root to make them discoverable alongside platform examples.

Validate generated templates immediately. Always use the --validate flag when generating from templates to catch parameter substitution errors before they propagate into downstream pipeline stages.

Error Handling

Error ConditionResponseRecovery
Example not foundSuggests similar example namesUse --search to find the correct name
Invalid template parameterLists valid parameters with typesCorrect parameter name or value
Template generation failureShows template with error markersFix parameter conflicts
Validation failure on generated outputDisplays validation errors with line numbersEdit generated file or adjust parameters
Repository corruptedFalls back to bundled defaultsReinstall platform or clear cache

Advanced Usage

Custom Example Repository

# Initialize a project-local example repository
/ir-examples --init-local

# Add a custom example to the local repository
/ir-examples --add my-pattern --file my_pattern.ir --category custom --difficulty intermediate

# Export examples as a shareable package
/ir-examples --export --category custom --output custom-examples.tar.gz

Batch Template Generation

# Generate multiple workflows from a parameter matrix
/ir-examples --template etl-pipeline --param-file matrix.json --output-dir generated/

# Generate with all parameter combinations
/ir-examples --template agent-workflow --param agents=1,2,4,8 --param retry=true,false --output-dir sweep/

Doctrine Compliance

All commands operate under the NO MERCY, NO DOUBTS doctrine:

  • NO MERCY: Zero tolerance for incomplete execution or quality violations. All examples in the repository are validated against the current IR specification at build time. Examples that fail validation are automatically quarantined and excluded from user-facing results. Generated templates must pass all quality gates before being written to disk.
  • NO DOUBTS: Full investigation before action, evidence-based results. Each example includes provenance information indicating its source (production extraction, manual authoring, or template generation), its validation history, and its compatibility with the current IR specification version.

The example repository adheres to the NABLA Infinity framework by maintaining multiple independent examples for each concept (Signal Plurality), timestamping all examples with their creation and last-validation dates (Time Decay), and tracing each example to its source workflow or design decision (Provenance Mandatory).

  • /ir-generate - Generate IR workflows from natural language descriptions
  • /ir-validate - Comprehensive validation of IR workflows with DAG analysis and type safety
  • /ir-lint - Static analysis and code quality enforcement for IR workflows
  • /ir-benchmark - Comprehensive performance benchmarking with Benchee integration for IR workflows
  • /pvm-compile - Compile validated IR to optimized PVM bytecode
  • /pvm-execute - Execute compiled PVM programs with fault tolerance and real-time monitoring
  • /pvm-trace - Real-time execution tracing and debugging for PVM programs
  • /doc - Technical documentation and API reference generation

Connect & Contribute

Created by Tomáš Korcak (korczis) | Open Source under GHL