Skip to content
Back to skills

Ai Integration

ASecurity

Use when writing, reviewing, or refactoring code that calls an LLM — the Vercel AI SDK, an AI gateway, OpenAI, Anthropic, or Google SDKs, LangChain, Mastra, or similar — or when adding or swapping a model, adopting a newly released model, adding tools or agents, structured output, or streaming chat, or when AI costs, timeouts, or provider outages are a problem. Keeps model choice in one place so a model swap is a config change. Not for prompt writing or choosing which model is best.

  • 8 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 5, 2026
ai-agentspythongorefactoringapisecurity

Works with

  • api

Security analysis

A100/100

Pro scans all 9 files and shows the line behind each finding

Scanned December 5, 2026

npx -y skills add tartinerlabs/skills --skill ai-integration --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Ai Integration?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Ai Integration
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/tartinerlabs-ai-integration/badge)](https://www.skillsdirectory.com/skills/tartinerlabs-ai-integration)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: ai-integration
description: Use when writing, reviewing, or refactoring code that calls an LLM — the Vercel AI SDK, an AI gateway, OpenAI, Anthropic, or Google SDKs, LangChain, Mastra, or similar — or when adding or swapping a model, adopting a newly released model, adding tools or agents, structured output, or streaming chat, or when AI costs, timeouts, or provider outages are a problem. Keeps model choice in one place so a model swap is a config change. Not for prompt writing or choosing which model is best.
license: MIT
allowed-tools: Read Glob Grep Edit Write
compatibility: Any project that calls an LLM; JS/TS and the Vercel AI SDK first-class, other libraries and languages by their equivalents
metadata:
  short-description: Review and build LLM code that swaps models easily.
  title: Build AI features that can switch models
  goal: ship-code-safely
  audience: developers, founders, team-leads
---

You make LLM code that outlives the model it was written for. New models ship every few weeks; adopting one should be a change to one config value plus an eval run, never a hunt through call sites. The worked example is the Vercel AI SDK routed through Vercel AI Gateway, where a model is a plain `"provider/model"` string; the rules apply to any library.

## 1. Pick the Mode

Decide from the request; do not ask.

- **Build mode** — the task adds or changes AI code. Apply the rules as constraints while writing it. Mention a rule only when it changed a decision, in one line.
- **Review mode** — the user asks to review, audit, or tidy AI code, or to make models easier to swap. Work through Step 4.

## 2. Detect the Library

Read the manifest as prose (`package.json`, `pyproject.toml`, `go.mod`, …) and keep the library the project already uses; these rules say what to check, not which library to switch to.

| Library | Detected by | Load |
|---|---|---|
| **Vercel AI SDK** (any provider, AI Gateway) | `ai`, `@ai-sdk/*` | [references/ai-sdk.md](references/ai-sdk.md) |

For anything else (`openai`, `@anthropic-ai/sdk`, `@google/genai`, LangChain, Mastra, the Python SDKs), apply the rules with that library's equivalents: its model parameter, its schema-validated output helper, its tool definition, and its abort and token-limit options. A gateway with an OpenAI-compatible endpoint gives these libraries the same one-string model swap.

**Never write a model ID from memory.** Models are released and retired too often. Read the current list from the gateway or provider (for AI Gateway, `https://ai-gateway.vercel.sh/v1/models`) or ask the user, and check the installed library's own docs before relying on an API you remember.

## 3. Rules

| Rule | Impact | Applies to | File |
|---|---|---|---|
| One model registry | CRITICAL | every model ID in the codebase | [rules/model-registry.md](rules/model-registry.md) |
| Tool and agent safety | CRITICAL | tools, agents, model output that drives actions | [rules/tool-safety.md](rules/tool-safety.md) |
| Provider-agnostic routing | HIGH | provider packages, credentials, fallbacks, provider options | [rules/provider-routing.md](rules/provider-routing.md) |
| Validated structured output | HIGH | any output parsed into data | [rules/structured-output.md](rules/structured-output.md) |
| Limits and cost | HIGH | token caps, step caps, timeouts, per-user limits, usage logging | [rules/limits-and-cost.md](rules/limits-and-cost.md) |
| Streaming | MEDIUM | user-facing generations | [rules/streaming.md](rules/streaming.md) |
| Tests and evals for swaps | MEDIUM | tests of AI code, adopting a new model | [rules/model-swap-evals.md](rules/model-swap-evals.md) |

## 4. Review Mode

1. **Inventory** — every call site that names a model, every provider package and API key, every tool, and every place model output is parsed or acted on. Report the counts before editing
2. **Fix in impact order** — CRITICAL first. Change only what the rule needs; keep prompts, behaviour, and the current models unless the user asks to change them
3. **Centralise models** — move model IDs into the registry from [rules/model-registry.md](rules/model-registry.md), keeping the same models, so the swap itself is a separate, reviewable change
4. **Test** — run the project's build and tests, or ask the user to, and report real results. Do not make paid live model calls unless the user asks

End with what changed, the one place to edit to swap a model, and anything left provider-specific and why.

## Boundaries

- **Prompt wording** and **which model is best** for a task are the user's call; this skill makes them cheap to change.
- **Secrets** found in code are reported, never printed; rotating them belongs to `security`.
- **Durable agents and workflows** (long-running, resumable runs) follow their framework's docs; these rules still apply to each model call inside them.

Files in this skill

  • SKILL.md4.8 KB
  • references/ai-sdk.md3.3 KB
  • rules/limits-and-cost.md2.4 KB
  • rules/model-registry.md3.2 KB
  • rules/model-swap-evals.md2.2 KB
  • rules/provider-routing.md2.5 KB
  • rules/streaming.md2 KB
  • rules/structured-output.md2 KB
  • rules/tool-safety.md2.5 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in ai-agents →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.