Skip to content

codegen

A scriptable meta-programming engine for modern C++.

codegen is a production-grade C++ code generation engine. You annotate C++ declarations directly in source — structs, classes, enums, free functions, aliases — and each rule declares in its YAML which AST node kinds it consumes. You write a LuaU script that receives a structured AST node as JSON and emits whatever you want — C++, TypeScript, Markdown, SQL. The engine handles the rest: parsing, scheduling, deduplication, inline injection, and file routing.

It ships as a single binary. It calls nothing home. It runs the same on every machine.

codegen separates the problem into two clean layers:

  1. Parsing — handled by the engine. The full C++ AST is resolved and serialised to JSON, including namespaces, template arguments, member variables, enumerators, and annotations.
  2. Transformation — handled by you, in LuaU. Your rule receives one AST node as JSON and returns output text. The rule has no compiler coupling, no filesystem access, and no network access.

This split is what makes everything below possible.


Deterministic output

Same source ⇒ same output. Always. The engine is a pure function over your AST. Generated files are stable across machines and CI runs, making diffs meaningful and code review tractable.

Non-1:1 generation

Most generators emit one output file per input file. codegen does not require this. A grouping.luau script routes each matched entity to any output path — fan-in dozens of structs into a single api-reference.md, a registry.cpp, or a sorted bindings.ts. The topology is yours to define.

Cross-language generation

Rules emit text. The engine does not care whether that text is C++, TypeScript, Markdown, SQL, or a JSON manifest. One annotated C++ type can drive a serialiser, an FFI binding, a documentation page, and a database migration — all from the same source of truth.

LLM-ready AST schema

The C++ AST is fully serialised as JSON before any rule sees it. Rules are testable without a compiler, inspectable with jq, and the full docs are also published as a single plain-text bundle at /llms-full.txt — drop it into any LLM agent for codegen-aware code intelligence.

Rules testable in isolation

Feed a JSON blob to a rule, assert on the output. No compiler, no project, no fixtures. The same property that makes rules LLM-friendly makes them unit-testable in seconds.

Isolated execution

LuaU runs in a sandboxed VM. Rules have no filesystem access, no network access, no process spawning — unless you explicitly grant permissions in the config. A malicious rule in a third-party library cannot exfiltrate your source code.

Inline injection

Rules can emit a source (to a .g.cpp file) and an inline list — declarations injected back into the original header at a designated anchor comment. Bare anchors are rewritten into idempotent :begin]] / :end]] blocks on first run.

Self-hosted

codegen generates parts of its own infrastructure. We use it ourselves to build it, so every feature you rely on has already been exercised against a 100k+ LoC real-world codebase.


Community

Free forever

For open-source projects and personal exploration.

  • CLI-only interface
  • All built-in rule examples included
  • Community support (GitHub Issues)

No commercial use.

Professional

€12 / month · €99 / year · Individual

For solo developers building commercial software.

  • Everything in Community
  • TUI diff viewer: review generated changes before applying
  • VS Code DAP debugger: step through LuaU rules in the editor

14-day free trial. Annual saves ~31% (€8.25 / month effective).

Team

from €24 / seat / month · €230 / seat / year · Organization

For engineering teams that ship at scale.

  • Everything in Professional
  • CMake integration: rules run as part of the build graph
  • Shared .codegen/shared/ libraries: standardise grouping and preambles
  • Priority support: direct response SLA

30-day free trial. Volume discounts: 15% at 5+ seats, 25% at 20+ seats.