Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
agentic-insights avatar

Baml Codegen

  • 1 installs
  • 5 repo stars
  • Updated June 5, 2026
  • agentic-insights/foundry

baml-codegen is a Claude Code skill that generates type-safe BAML code for LLM extraction, classification, RAG, and agent workflows from natural-language requirements.

About

baml-codegen is a Claude Code skill that generates type-safe BAML code for LLM extraction, classification, RAG, and agent workflows. From natural-language requirements it produces complete .baml files with types, functions, clients, tests, and framework integrations for Python, TypeScript, Ruby and Go. It queries official BoundaryML repositories via MCP for current patterns and supports multimodal image and audio inputs.

  • Generates type-safe BAML code for LLM extraction, classification, RAG and agents
  • Emits complete .baml files with types, functions, clients, tests and retry policies
  • Queries BoundaryML repositories via MCP for real-time patterns; works offline from cache

Baml Codegen by the numbers

  • 1 all-time installs (skills.sh)
  • Ranked #14,102 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
  • Data as of Jul 7, 2026 (Skillselion catalog sync)
At a glance

baml-codegen capabilities & compatibility

requires an LLM provider API key (openai, anthropic, gemini, etc.) for the generated clients

Capabilities
code generation · llm extraction · classification · rag
Works with
openai · anthropic
Use cases
api development · orchestration · research
Pricing
Bring your own API key
From the docs

What baml-codegen says it does

Generate type-safe LLM extraction code. Use when creating structured outputs, classification, RAG, or agent workflows.
SKILL.md
**NEVER edit `baml_client/`** - 100% generated, overwritten on every `baml-cli generate`
SKILL.md
**Transpiler Not Library** - Write `.baml` → generate native code (Python/TypeScript/Ruby/Go), no runtime dependency
SKILL.md
npx skills add https://github.com/agentic-insights/foundry --skill baml-codegen

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs1
repo stars5
Last updatedJune 5, 2026
Repositoryagentic-insights/foundry

What it does

Generate type-safe BAML code for LLM extraction, classification, RAG and agent workflows.

Who is it for?

Producing type-safe LLM extraction, classification or RAG code as complete .baml files with tests.

Skip if: Editing generated baml_client code, which the skill says is 100% generated and overwritten on every generate.

When should I use this skill?

The user is generating BAML code for type-safe LLM extraction, classification, RAG, or agent workflows.

What you get

The skill emits complete .baml files with types, functions, clients, tests and framework integrations.

  • .baml files with types, functions and clients
  • pytest or jest tests
  • framework integration code

By the numbers

  • supports Python, TypeScript, Ruby and Go targets
  • claims 50-70% token optimization and 95%+ compilation success

Files

SKILL.mdMarkdownGitHub ↗

BAML Code Generation

Generate type-safe LLM extraction code. Use when creating structured outputs, classification, RAG, or agent workflows.

Golden Rules

  • NEVER edit `baml_client/` - 100% generated, overwritten on every baml-cli generate; check baml_src/generators.baml for output_type (python, typescript, ruby, go)
  • ALWAYS edit `baml_src/` - Source of truth for all BAML code
  • Run `baml-cli generate` after changes - Regenerates typed client code for target language

Philosophy (TL;DR)

  • Schema Is The Prompt - Define data models first, compiler injects types
  • Types Over Strings - Use enums/classes/unions, not string parsing
  • Fuzzy Parsing Is BAML's Job - BAML extracts valid JSON from messy LLM output
  • Transpiler Not Library - Write .baml → generate native code (Python/TypeScript/Ruby/Go), no runtime dependency
  • Test-Driven Prompting - Use VS Code playground or baml-cli test to iterate

Workflow

Analyze → Pattern Match (MCP) → Validate → Generate → Test → Deliver
         ↓ [IF ERRORS] Error Recovery (MCP) → Retry

BAML Syntax

ElementExample
Classclass Invoice { total float @description("Amount") @assert(this > 0) @alias("amt") }
Enumenum Category { Tech @alias("technology") @description("Tech sector"), Finance, Other }
Functionfunction Extract(text: string, img: image?) -> Invoice { client GPT5 prompt #"{{ text }} {{ img }} {{ ctx.output_format }}"# }
Clientclient<llm> GPT5 { provider openai options { model gpt-5 } retry_policy Exponential }
Fallbackclient<llm> Resilient { provider fallback options { strategy [FastModel, SlowModel] } }

Types

  • Primitives: string, int, float, bool | Multimodal: image, audio
  • Containers: Type[] (array), Type? (optional), map<string, Type> (key-value)
  • Composite: Type1 | Type2 (union), nested classes
  • Annotations: @description("..."), @assert(condition), @alias("json_name"), @check(name, condition)

Providers

openai, anthropic, gemini, vertex, bedrock, ollama + any OpenAI-compatible via openai-generic

Pattern Categories

PatternUse CaseModelFramework Markers
ExtractionUnstructured → structuredGPT-5fastapi, next.js
ClassificationCategorizationGPT-5-miniany
RAGAnswers with citationsGPT-5langgraph
AgentsMulti-step reasoningGPT-5langgraph
VisionImage/audio data extractionGPT-5-Visionmultimodal

Resilience

  • retry_policy: retry_policy Exp { max_retries 3 strategy { type exponential_backoff } }
  • fallback client: Chain models [FastCheap, SlowReliable] for cost/reliability tradeoff

MCP Indicators

  • Found patterns from baml-examples | Validated against BoundaryML/baml | Fixed errors using docs | MCP unavailable, using fallback

Output Artifacts

1. BAML Code - Complete .baml files (types, functions, clients, retry_policy) 2. Tests - pytest/Jest with 100% function coverage 3. Integration - Framework-specific client code (LangGraph nodes, FastAPI endpoints, Next.js API routes) 4. Metadata - Pattern used, token count, cost estimate

References

  • providers.md - OpenAI, Anthropic, Google, Ollama, Azure, Bedrock, openai-generic
  • types-and-schemas.md - Full type system, classes, enums, unions, map, image, audio
  • validation.md - @assert, @check, @alias, block-level @@assert
  • patterns.md - Pattern library with code examples
  • philosophy.md - BAML principles, golden rules
  • mcp-interface.md - Query workflow, caching
  • languages-python.md - Python/Pydantic, async
  • languages-typescript.md - TypeScript, React/Next.js
  • frameworks-langgraph.md - LangGraph integration

Related skills

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.