baml-codegen

baml-codegen is a skill for Claude Code from Agentic-Insights/foundry. It costs 100 tokens per session (1,241 once invoked), scanned A, original, Apache-2.0.

A code generator for BAML, a language for asking AI models to extract structured data. It creates schemas, model functions, clients, tests, and integrations for Python, TypeScript, Ruby, or Go.

In plain words
What is it for?
Use it to build extraction, classification, retrieval-augmented generation, or agent workflows with defined data types, provider settings, tests, and generated clients.
Why use it?
It turns natural-language requirements into typed extraction code and regenerates the client code when the BAML source changes. This reduces manual work when building structured AI workflows.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the baml plugin — 1 skill, 4 commands shipped together

Good fit Use it to build extraction, classification, retrieval-augmented generation, or agent workflows with defined data types, provider settings, tests, and generated clients.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/agentic-insights/foundry/baml-codegen
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add Agentic-Insights/foundry --skill baml-codegen
Clone the repo
git clone --depth 1 https://github.com/Agentic-Insights/foundry

Made for: Claude Code.

Or install baml, the plugin that ships this one along with the rest of its 1 skill, 4 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for baml-codegen

README.md
[![agentmods](https://agentmods.dev/badge/skills/agentic-insights/foundry/baml-codegen/github.svg)](https://agentmods.dev/skills/agentic-insights/foundry/baml-codegen)
Your own site
<a href="https://agentmods.dev/skills/agentic-insights/foundry/baml-codegen"><img src="https://agentmods.dev/badge/skills/agentic-insights/foundry/baml-codegen/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for baml-codegen

Your own site · 80×15
<a href="https://agentmods.dev/skills/agentic-insights/foundry/baml-codegen"><img src="https://agentmods.dev/badge/skills/agentic-insights/foundry/baml-codegen.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 100 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,241 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00100 $0.01241
Opus 5.5 $0.00040 $0.00496
Sonnet 5.5 $0.00020 $0.00248
Haiku 4.5 $0.00010 $0.00124

Measured 1mo ago against content hash 3705e1cf6958, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

baml-codegen scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/baml/skills/baml-codegen/SKILL.md · 91 lines

How it starts

The opening of the file, as written. The whole thing — 91 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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

Element Example
Class class Invoice { total float @description("Amount") @assert(this > 0) @alias("amt") }
Enum enum Category { Tech @alias("technology") @description("Tech sector"), Finance, Other }
Function function Extract(text: string, img: image?) -> Invoice { client GPT5 prompt #"{{ text }} {{ img }} {{ ctx.output_format }}"# }
Client client<llm> GPT5 { provider openai options { model gpt-5 } retry_policy Exponential }
Fallback client<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)

Read the full file on GitHub · 91 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 91 lines · 100 tokens per session scan A 3705e1cf6958

Subscribe to this mod's changes

baml-codegen is a skill published in the GitHub repository Agentic-Insights/foundry (5 stars, last pushed 4mo ago), licensed Apache-2.0. It adds 100 tokens to every session and 1,241 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

embeddings

Vector embeddings with HNSW indexing, sql.js persistence, and hyperbolic support. 75x faster with agentic-flow integration. Use when: semantic search, pattern matching, similarity queries, knowledge retrieval. Skip when: exact text matching, simple lookups, no semantic understanding needed.

ruvnet/ruflo · 62 tokens

agent-platform-rag-engine-management

Manage and query Agent Platform RAG Engine Corpora and retrieve grounded contexts using the Google GenAI SDK. Use when listing RAG corpora or files, inspecting a corpus, retrieving contexts, or generating content grounded in a RAG corpus. Do not use for standard database queries (use SQL/Spanner skills), Google…

google/skills · 85 tokens

llm-app-patterns

Production-ready patterns for building LLM applications. Covers RAG pipelines, agent architectures, prompt IDEs, and LLMOps monitoring. Use when designing AI applications, implementing RAG, building agents, or setting up LLM observability.

davila7/claude-code-templates · 54 tokens

9router-embeddings

Generate vector embeddings via 9Router /v1/embeddings using OpenAI / Gemini / Mistral / Voyage / Nvidia / GitHub embedding models for RAG, semantic search, similarity. Use when the user wants embeddings, vectors, RAG, semantic search, or to embed text.

decolua/9router · 66 tokens

similarity-search-patterns

Implement efficient similarity search with vector databases. Use when building semantic search, implementing nearest neighbor queries, or optimizing retrieval performance.

foryourhealth111-pixel/Vibe-Skills · 30 tokens

embedding-strategies

Select and optimize embedding models for semantic search and RAG applications. Use when choosing embedding models, implementing chunking strategies, or optimizing embedding quality for specific domains.

foryourhealth111-pixel/Vibe-Skills · 37 tokens