Baml codegen

From lxyeternal/MalSkillBench · View interactive version

Baml codegen is an AI agent skill from the GitHub repository lxyeternal/MalSkillBench. Use when generating BAML code for type-safe LLM extraction, classification, RAG, or agent workflows - creates complete .baml files with types, functions, clients, tests, and framework integrations from natural language requirements. Queries official BoundaryML repositories via MCP for real-time patt

How to use this skill

Skill file

BAML Code Generation

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

Golden Rules

Philosophy (TL;DR)

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

Providers

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

Pattern Categories

| Pattern | Use Case | Model | Framework Markers |

|---------|----------|-------|-------------------|

| Extraction | Unstructured → structured | GPT-5 | fastapi, next.js |

| Classification | Categorization | GPT-5-mini | any |

| RAG | Answers with citations | GPT-5 | langgraph |

| Agents | Multi-step reasoning | GPT-5 | langgraph |

| Vision | Image/audio data extraction | GPT-5-Vision | multimodal |

Resilience

MCP Indicators

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

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.