/engineering:ai-web-appsfrom engineering
Designs AI-enhanced web apps with chat, RAG, MCP tools, streaming, provider abstraction, token budgets, and output guardrails.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Prompts for AI web features must join the user journey to the model/system boundary: state the user outcome, context assembly and provenance, tenant and authority scope, tool permissions, output schema, loading/empty/error/refusal states, latency and cost budget, fallback, and acceptance evidence. For agentic features, separate inspect/plan from mutation, validate model output before rendering or acting, require approval for consequential side effects, and log the prompt/model/context/tool versions needed to reproduce a result. Test prompt revisions with representative, edge, adversarial, and accessibility cases; do not treat a good demo or a framework default as production evidence.
| Input | Required | Purpose |
|---|---|---|
| Domain evidence | yes | web runtime, AI user journeys, tenancy model, provider constraints, tool authority, budgets, and UI state requirements |
Default to read-only analysis. Read only scoped records; redact secrets and regulated data. Writes, execution, network calls, production configuration, customer communication, billing changes, and delegation require explicit authority and an identified owner. Never widen tenant, time-window, or system scope implicitly.
When required telemetry, evidence, execution, network access, or write authority is unavailable, return a partial result with each unassessed item labelled, preserve the safest existing state, and state the evidence or approval needed to continue. Never convert missing evidence into a pass.
| Condition | Action |
|---|---|
| Scope, owner, or threshold is missing | Stop the affected decision and request it |
| Evidence is incomplete but read-only analysis is safe | Produce a qualified partial result and gap list |
| A mutation exceeds authority or tenant boundary | Block it and route for approval |
| Evidence meets the stated threshold | Issue the output with provenance and owner |
Acknowledgement: Shared by Peter Bamuhigire, techguypeter.com, +256 784 464178.
ai-llm-integration or python-saas-integration instead.ai-ux-patterns or ai-agent-ux (chwezi-design-engine).ai-metering-billing or ai-saas-billing.ai-prompt-engineering, ai-security, or llm-security.SKILL.md, then load only the deep-dive references needed for the concrete task.maxTokens is set on every call; fallback is limited to transient provider errors.dangerouslySetInnerHTML or unsanitised Markdown.references/module-gate.md.references/token-ledger-and-budgets.md.references/provider-abstraction.md.references/output-guardrails.md.| Category | Artifact | Format | Example |
|---|---|---|---|
| Correctness | AI web app integration test plan | Markdown doc covering Next.js + Vercel AI SDK + MCP tool flow tests | docs/ai/web-app-tests.md |
| Security | AI web app security note | Markdown doc covering provider-key handling, prompt-injection defense, and per-tenant isolation | docs/ai/web-app-security.md |
References section below.This skill specialises the generic integration patterns in ai-architecture-patterns for a Next.js + Vercel AI SDK runtime. It is the AI-specialist seat in the architecture: it turns a feature concept plus upstream context/threat artifacts into four concrete deliverables the rest of the stack can depend on.
Skill-specific references:
references/module-gate.md — feature catalog, tenant flags, kill switch, audit, rollout choreography.references/token-ledger-and-budgets.md — ledger schema, budget guard, quota gate, cost estimation, join queries.references/provider-abstraction.md — factory, request schema, model selection table, fallback policy.references/output-guardrails.md — three-layer guardrails, tool-result validation, streaming validation, prompt-injection hooks.references/streaming-and-ui-patterns.md — streaming route, useChat, streamUI generators, multi-modal, middleware pipeline, light rate limits.references/mcp-integration.md — MCP server + client, authority tiers, lifecycle, observability.Source base: Despoudis, T. — Build AI-Enhanced Web Apps (Packt, 2024), adapted to the repository contract model.
Load the following before this skill, in order:
world-class-engineering — release gates and production bar.system-architecture-design — produces the context map and critical-flow table.database-design-engineering — produces the access-pattern list that shapes the ledger schema.vibe-security-skill — produces the threat model; ai-security and llm-security extend it for LLMs.| Artifact | Produced by | Required? | Why |
|---|---|---|---|
| Context map | system-architecture-design | required | names the module boundary the AI feature sits inside |
| Critical-flow table | system-architecture-design | required | sets latency + availability budget for the feature |
| Access-pattern list | database-design-engineering | required | shapes the ledger, quota, and corpus-retrieval queries |
| Threat model | vibe-security-skill / ai-security / llm-security | required | informs prompt-injection, PII, and abuse controls |
| Auth/authz matrix | vibe-security-skill | required | drives the role check inside the module gate |
| SLO set | observability-monitoring | optional | calibrates fallback thresholds and kill-switch triggers |
| Pricing / plan catalog | subscription-billing | optional | determines min_plan_tier in the feature catalog |
| Artifact | Consumed by | Template |
|---|---|---|
| Module gate contract | ai-saas-billing, platform admin UI, feature routes | references/module-gate.md |
| Token ledger + budget schema | ai-metering-billing, observability-monitoring, finance reporting | references/token-ledger-and-budgets.md |
| Provider abstraction contract | every AI route, ai-feature-spec, ai-evaluation | references/provider-abstraction.md |
| Output validation + guardrail rules | every AI route, ai-evaluation, ai-security | references/output-guardrails.md |
| Streaming + UI implementation notes | frontend integrators | references/streaming-and-ui-patterns.md |
| MCP server/client contract | internal tool owners, ai-agents-tools | references/mcp-integration.md |
Each of the four formal outputs has a template; other outputs are implementation references.
maxTokens; cost estimation uses maxTokens, not an optimistic expected completion.dangerouslySetInnerHTML is banned.NEXT_PUBLIC_* for an AI key is a release blocker.tools:Single app, single model, <5 tools -> inline tools in streamText
Reused across apps or across models -> MCP server (stdio transport)
Tools require out-of-process credentials -> MCP server, separate service account
Latency budget <150 ms per tool call -> inline; MCP handshake adds overhead
Wrong choice cost: inline-when-should-be-MCP means every app duplicates the tool surface; MCP-when-should-be-inline pays handshake latency for no composition benefit.
| Need | First choice | Fallback | Why not the other way |
|---|---|---|---|
| Latency-critical chat, short replies | Gemini Flash | GPT-3.5 | frontier model burns budget on a task that does not need it |
| High-quality reasoning, long tool chains | Claude Sonnet | GPT-4o | flash model hallucinates multi-step chains |
| Cheapest structured extraction | Gemini Flash | GPT-3.5 | frontier cost is a 10–30x multiplier with no quality gain |
Strict schema adherence (generateObject) | GPT-4o | Claude Sonnet (tool-call) | flash models drift from the schema under pressure |
| Residency / on-prem constraint | regional deployment | fail closed | cross-region fallback is a compliance breach |
Full selection table: references/provider-abstraction.md.
1. Module gate (entitlement + enablement + role + consent)
2. Quota gate (Redis counter, per user per feature per day)
3. Budget guard (ledger sum + estimated cost vs tenant cap)
4. Execute call (factory -> model with maxTokens)
5. Ledger write (onFinish, real tokens + real cost)
6. Guardrails (structural -> semantic -> render)
Skip step 1: free tenants consume paid features. Skip step 2: one user drains tenant cap. Skip step 3: fallback to cheaper model masks runaway spend. Skip step 5: cost attribution breaks; billing disputes become unresolvable. Skip step 6: XSS or bad-data writes reach production.
| Signal | Route (streaming) | Queue (background) |
|---|---|---|
| p95 total work | <25 s | >25 s |
| User must see partial output as it arrives | yes | no |
| Multi-step tool chain with web fetches | mixed | queue |
| Result is persisted regardless of UI | optional | queue |
| Retry on failure must be automatic | hard in route | natural in queue |
Wrong choice: running a 90-second multi-tool task in a route blows the 30 s Vercel function cap; running a fast chat through a queue destroys the streaming UX users expect.
Zod schema missing -> silent data corruption downstream
Business rule check missing -> valid-looking nonsense reaches users / DB
Markdown sanitiser missing -> XSS via model output
All three run; skipping any layer imports that layer's failure mode.
User (React UI)
|
v Server Actions / HTTP
Next.js App Router (middleware: CORS, IP rate limit, auth)
|
v
Module Gate -> Quota Gate -> Budget Guard
|
v Provider Factory (allow-listed)
Vercel AI SDK -----------------------> OpenAI / Gemini / Anthropic
| ^
v | ai-fallback on 429/5xx
MCP Client (optional) ----------------> MCP Server(s) -> internal APIs + vector stores
|
v Guardrails (structural, semantic, render)
Ledger Write (onFinish) -> Streaming response back to client
The four dashed boxes in this diagram correspond to the four formal outputs. Everything else is glue.
Write these down before touching code:
This is the ai-feature-spec deliverable. This skill consumes it.
Implement the module gate (references/module-gate.md) and the quota + budget pair (references/token-ledger-and-budgets.md) before writing the route. The route wires them together; it does not invent them.
Order in the route:
moduleGate -> quotaGate -> budgetGuard -> factory -> streamText -> guardrails -> ledgerWrite
All model access goes through the factory in references/provider-abstraction.md. Feature code never imports a provider SDK directly. This is how:
Streaming gives a great UX and a fragile validation point. Rules:
onFinish has validated the final object.onFinish with real usage; never use the estimate as the billed amount.Implementation: references/streaming-and-ui-patterns.md.
Structural (Zod on generateObject and tools), semantic (business rules, PII scrub, confidence thresholds), render (Markdown-only with a sanitiser). Full rules in references/output-guardrails.md.
Every call logs a single request_id that joins the prompt trace, tool calls, and the ledger row. Metrics at minimum:
ai.requests_total{feature, model, status}ai.tokens_total{feature, model, kind=prompt|completion}ai.cost_micros_total{tenant, feature}ai.guard_failures_total{guard, feature}ai.fallback_triggered_total{from_model, to_model}Alert on sustained fallback (>5% for 5 min), sustained guard failures (>1% for 10 min), and any tenant crossing 80% of monthly cap.
npm install ai @ai-sdk/openai @ai-sdk/google @ai-sdk/anthropic ai-fallback zod
npm install @modelcontextprotocol/sdk # if exposing or consuming MCP tools
npm install lru-cache # only for dev / single-instance rate limit
Production rate limits are Redis-backed (e.g. Upstash); the LRU snippet in references/streaming-and-ui-patterns.md is a dev fallback.
OPENAI_API_KEY directly in a route handler. Fix: all keys resolve inside lib/ai/factory.ts; feature code calls getSupportedModel(provider, model) only. A missing key becomes a typed error, not a runtime 500.tenant_ai_features.enabled, roleMayUseFeature, checkBudget. All three must pass; any one is sufficient to block.maxTokens pre-call for the budget guard; record the real usage in the ledger onFinish. Estimating with expected completion lets runaway responses blow through the cap.toDataStreamResponse() without maxTokens on streamText. Fix: maxTokens is always set; the budget guard uses the same value. Otherwise a jailbroken prompt can produce a 10 000-token reply on your dime.dangerouslySetInnerHTML for "formatting". Fix: render through react-markdown + rehype-sanitize, disable raw HTML, allow-list link protocols. Direct HTML injection is a live XSS vector.status: "confirmed".onFinish and on request abort; cache the tool list per worker. Otherwise stdio subprocesses accumulate and the worker OOMs.toISOString().slice(0, 10)). Local-date keys cause midnight races for users in other timezones and let them double their quota on travel days.untrusted in the system prompt, strip to text-only, and never let untrusted content trigger privileged tools in the same turn. See llm-security for the trust-tiering pattern.skill-composition-standards — the house style and contract gates this skill implements.ai-architecture-patterns — the generic integration patterns this skill specialises.ai-security — prompt-injection defence, PII handling, abuse controls.ai-evaluation — offline evals, regression tests, AI-as-judge for quality gates.ai-metering-billing — depth on ledger-to-invoice, unit economics, rev-share models.llm-security — OWASP Top 10 for LLMs, trust-tiering, instruction hierarchy.ai-feature-spec — how to write the feature contract this skill consumes.ai-ux-patterns — streaming UX, confidence indicators, progressive disclosure.nextjs-app-router — server/client components, middleware, RBAC three-tier.references/mcp-integration.md (opens in a new tab)references/module-gate.md (opens in a new tab)references/output-guardrails.md (opens in a new tab)references/provider-abstraction.md (opens in a new tab)references/streaming-and-ui-patterns.md (opens in a new tab)references/token-ledger-and-budgets.md (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
ai-web-apps, rag, streaming, guardrails, token-budget, mcp-tools
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions.Other plugins' skills for the same job