skills/ai-integration/SKILL.md
ALWAYS trigger for ANY task involving AI integration, OpenAI API, Anthropic API, Claude API, GPT, embeddings, RAG (Retrieval Augmented Generation), vector databases, LangChain, AI SDK (Vercel), text generation, chat completions, streaming responses, prompt engineering, function calling, tool use, AI agents, semantic search, Pinecone, ChromaDB, pgvector, or any LLM-related development task.
npx skillsauth add thesaifalitai/claude-setup ai-integrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
You are a senior AI engineer who integrates LLMs into production applications. You build reliable AI features with proper streaming, error handling, caching, and cost management.
npm install ai @ai-sdk/anthropic @ai-sdk/openai
// app/api/chat/route.ts — Streaming chat with Claude
import { anthropic } from '@ai-sdk/anthropic';
import { streamText } from 'ai';
export async function POST(req: Request) {
const { messages } = await req.json();
const result = streamText({
model: anthropic('claude-sonnet-4-20250514'),
system: 'You are a helpful coding assistant. Be concise.',
messages,
maxTokens: 4096,
});
return result.toDataStreamResponse();
}
// components/Chat.tsx — Client component
'use client';
import { useChat } from 'ai/react';
export function Chat() {
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({
api: '/api/chat',
});
return (
<div>
{messages.map((m) => (
<div key={m.id} className={m.role === 'user' ? 'text-right' : 'text-left'}>
<p>{m.content}</p>
</div>
))}
<form onSubmit={handleSubmit}>
<input value={input} onChange={handleInputChange} disabled={isLoading} />
</form>
</div>
);
}
// lib/anthropic.ts
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
// Simple completion
export async function generateText(prompt: string): Promise<string> {
const message = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
messages: [{ role: 'user', content: prompt }],
});
return message.content[0].type === 'text' ? message.content[0].text : '';
}
// Streaming
export async function streamText(prompt: string) {
return client.messages.stream({
model: 'claude-sonnet-4-20250514',
max_tokens: 4096,
messages: [{ role: 'user', content: prompt }],
});
}
// Tool Use (Structured Output)
export async function extractData(text: string) {
const response = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 1024,
tools: [{
name: 'extract_contact',
description: 'Extract contact information from text',
input_schema: {
type: 'object' as const,
properties: {
name: { type: 'string', description: 'Full name' },
email: { type: 'string', description: 'Email address' },
phone: { type: 'string', description: 'Phone number' },
company: { type: 'string', description: 'Company name' },
},
required: ['name'],
},
}],
messages: [{ role: 'user', content: `Extract contact info: ${text}` }],
});
const toolBlock = response.content.find((b) => b.type === 'tool_use');
return toolBlock?.type === 'tool_use' ? toolBlock.input : null;
}
// lib/rag.ts — Using pgvector with Prisma
import { db } from '@/lib/db';
import { generateEmbedding } from './embeddings';
// Store document with embedding
export async function indexDocument(content: string, metadata: Record<string, string>) {
const embedding = await generateEmbedding(content);
await db.$executeRaw`
INSERT INTO documents (content, metadata, embedding)
VALUES (${content}, ${JSON.stringify(metadata)}::jsonb, ${embedding}::vector)
`;
}
// Semantic search
export async function searchDocuments(query: string, limit: number = 5) {
const queryEmbedding = await generateEmbedding(query);
const results = await db.$queryRaw`
SELECT content, metadata,
1 - (embedding <=> ${queryEmbedding}::vector) as similarity
FROM documents
WHERE 1 - (embedding <=> ${queryEmbedding}::vector) > 0.7
ORDER BY embedding <=> ${queryEmbedding}::vector
LIMIT ${limit}
`;
return results;
}
// RAG chat
export async function ragChat(question: string) {
const context = await searchDocuments(question, 3);
const contextText = context.map((d: { content: string }) => d.content).join('\n\n');
const response = await client.messages.create({
model: 'claude-sonnet-4-20250514',
max_tokens: 2048,
system: `Answer based on this context. If the context doesn't contain the answer, say so.\n\nContext:\n${contextText}`,
messages: [{ role: 'user', content: question }],
});
return {
answer: response.content[0].type === 'text' ? response.content[0].text : '',
sources: context,
tokensUsed: response.usage,
};
}
// lib/embeddings.ts
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
// Use Voyage AI (Anthropic's recommended embedding model)
export async function generateEmbedding(text: string): Promise<number[]> {
const response = await fetch('https://api.voyageai.com/v1/embeddings', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.VOYAGE_API_KEY}`,
},
body: JSON.stringify({
input: text,
model: 'voyage-3',
}),
});
const data = await response.json();
return data.data[0].embedding;
}
// middleware/ai-cost-tracker.ts
interface TokenUsage {
inputTokens: number;
outputTokens: number;
model: string;
costUsd: number;
}
const MODEL_PRICING: Record<string, { input: number; output: number }> = {
'claude-opus-4-20250514': { input: 15.0, output: 75.0 },
'claude-sonnet-4-20250514': { input: 3.0, output: 15.0 },
'claude-haiku-4-5-20251001': { input: 0.80, output: 4.0 },
};
export function calculateCost(usage: { input_tokens: number; output_tokens: number }, model: string): number {
const pricing = MODEL_PRICING[model] ?? MODEL_PRICING['claude-sonnet-4-20250514'];
return (usage.input_tokens / 1_000_000 * pricing.input) + (usage.output_tokens / 1_000_000 * pricing.output);
}
development
Use when building Vue 3 applications with Composition API, Nuxt 3, or Quasar. Invoke for Pinia, TypeScript, PWA, Capacitor mobile apps, Vite configuration.
tools
Expert Upwork freelancer skill for writing winning proposals, client communication, and project management. ALWAYS trigger for ANY task involving Upwork job proposals, bid writing, client messages, project scoping, milestone planning, contract setup, client onboarding, status updates, project handoffs, portfolio descriptions, rate negotiation, handling difficult clients, raising rates, dispute resolution, or review requests. Also triggers for: "write a proposal", "reply to client", "Upwork bid", "freelance proposal", "client message", "project quote", "scope of work", "follow up with client", "client is ghosting", "request review", "upwork job".
development
UI component code implementation specialist. Trigger when WRITING or FIXING UI code — Tailwind CSS utilities, shadcn/ui components, Radix UI primitives, CVA component variants, Framer Motion animations, CSS variables for dark mode, WCAG accessibility code (ARIA labels, focus management, keyboard navigation), responsive layouts, skeleton loaders, empty states, Storybook stories, Figma-to-code. Also triggers for: fix this component, add dark mode, make this accessible, write a Button component, style this form, add animations, fix layout shift. For design PLANNING (choosing colors, styles, font pairings for a new project) use ui-ux-pro-max instead.
development
Design PLANNING and DISCOVERY specialist — use before writing any code. Invoke when CHOOSING a design direction: pick a visual style (glassmorphism, brutalism, minimalism, claymorphism, neumorphism, bento grid, skeuomorphism), generate a color palette, select font pairings, plan a design system, choose chart styles, or define the look-and-feel for a new project. Triggers: 'what style should I use', 'suggest a color palette', 'recommend fonts for my app', 'design system for a SaaS', 'what UI style fits a fintech app', 'generate a design brief', 'choose between dark/light theme', 'plan the visual identity'. Covers 50 styles, 97 palettes, 57 font pairings across React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui stacks. For WRITING or FIXING actual UI code (components, Tailwind classes, animations) use uiux-design instead.