TypePrompt: open-source compiler turns prompt templates into typesafe APIs in 8 languages
gepheum · reddit · 2026-11-23
A developer released TypePrompt (MIT), a compiler for prompt templates that solves the problem of prompts living in files the compiler can't check — renamed fields breaking placeholders, changed output types contradicting system prompts, few-shot examples teaching outdated JSON shapes.
How it works: each prompt is a self-contained .tp file with instructions, Input/Output schemas (a TypeScript subset), tools, and few-shot examples. Running npx @typeprompt/cli gen validates placeholder paths/types/formats, inline references, and every example at build time, then compiles to native code for TypeScript, Python, Kotlin, Rust, C++, Swift, Dart, or C#.
It's not an SDK wrapper and makes no network calls: you write one generic executePrompt helper with any SDK (OpenAI, Anthropic, Gemini, Ollama, internal gateway), and TypePrompt hands it rendered messages, strict JSON Schemas, and tool definitions, then parses/validates responses. Ships with a VS Code extension.
More from coding & agent
- Solo dev ships AquaPaths puzzle game in 6 months — 9 of 10 commits co-authored by Claude Code — Pleasant_Present_160 · 2026-11-23
- A Five-Level Maturity Model for Safe Agent Interaction with Applications — crotalul94 · 2026-11-23
- Open-source AI video editor Scarlet gains traction as Gemini's native audio stands out — MatthewBerman · 2026-11-23
- Dev builds a lights-control API and lets an AI watch his camera to auto-optimize lighting — TheZachMueller · 2026-11-23
- Data Scientist's pick: 'Software Engineering for Data Scientists' bridges notebooks to production code — mdancho84 · 2026-11-23
- 10-book AI engineering reading list for 2026, ordered from ML basics to production LLM systems — mdancho84 · 2026-11-23