Ai llm patterns

From rnavarych/alpha-engineer · View interactive version

Ai llm patterns is an AI agent skill from the GitHub repository rnavarych/alpha-engineer. AI/LLM integration patterns: Anthropic SDK streaming with TypeScript, RAG architecture (chunking, embedding, vector search with pgvector), tool use / function calling, model selection guide (Haiku 4.5 vs Sonnet 5 vs Opus 4.8), prompt caching, structured output with Zod, token cost management. Use wh

How to use this skill

Skill file

AI/LLM Integration Patterns

When to Use This Skill

Core Principles

  1. Model selection matters for cost — Haiku is 10× cheaper than Sonnet; Sonnet is 5× cheaper than Opus; use the smallest model that can do the task
  2. Streaming for user experience — start showing text immediately; never make users wait for full response
  3. Tool use for deterministic operations — LLM decides what to do; your code does it safely; never trust LLM output directly for DB writes
  4. Prompt caching for repeated context — system prompts, documents, RAG context: cache if >1024 tokens
  5. RAG chunk size matters — too small (50 tokens) = no context; too large (2000 tokens) = irrelevant context dilutes relevance

References available

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.