
Senior Ml Engineer
Integrate production LLM APIs with provider abstraction, prompt patterns, token and cost controls, and robust error handling.
Overview
Senior-ml-engineer is an agent skill most often used in Build (also Operate for cost and errors) that teaches production LLM API integration with abstraction, prompts, tokens, and cost control.
Install
npx skills add https://github.com/alirezarezvani/claude-skills --skill senior-ml-engineerWhat is this skill?
- Documents provider abstraction with abstract LLMProvider plus OpenAI and Anthropic concrete implementations
- Covers API integration patterns, prompt engineering, token optimization, and cost management sections
- Includes dedicated error-handling guidance for production LLM calls
- Table of contents structures five integration topics for incremental implementation
- Python-oriented examples using OpenAI and Anthropic SDK client patterns
- Guide table of contents lists 5 sections: API integration, prompt engineering, token optimization, cost management, erro
Adoption & trust: 770 installs on skills.sh; 17.5k GitHub stars; 3/3 security scanners passed (skills.sh audits).
What problem does it solve?
You are wiring LLMs into an app ad hoc with duplicated provider code, unpredictable token bills, and fragile error handling.
Who is it for?
Indie builders adding OpenAI or Anthropic (or similar) behind a Python service who want a structured integration checklist—not notebook experiments.
Skip if: Pure computer-vision training pipelines, teams needing only scikit-learn tabular models, or front-end-only apps with no server-side LLM calls.
When should I use this skill?
When integrating Large Language Models into applications and needing production API patterns, prompts, token/cost control, or error handling.
What do I get? / Deliverables
After applying the guide, you have a provider abstraction, clearer prompt and token strategies, and production-oriented error handling for chat and completion paths.
- Provider abstraction module pattern
- Production-oriented prompt and cost practices
- Error-handling strategy for LLM calls
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
LLM integration guides primarily land in build when wiring models into apps; production concerns extend into operate. Provider clients, chat/complete APIs, and abstraction layers are integration work—canonical shelf is build → integrations.
Where it fits
Implement LLMProvider with OpenAI and Anthropic clients behind one interface for your API.
Harden error handling and secret handling before exposing LLM routes to users.
Tune token limits and cost management after reviewing production completion volumes.
How it compares
Integration playbook for LLM APIs—not a hosted inference MCP and not a fine-tuning or dataset-labeling skill.
Common Questions / FAQ
Who is senior-ml-engineer for?
Solo developers and small teams building SaaS or agent products that call LLM APIs from application code, especially with Python backends.
When should I use senior-ml-engineer?
In Build when adding provider clients and abstraction; in Ship when hardening error paths; in Operate when optimizing token spend and monitoring failed completions.
Is senior-ml-engineer safe to install?
Review Prism Security Audits on this page; treat API keys as secrets and never paste production credentials into untrusted agent logs.
SKILL.md
READMESKILL.md - Senior Ml Engineer
# LLM Integration Guide Production patterns for integrating Large Language Models into applications. --- ## Table of Contents - [API Integration Patterns](#api-integration-patterns) - [Prompt Engineering](#prompt-engineering) - [Token Optimization](#token-optimization) - [Cost Management](#cost-management) - [Error Handling](#error-handling) --- ## API Integration Patterns ### Provider Abstraction Layer ```python from abc import ABC, abstractmethod from typing import List, Dict, Any class LLMProvider(ABC): """Abstract base class for LLM providers.""" @abstractmethod def complete(self, prompt: str, **kwargs) -> str: pass @abstractmethod def chat(self, messages: List[Dict], **kwargs) -> str: pass class OpenAIProvider(LLMProvider): def __init__(self, api_key: str, model: str = "gpt-4"): self.client = OpenAI(api_key=api_key) self.model = model def complete(self, prompt: str, **kwargs) -> str: response = self.client.completions.create( model=self.model, prompt=prompt, **kwargs ) return response.choices[0].text class AnthropicProvider(LLMProvider): def __init__(self, api_key: str, model: str = "claude-3-opus"): self.client = Anthropic(api_key=api_key) self.model = model def chat(self, messages: List[Dict], **kwargs) -> str: response = self.client.messages.create( model=self.model, messages=messages, **kwargs ) return response.content[0].text ``` ### Retry and Fallback Strategy ```python import time from tenacity import retry, stop_after_attempt, wait_exponential @retry( stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=1, max=10) ) def call_llm_with_retry(provider: LLMProvider, prompt: str) -> str: """Call LLM with exponential backoff retry.""" return provider.complete(prompt) def call_with_fallback( primary: LLMProvider, fallback: LLMProvider, prompt: str ) -> str: """Try primary provider, fall back on failure.""" try: return call_llm_with_retry(primary, prompt) except Exception as e: logger.warning(f"Primary provider failed: {e}, using fallback") return call_llm_with_retry(fallback, prompt) ``` --- ## Prompt Engineering ### Prompt Templates | Pattern | Use Case | Structure | |---------|----------|-----------| | Zero-shot | Simple tasks | Task description + input | | Few-shot | Complex tasks | Examples + task + input | | Chain-of-thought | Reasoning | "Think step by step" + task | | Role-based | Specialized output | System role + task | ### Few-Shot Template ```python FEW_SHOT_TEMPLATE = """ You are a sentiment classifier. Classify the sentiment as positive, negative, or neutral. Examples: Input: "This product is amazing, I love it!" Output: positive Input: "Terrible experience, waste of money." Output: negative Input: "The product arrived on time." Output: neutral Now classify: Input: "{user_input}" Output:""" def classify_sentiment(text: str, provider: LLMProvider) -> str: prompt = FEW_SHOT_TEMPLATE.format(user_input=text) response = provider.complete(prompt, max_tokens=10, temperature=0) return response.strip().lower() ``` ### System Prompts for Consistency ```python SYSTEM_PROMPT = """You are a helpful assistant that answers questions about our product. Guidelines: - Be concise and direct - Use bullet points for lists - If unsure, say "I don't have that information" - Never make up information - Keep responses under 200 words Product context: {product_context} """ def create_chat_messages(user_query: str, context: str) -> List[Dict]: return [ {"role": "system", "content": SYSTEM_PROMPT.format(product_context=context)}, {"role": "user", "content": user_query} ] ``` --- ## Token Optimization ### Token Counting ```python import tiktoken def count_tokens(text: str, model: str