ai-ml-integration-patterns

ai-ml-integration-patterns is a skill for Claude Code, Codex from mickeyyaya/refactoring-skills. It costs 66 tokens per session (5,478 once invoked), scanned A, original, MIT.

A guide to adding AI and machine-learning features to software, including document-based question answering, prompts, structured responses, tool calls, and handling model errors.

In plain words
What is it for?
Designing or reviewing code that calls language-model APIs, builds retrieval-augmented generation systems, validates model output, or runs AI-selected tools.
Why use it?
AI services can invent information, exceed token budgets, accept unsafe instructions, or return data that has not been checked before use.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Designing or reviewing code that calls language-model APIs, builds retrieval-augmented generation systems, validates model output, or runs AI-selected tools.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add mickeyyaya/refactoring-skills --skill ai-ml-integration-patterns
Clone the repo
git clone --depth 1 https://github.com/mickeyyaya/refactoring-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ai-ml-integration-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns/github.svg)](https://agentmods.dev/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns)
Your own site
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for ai-ml-integration-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns"><img src="https://agentmods.dev/badge/skills/mickeyyaya/refactoring-skills/ai-ml-integration-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 66 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 5,478 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00066 $0.05478
Opus 5 $0.00033 $0.02739
Sonnet 5 $0.00013 $0.01096
Haiku 4.5 $0.00007 $0.00548

Measured 10d ago against content hash 6706779819f8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-10, from the pricing page.

Security

Grade A, and why

ai-ml-integration-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 10d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/ai-ml-integration-patterns/SKILL.md · 561 lines

How it starts

The opening of the file, as written. The whole thing — 561 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI/ML Integration Patterns

Overview

Integrating LLMs into production systems introduces failure modes unique to probabilistic outputs: hallucinated facts, unbounded token costs, prompt injection attacks, and unvalidated structured responses. Use this guide when designing, building, or reviewing code that calls LLM APIs, builds RAG pipelines, or orchestrates AI agents.

When to use: Reviewing code that calls OpenAI, Anthropic, or other LLM APIs; evaluating RAG pipeline design; auditing prompt construction; any system that relies on LLM-generated structured output or tool execution loops.

Quick Reference

Pattern Core Idea Primary Red Flag
RAG Pipeline Ground LLM answers in retrieved documents Retrieval without relevance filtering; missing context window budget
Prompt Engineering Structured prompts for reliable, reproducible outputs Hardcoded prompts scattered in code; no version control
Structured Output + Schema Validate LLM JSON against a schema before using it Trusting raw LLM output as typed data
Tool Use / Function Calling LLM selects and invokes registered tools; app executes Executing tool calls without validating arguments
LLM Error Handling Retry rate limits, fall back on model failures, timeout on hangs No retry on 429; no timeout on streaming calls
Token Budget Management Count, chunk, and truncate to stay within context limits Unlimited context assembly; no chunk size cap
Hallucination Mitigation Source citation, confidence scoring, guardrails LLM answers used directly with no grounding check
Anti-Patterns Common misuse patterns that cause prod failures Prompt injection via user input; no output validation

Patterns in Detail

1. RAG (Retrieval-Augmented Generation) Pipeline

RAG grounds LLM responses in real data by retrieving relevant documents at query time and injecting them into the context window.

Pipeline stages:

  1. Embedding — convert documents and queries to dense vectors
  2. Vector store — index and persist embeddings for ANN search
  3. Retrieval — query vector store with top-k similarity
  4. Reranking (optional) — re-score candidates with a cross-encoder
  5. Context window management — pack retrieved chunks within token budget
  6. Generation — LLM answers using grounded context

Read the full file on GitHub · 561 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 10d ago First seen · 561 lines · 66 tokens per session scan A 6706779819f8

Subscribe to this mod's changes

ai-ml-integration-patterns is a skill published in the GitHub repository mickeyyaya/refactoring-skills (6 stars, last pushed 5mo ago), licensed MIT. It adds 66 tokens to every session and 5,478 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.