# Build Type-Safe BAML Integrations

Unstructured LLM outputs create fragile integrations and repeated parsing work. This skill guides BAML schema design, client generation, synchronization, and wrapper implementation.

## Install

```bash
npx skillstore add consiliency/baml-integration
```

## Metadata

- Status: approved
- Slug: consiliency-baml-integration
- Skillstore revision: r1
- Version status: missing
- Tree hash: 224233b303dfeec62998ebde9c078c68bc10f0ea67dd9792c34cd3c3125b2e7c
- Author: Consiliency
- GitHub username: Consiliency
- License: MIT
- Repository: https://github.com/Consiliency/treesitter-chunker/tree/main/.ai-dev-kit/skills/baml-integration
- Ref: 635f69fb8d2f4e6330ba47a4e5a0fb239c04d110
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem, network
- Quality score: 50
- Quality tier: warning
- Public page: https://skillstore.pages.dev/skills/consiliency-baml-integration
- Manifest: https://skillstore.pages.dev/api/skills/consiliency-baml-integration/manifest

## Capabilities

- Inspects existing BAML files, generated clients, and generator configuration.
- Designs classes, enums, unions, and typed request and response models.
- Guides Python and TypeScript client generation with the BAML CLI.
- Aligns BAML types with database models, API contracts, and frontend types.
- Provides wrapper patterns for retries, caching, rate limits, fallbacks, metrics, and structured errors.

## Use Cases

- Add a Typed LLM Feature: Define clear BAML inputs and outputs, generate a client, and connect the function to a backend service.
- Synchronize Application Schemas: Compare BAML types with database and API models, then plan compatible schema updates and client regeneration.
- Share Types Across the Stack: Generate Python and TypeScript DTOs that keep service and frontend contracts aligned.

## Prompt Templates

### Inspect Existing Setup

```
Inspect this repository for BAML sources, generator configuration, and generated clients. Summarize the current setup and identify missing prerequisites. Do not modify files.
```

### Design a Typed Function

```
Design BAML input and output types for [feature]. Reuse existing types where suitable. Include field descriptions, error variants, and the client generation steps.
```

### Plan Schema Synchronization

```
Compare the BAML schema with [database or API models]. List mismatches, compatibility risks, migration order, consumer updates, and client regeneration checks.
```

### Build a Production Wrapper

```
Implement a BAML client wrapper for [language and framework]. Include bounded caching, retries, rate limits, sanitized errors, metrics, dependency injection, and focused tests.
```

## Limitations

- The skill provides guidance and examples, not an executable integration package.
- BAML and the required model providers must be installed and configured separately.
- Generic examples require adaptation to project schemas, frameworks, and deployment controls.
- Type-safe output does not prevent prompt injection, and field descriptions do not replace runtime validation.

## Best Practices

- Review existing schemas before adding types or functions.
- Regenerate clients after every BAML change and verify the generated diff.
- Validate external inputs and sanitize errors at application boundaries.

## Anti Patterns

- Do not parse structured model output manually when a BAML type can represent it.
- Do not edit generated clients directly because regeneration will overwrite changes.
- Do not use unbounded caches or expose raw provider errors in production wrappers.

## Security Audit

- Audited at: 2026-07-13T15:25:24.609\+00:00
- Summary: All 80 static findings are false positives caused by Markdown syntax, fixed imports, benign identifiers, or constrained maintenance commands. Three medium-risk examples remain: mutable CI dependencies, raw exception disclosure, and unbounded in-memory caches. No audit-directed prompt injection, credential theft, or malicious command intent was found.

## Stats

- Views: 217
- Downloads: 8
- Favorites: 0
- Popularity score: 0
