Awesome-omni-skill baml-generator
Automatically regenerate BAML client code when .baml files are modified. Use after any changes to BAML definitions to keep generated code in sync.
install
source · Clone the upstream repo
git clone https://github.com/diegosouzapw/awesome-omni-skill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/diegosouzapw/awesome-omni-skill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/tools/baml-generator" ~/.claude/skills/diegosouzapw-awesome-omni-skill-baml-generator && rm -rf "$T"
manifest:
skills/tools/baml-generator/SKILL.mdsource content
BAML Code Generator
When to Use This Skill
Automatically invoke this skill when:
- User modifies any
file.baml - User creates new BAML functions or types
- User asks to update generated code
- After scaffolding new BAML components
- User mentions BAML client is out of sync
Examples That Trigger This Skill
- "I just updated the BAML function"
- "The type definitions changed"
- "Generate the client code"
- "Update the BAML client"
- After creating function: "Now make it usable in Python/TypeScript"
How to Use
-
Detect BAML project:
- Look for
directorybaml_src/ - Verify BAML configuration exists
- Check for modified
files.baml
- Look for
-
Determine if generation needed:
- Files were just modified
- User explicitly requests generation
- Client code is missing or outdated
-
Run code generation:
- Execute
commandbaml generate - Capture output and any errors
- Report success or failure
- Execute
-
Verify generated code:
- Check
directorybaml_client/ - Confirm files were created/updated
- Show what was generated
- Check
-
Provide usage guidance:
- Show import statements for target language
- Provide code example using generated client
- Mention next steps (testing, integration)
Generation Process
Standard Generation
baml generate
This command:
- Reads all
files in.bamlbaml_src/ - Generates typed client code
- Outputs to
directorybaml_client/ - Creates language-specific modules
Watch Mode (Development)
For active development, suggest watch mode:
baml generate --watch
Benefits:
- Automatically regenerates on file changes
- Fast feedback during development
- No manual generation needed
Language-Specific Output
Generated structure varies by language:
Python:
baml_client/ ├── __init__.py ├── client.py ├── types.py └── functions/ ├── extract_receipt.py └── ...
TypeScript:
baml_client/ ├── index.ts ├── client.ts ├── types.ts └── functions/ ├── extractReceipt.ts └── ...
After Generation
Python Usage Example
from baml_client import b # Async call result = await b.ExtractReceipt(image="path/to/receipt.jpg") print(f"Vendor: {result.vendor}") print(f"Total: ${result.total}") # Streaming async for partial in b.stream.SummarizeText(text=long_text): print(partial)
TypeScript Usage Example
import { b } from './baml_client'; // Async call const result = await b.ExtractReceipt({ image: "path/to/receipt.jpg" }); console.log(`Vendor: ${result.vendor}`); console.log(`Total: $${result.total}`); // Streaming const stream = b.stream.SummarizeText({ text: longText }); for await (const partial of stream) { console.log(partial); }
Error Handling
Common Errors
"No BAML files found":
- Check
exists and containsbaml_src/
files.baml - Verify working directory is project root
"Parse error in X.baml":
- Read error message for line number
- Check syntax (missing braces, typos, etc.)
- Offer to fix syntax errors
"Client already exists":
- Name conflict in client definitions
- Check
for duplicate namesclients.baml
"Invalid type reference":
- Type used in function doesn't exist
- Check type definitions and imports
Recovery
If generation fails:
- Show error message to user
- Identify problematic file and line
- Suggest fix or offer to correct
- Re-run generation after fix
Integration with Workflows
After Creating Function
User: [creates new BAML function] Claude: [Uses baml-scaffolder skill] Claude: [Automatically uses baml-generator skill] Result: Function ready to use in code
After Editing Types
User: [modifies class definition] Claude: [Detects .baml file change] Claude: [Uses baml-generator skill] Result: Updated types in generated code
Best Practices
- Always regenerate after changes: Don't let generated code get stale
- Use watch mode in development: Fastest workflow
- Commit baml_src/, gitignore baml_client/: Source vs generated
- Verify generation success: Check for errors before continuing
- Show usage examples: Help user understand how to use generated code
Automation
This skill enables autonomous workflow:
- User describes AI functionality
creates BAML definitionsbaml-scaffolder
creates usable client code (THIS SKILL)baml-generator- User can immediately use in their application
No manual steps needed - Claude handles the full pipeline.
Notes
- Generated code is fully typed - leverage IDE autocomplete
- Generation is fast (< 1 second typically)
- Each language gets idiomatic code (Pythonic in Python, TypeScript patterns in TS)
- Streaming support is automatically included
- Error handling and retry logic built into generated client