baml-integration

Integrate BAML outputs into Sagebase pipelines with type-safe client regeneration.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/sage-base/sagebase --skill baml-integration-sage-base
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: baml-integration
Source: https://github.com/sage-base/sagebase/tree/main/.claude/skills/baml-integration
Command: npx skills add https://github.com/sage-base/sagebase --skill baml-integration-sage-base

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Sagebase projects using BAML often struggle with maintaining consistent, type-safe bindings between defined BAML schemas and generated clients. This skill consolidates best practices for creating BAML definitions, regenerating clients, and applying hybrid design patterns to ensure reliable, scalable integrations.

Core Features & Use Cases

  • BAML Definitions: Create and manage .baml files in baml_src/ to describe prompts, schemas, and client behavior.
  • Client Regeneration: Automate regeneration of the baml_client code after changes, ensuring synchronization with definitions.
  • Hybrid Patterns: Implement hybrid approaches (rule-based matching + BAML) to optimize performance and cost, while maintaining accuracy.
  • Factory Patterns: Use factory patterns to instantiate BAML-based services and promote modularity.

Quick Start

Create a new .baml definition in baml_src/ (e.g., politician_matching.baml) and run the BAML client generation script to produce or update the corresponding Python client under baml_client/. Then integrate the generated client into your service.

Frequently Asked Questions about baml-integration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I integrate BAML outputs into Python pipelines for type-safe data handling?

Integrate BAML outputs by defining schemas in .baml files and regenerating the baml_client to produce type-safe Python bindings. This validates outputs against Pydantic-compatible models, ensuring robust data handling across CLIs and services within Sagebase pipelines.

What is the best way to keep BAML client code synchronized with my .baml definitions?

Keep BAML client code synchronized by running the BAML client generation script after modifying .baml files in baml_src/. This regenerates the corresponding Python client under baml_client/, ensuring your generated code matches your updated definitions.

When should I use hybrid matching patterns with BAML instead of pure LLM calls?

Use hybrid matching patterns with BAML to optimize performance and cost while maintaining accuracy. Combining rule-based matching with BAML allows you to handle deterministic logic efficiently, reserving LLM processing for complex scenarios.

Can I validate BAML generated outputs against Pydantic models in my service?

Yes, you can validate BAML generated outputs against Pydantic models. This skill guides best practices for validating generated client outputs, ensuring robust and type-safe data handling across your Sagebase pipelines and services.

How do I structure BAML services to promote modularity in my application?

Structure BAML services using factory patterns to instantiate BAML-based components. This promotes modularity by centralizing service instantiation, making it easier to manage dependencies and scale your type-safe data handling processes.

What are the limitations of using BAML for type-safe code generation?

BAML requires access to BAML definitions and client tooling, meaning your project must maintain .baml files in baml_src/ and run regeneration scripts to prevent schema binding mismatches. It is not a standalone solution and requires pipeline integration.