AI Feature Integration
Installation
SKILL.md
AI Feature Integration
First question: does it need an LLM?
Use deterministic code when the task has a fixed rule set (pricing, routing, validation, search over structured fields). LLMs are for fuzzy language tasks, generation, extraction from messy text, and summarization. If a regex or SQL query solves it, use that.
Architecture
request -> validate input -> (retrieve context) -> prompt builder -> model
-> validate output -> guardrails -> response + trace
↘ fallback (cache / template / deterministic path)
- Structured output: JSON Schema / tool calling, then validate with Zod. Retry once with the validation error; never parse prose with regex.
- Streaming for anything >1s perceived; show progress and allow cancel.
- Caching: exact-match cache for repeated prompts; prompt-prefix caching where the provider supports it.
- Timeouts and budgets: hard timeout, max tokens, max tool calls, max cost per request. Fail closed for money/auth actions.
- Model choice by eval, not vibes: run the golden set against 2–3 candidates on quality, latency, and cost.