Table of Contents
- rgen
rgen
Language-agnostic generator for reproducible code projections.
rgen turns one ontology into CLI subcommands, APIs, schema files, and docs for any target language.
π§ Purpose
Developers repeat the same scaffolding logic across stacks. rgen removes the language barrier.
You describe the intent (command, type, or system capability) once as a graph or RDF-like metadata block.
rgen projects that intent into any target framework or language.
π Install
Homebrew
Cargo
βοΈ Quick start
Goal: generate a new CLI subcommand for any language.
Using marketplace rpacks (recommended)
# Search for CLI subcommand templates
# Install a high-quality rpack
# Generate using the installed rpack
Using local templates
Output depends on your template set (Rust, Python, Bash, etc). Each output is produced deterministically from the same RDF description.
πͺ Marketplace
The rgen marketplace provides a curated ecosystem of reusable code generation packs (rpacks) served directly from the GitHub repository. Discover, install, and use high-quality templates from the community.
Marketplace Source: seanchatmangpt/rgen
Registry URL: https://raw.githubusercontent.com/seanchatmangpt/rgen/master/registry/
Configuration: Set RGEN_REGISTRY_URL environment variable to override the default URL
Discover rpacks
# Search for templates by language and type
# Browse popular categories
# Get detailed information about a specific rpack
Install and use
# Install the latest version
# Install specific version
# List installed rpacks
# Update to latest versions
# Use installed rpack templates
Rpacks include templates, RDF schemas, SPARQL queries, and dependencies. They're versioned, tested, and maintained by the community.
π§© Templates
Templates are self-contained in their directories with local RDF graphs:
templates/
cli/
subcommand/
rust.tmpl # Template file
graphs/ # Local RDF data
cli.ttl
shapes/
cli.shacl.ttl
Each .tmpl has a YAML frontmatter header that describes:
to:β where to write the filevars:β default variablesrdf:β RDF files (relative to template directory)shape:β SHACL shape files for validationsparql:β queries to extract variables from graph datadeterminism:β optional seed for reproducibility
Example: templates/cli/subcommand/rust.tmpl
---
to: src/cmds/{{ cmd }}.rs
vars:
cmd: "hello"
summary: "Print a greeting"
rdf:
- "graphs/cli.ttl"
shape:
- "graphs/shapes/cli.shacl.ttl"
sparql:
- "SELECT ?cmd ?summary WHERE { ?cmd rdfs:label ?summary }"
determinism:
seed: "cli-subcommand"
sort_order:
---
use clap::Args;
use utils::error::Result;
#[derive(Args, Debug)]
pub struct {{ cmd|title }}Args {
/// {{ summary }}
#[arg(value_name = "INPUT")]
pub input: Option<String>,
}
pub async fn run(args: cmd|title }}Args) -> Result<()> {
println!("{{ summary }}");
Ok(())
}
Same RDF + seed β identical files every run.
π‘ Commands
| Command | Description |
|---|---|
| Marketplace | |
rgen search <query> |
Search for rpacks in registry |
rgen categories |
Show popular categories and keywords |
rgen add <rpack> |
Install an rpack to the project |
rgen remove <rpack> |
Remove an rpack from the project |
rgen packs |
List installed rpacks |
rgen update [rpack] |
Update rpacks to latest versions |
| Generation | |
rgen gen <template> |
Generate code from templates |
rgen list |
List available template scopes and actions |
rgen show <template> |
Show template and resolved context |
| Validation | |
rgen validate <template> |
Validate RDF/SHACL graphs |
rgen lint <template> |
Lint template with schema validation |
| Utilities | |
rgen graph export |
Merge RDF sources into a single graph |
rgen hazard |
Generate hazard report |
rgen completion <shell> |
Generate shell completion scripts |
π Determinism
rgen computes a manifest hash over:
graph data + shape + frontmatter + template + seed
The same graph + seed = byte-identical results.
π§ Example: Multi-language CLI generation
Using marketplace rpacks
# Install multi-language CLI rpacks
# Generate for each language
Using local templates
Both approaches create:
src/cmds/status.rs
commands/status.py
commands/status.sh
All derived from one ontology. No duplicated logic, no language bias.
π§° Integrations
rgen doesnβt care about runtime:
- Works for Rust, Python, Bash, Go, TypeScript, etc.
- Graph-aware: uses RDF, JSON-LD, or YAML metadata.
- Deterministic output: same intent, same projection.
π¦ Extend
Create local templates
Add your own generator:
Edit frontmatter and target path. rgen will detect and render automatically.
Publish rpacks to marketplace
Share your templates with the community:
# Initialize new rpack
# Lint and test your rpack
# Publish to registry
Rpacks support versioning, dependencies, and comprehensive testing. See the marketplace documentation for details.
π License
MIT Β© rgen contributors
π Documentation
- Installation Guide - Detailed installation instructions
- Quick Start - Get up and running quickly
- Templates Guide - Creating and using templates
- Marketplace Guide - Using and publishing rpacks
- RDF & SPARQL - Semantic web integration
- Determinism - Reproducible generation
- CLI Reference - Complete command reference
rgen β one intent, many projections. Code is just a projection of knowledge.