baml-codegen
Generates production-ready BAML applications from natural language requirements. Creates complete type definitions, functions, clients, tests, and framework integrations for data extraction, classification, RAG, and agent workflows. Queries official BoundaryML repositories via MCP for real-time patterns. Supports multimodal inputs (images, audio), 6 programming languages (Python, TypeScript, Ruby, Java, Go, C#), 10+ frameworks, 50-70% token optimization, and 95%+ compilation success.
What this skill does
# BAML Code Generation Skill
**Version**: 1.2.0
**Status**: Production (Two-Phase MCP Validation)
**Token Budget**: ~3800 tokens (validated)
## Overview
Generate production-ready BAML applications by querying official BoundaryML repositories through MCP servers. This skill extracts patterns, validates syntax, and synthesizes complete solutions including types, functions, tests, and integrations.
## Activation Triggers
- Keywords: BAML, LLM, structured output, code generation, extraction, classification
- User requests to generate BAML code
- Questions about BAML syntax or patterns
## Prerequisites
**Required MCP Servers**:
- `baml_Docs`: Core BAML repository access
- `baml_Examples`: Production pattern examples (optional)
**Validation**: Check MCP availability before proceeding. If unavailable, use embedded fallback cache.
## Core Capabilities
### 1. Pattern Recognition
**Algorithm**: Multi-stage pattern detection
```
INPUT: Natural language requirement
OUTPUT: Pattern category + matched examples
STEPS:
1. Tokenize requirement text
2. Match trigger keywords:
- extraction: [extract, parse, structure, data]
- classification: [classify, categorize, label]
- rag: [search, retrieve, context, citation]
- agents: [agent, plan, execute, tool]
3. Score categories (frequency + position weighting)
4. Select primary category (threshold > 0.5)
5. **EXECUTE MCP QUERIES** (Critical for freshness):
- mcp__baml_Examples__search_baml_examples_code("{category} extension:baml")
- Fetch top 2-3 results via mcp__baml_Docs__fetch_generic_url_content
- Parse types, functions, prompts from real examples
- VALIDATE: Query baml_Docs to verify syntax is current (not deprecated)
- Output: "๐ Found {X} patterns from BoundaryML/baml-examples"
- Fall back to cache only if MCP unavailable
```
### 2. Code Synthesis Pipeline
**Template-Based Generation**:
```
PHASE 1: Type Inference
- Extract entities from requirements
- Map to BAML types (class, enum, primitive)
- Generate type definitions with @description
PHASE 2: Function Generation
- Determine function signature
- Select appropriate client/model
- Synthesize prompt template
- Inject ctx.output_format
PHASE 3: Client Configuration
- Match model to use case:
* Multimodal โ vision model
* Classification โ fast model (GPT-5-mini)
* Complex โ reasoning model (GPT-5)
- Generate client block with options
PHASE 4: Validation
- Syntax check (BAML grammar)
- Type safety (all refs defined)
- Completeness (all components present)
```
### 3. MCP Query Patterns
**Available Tools**:
```yaml
mcp__baml_Docs__fetch_baml_documentation:
Purpose: Fetch complete README
Use: General context, fallback
Cost: ~3000 tokens
mcp__baml_Docs__search_baml_documentation:
Purpose: Semantic search
Use: Find specific features
Cost: 200-1000 tokens
mcp__baml_Docs__search_baml_code:
Purpose: GitHub code search
Use: Find implementation examples
Cost: ~500 tokens (30 results/page)
mcp__baml_Docs__fetch_generic_url_content:
Purpose: Fetch specific file
Use: Detailed reference
Cost: 500-2000 tokens
```
**Query Strategy**:
1. Check session cache first (15 min TTL)
2. Check persistent cache (7 day TTL)
3. Query MCP if cache miss
4. Validate with commit hash
### 4. BAML Syntax Reference
**Core**: class, enum, function, client | **Types**: string, int, float, bool, Type[], Type?, Type|Type
**Key Patterns**: @description("..."), {{ param }}, {{ ctx.output_format }}
**Providers**: openai, anthropic, gemini, vertex, bedrock
*Query MCP for complete syntax: mcp__baml_Docs__search_baml_documentation("syntax")*
### 5. Optimization Strategies
**Token Reduction**:
- Remove redundant @description attributes
- Apply symbol tuning to prompts
- Consolidate similar types
- Use @alias for long identifiers
- Target: 50-70% reduction vs baseline
**Performance**:
- Cache frequently used patterns
- Batch related MCP queries
- Preload top 10 patterns on activation
- Target: <5s simple, <30s complex
### 6. Validation Pipeline
**5-Layer Validation**:
1. **Syntax**: Parse with BAML grammar
2. **Types**: All references defined, no cycles
3. **Semantics**: Prompt coherence check
4. **Tests**: 100% function coverage
5. **Performance**: Token count, cost estimate
**Success Criteria**:
- First-time compilation: >95%
- Type safety: 100% (guaranteed)
- Test pass rate: >90%
## Workflow
```
User Request
โ
[1] Analyze Requirements
- Parse text
- Identify pattern (extraction/classification/rag/agents)
- Extract entities and constraints
โ
[2] Pattern Matching **๐ MCP REQUIRED**
- Execute: mcp__baml_Examples__search_baml_examples_code
- Fetch: mcp__baml_Docs__fetch_generic_url_content
- Parse: Extract types/functions/prompts from real code
- Rank by similarity (>0.7 threshold)
- Select top 3 candidates
- Output: "๐ Found {X} patterns from BoundaryML/baml-examples"
โ
[2.5] Syntax Validation **๐ baml_Docs**
- Query: mcp__baml_Docs__search_baml_documentation("syntax {feature}")
- Compare: Example syntax vs canonical docs from BoundaryML/baml
- Modernize: Update deprecated patterns to current spec
- Output: "โ
Validated against BoundaryML/baml" OR "๐ง Modernized {N} patterns"
โ
[3] Code Generation
- Generate types (classes, enums)
- Generate function (signature, prompt, client)
- Generate client configuration
โ
[4] Test Generation
- Happy path tests
- Edge case tests
- Error handling tests
โ
[5] Integration Generation
- Python/TypeScript/Ruby client code
- Framework-specific endpoints
- Deployment configuration
โ
[6] Validation & Optimization
- Validate syntax and types
- Optimize for tokens
- Estimate costs
โ
[6.5] Error Recovery **๐ง IF ERRORS**
- Extract: Parse error message from validation
- Query: mcp__baml_Docs__search_baml_documentation("{error}")
- Fetch: Current syntax spec from BoundaryML/baml
- Fix: Update code to match canonical specification
- Retry: Re-validate (max 2 attempts)
- Output: "๐ง Fixed {N} errors using BoundaryML/baml docs"
โ
[7] Deliver Artifacts
- BAML code
- Test suite
- Integration code
- Deployment config
- Performance metadata
```
## MCP Query Execution
**CRITICAL**: Always query MCP for fresh patterns during code generation.
**Observable Indicators** (show user MCP usage):
- ๐ "Found {X} patterns from BoundaryML/baml-examples"
- โ
"Fetched {file} from BoundaryML/baml"
- โ
"Validated against BoundaryML/baml - syntax current"
- ๐ง "Modernized {N} deprecated patterns from example"
- ๐ง "Fixed {N} errors using BoundaryML/baml docs"
- ๐ฆ "Using cached pattern (MCP unavailable)"
- โ ๏ธ "MCP unavailable, using fallback templates"
**Execution Order**:
1. Check MCP availability first
2. Execute queries for pattern category
3. Parse real code examples
4. Adapt to requirements
5. Fall back to cache only if MCP fails
## Caching Strategy
**Multi-Tier Cache**:
```
Tier 1 (Embedded): Core syntax (500 tokens, never expires)
Tier 2 (Session): Recent patterns (15 min TTL, LRU eviction)
Tier 3 (Persistent): Top 20 patterns (7 day TTL)
Tier 4 (MCP): Live queries (no cache, always fresh)
```
**Invalidation**:
- Session end โ Clear Tier 2
- 7 days โ Refresh Tier 3
- Commit hash change โ Invalidate all
- Manual refresh command
## Error Handling
**MCP Unavailable**:
- Fall back to Tier 1-3 caches
- Use generic templates
- Warn user about limited patterns
**Pattern Not Found**:
- Use generic template for category
- Request more specific requirements
- Suggest similar patterns
**Validation Failure**:
- Auto-query: mcp__baml_Docs__search_baml_documentation("{error}")
- Compare: Generated code vs canonical BoundaryML/baml syntax
- Auto-fix: Update code to match current specification
- Retry: Re-validate with modernized code (max 2 attempts)
- Report: "๐ง Fixed {N} issues" or detailed error if unfixable
**Generation TimeoutRelated in Image & Video
watch
IncludedWatch a video (URL or local path). Downloads with yt-dlp, extracts auto-scaled frames with ffmpeg, pulls the transcript from captions (or Whisper API fallback), and hands the result to Claude so it can answer questions about what's in the video.
physical-ai-defect-image-generation
IncludedUse when the user wants to orchestrate defect image generation, run associated setup, or handle outputs on OSMO. The Day 0 path handles cold-start with USD-to-ROI, image-edit augmentation, and AnomalyGen to create initial PCBA datasets. The Day 1 path performs inference and labeling on real images. This skill helps with first-time asset setup, creation of finetuning checkpoints, and configuring deployment. Trigger keywords: defect image generation, dig workflow, dig pipeline, defect image detection workflow, aoi pipeline, aoi anomalygen, usd2roi anomalygen, day 0 pcba, day 1 pcba, day 1 real-photo alignment, day 1 manual roi, metal surface anomaly, glass defect, anomalygen finetune, setup_pcb, setup_metal, setup_glass, setup_pretrained, dig setup, dig datasets, dig pretrained checkpoint, dig image-edit endpoint.
accelint-react-best-practices
IncludedReact performance optimization and best practices. ALWAYS use this skill when working with any React code - writing components, hooks, JSX; refactoring; optimizing re-renders, memoization, state management; reviewing for performance; fixing hydration mismatches; debugging infinite re-renders, stale closures, input focus loss, animations restarting; preventing remounting; implementing transitions, lazy initialization, effect dependencies. Even simple React tasks benefit from these patterns. Covers React 19+ (useEffectEvent, Activity, ref props). Triggers - useEffect, useState, useMemo, useCallback, memo, inline components, nested components, components inside components, re-render, performance, hydration, SSR, Next.js, useDeferredValue, combined hooks.
elevenlabs-agents
IncludedBuild conversational AI voice agents with ElevenLabs Platform using React, JavaScript, React Native, or Swift SDKs. Configure agents, tools (client/server/MCP), RAG knowledge bases, multi-voice, and Scribe real-time STT. Use when: building voice chat interfaces, implementing AI phone agents with Twilio, configuring agent workflows or tools, adding RAG knowledge bases, testing with CLI "agents as code", or troubleshooting deprecated @11labs packages, Android audio cutoff, CSP violations, dynamic variables, or WebRTC config. Keywords: ElevenLabs Agents, ElevenLabs voice agents, AI voice agents, conversational AI, @elevenlabs/react, @elevenlabs/client, @elevenlabs/react-native, @elevenlabs/elevenlabs-js, @elevenlabs/agents-cli, elevenlabs SDK, voice AI, TTS, text-to-speech, ASR, speech recognition, turn-taking model, WebRTC voice, WebSocket voice, ElevenLabs conversation, agent system prompt, agent tools, agent knowledge base, RAG voice agents, multi-voice agents, pronunciation dictionary, voice speed control, elevenlabs scribe, @11labs deprecated, Android audio cutoff, CSP violation elevenlabs, dynamic variables elevenlabs, case-sensitive tool names, webhook authentication
humanizer
IncludedHumanize AI-generated text by detecting and removing patterns typical of LLM output. Rewrites text to sound natural, specific, and human. Uses 28 pattern detectors, 560+ AI vocabulary terms across 3 tiers, and statistical analysis (burstiness, type-token ratio, readability) for comprehensive detection. Use when asked to humanize text, de-AI writing, make content sound more natural/human, review writing for AI patterns, score text for AI detection, or improve AI-generated drafts. Covers content, language, style, communication, and filler categories.
generating-mermaid-diagrams
IncludedSalesforce architecture diagrams using Mermaid with ASCII fallback. Use this skill when generating text-based diagrams for Salesforce architecture, OAuth flows, ERDs, integration sequences, or Agentforce structure. TRIGGER when: user says "diagram", "visualize", "ERD", or asks for sequence diagrams, flowcharts, class diagrams, or architecture visualizations in Mermaid. DO NOT TRIGGER when: user wants PNG/SVG image output (use generating-visual-diagrams), or asks about non-Salesforce systems.