/ai-product-development
An AI feature with a typed server contract, every UI state, evals and cost controls.
Then type /ai-product-development in Claude Code, or describe the task and let it pick the skill.
What you get back recorded run · 9 Oct 2026
- Key stays on the server
- Notes are never logged
- Model output checked first
- I've added the quick-add box to the dashboard, but I couldn't test it against OpenAI. The
OPENAI_API_KEYin.env.localis a placeholder (sk-test-…, 28 characters), and OpenAI rejects it with a 401 even when called directly. - Names are matched against the group. Anyone who isn't a member is left out and listed in a warning.
- If the amount isn't written exactly that way in the note (for example "1.2k"), it warns you to double-check it.
- Confirmed expenses aren't saved. The app has no database, so Add expense only adds the row to the page, and it disappears on reload. There's a TODO where the save call should go.
Input → output from the run
export default function Dashboard() {
const total = expenses.reduce((s, e) => s + e.amount, 0);
return (
<main className="page">
<h1>Flat 4B — Indiranagar</h1>export function toDraft(raw, { text, members, currentMember, today }) {
const warnings = [];
let amount = typeof raw.amount === "number" && Number.isFinite(raw.amount) ? Math.round(raw.amount * 100) / 100 : null;
if (amount !== null && (amount <= 0 || amount > MAX_AMOUNT)) amount = null;
if (amount === null) warnings.push("Couldn't find an amount — please enter it.");
else if (!numbersInText(text).includes(amount)) warnings.push("Double-check the amount; it wasn't written exactly like that.");
let paidBy = matchMember(raw.payer, members);
if (!paidBy) {
paidBy = currentMember;
if (raw.payer) warnings.push(`"${raw.payer}" isn't in this group, so the payer defaulted to you.`);
}When to use it
Use when building AI into an app or auditing an AI feature before it ships.
Skip it for a repo-wide AI cost and margin audit; ai-cost-audit owns that.
The thinking behind itAn AI feature is a product, not a prompt. Typed contracts, every UI state, evals and cost limits mean it holds up when real users hit it.
Output contract from the skill's Output section
Report the chosen interaction and why, server/UI paths changed, state coverage, safety and permission boundaries, evaluation results, latency/cost observations, usage-settlement behavior, verification evidence, and remaining provider or production setup.
How it checks its own work from the instructions
- Mid-stream failure, cancellation, and timeout paths are tested
- Tool actions tested against prompt injection and cross-tenant IDs
- Execution-time authorization and usage settlement hold under concurrency
- Evaluation set runs alongside lint, type, test, and build
Requirements what it needs
- Works in
- Codex, Claude Code, Cursor
- Needs
- project files, terminal commands, network access
The instructions SKILL.md · 101 lines
Instructions & references
Back to overview ↑On this page 10 sections
AI product development
A model call that works in a demo fails in production in three places: a tool handler that trusts an earlier authorization check, usage charged after the fact under concurrency, and a model or prompt change shipped without an evaluation. Get those three right, then map every UI state to its failure and its charge. Input validation, secret handling and typed routes are assumed.
Choose a mode
- Build: add or change an AI feature. Apply every section that the feature touches.
- Audit: review an existing feature. Do not edit unless asked. Report findings ranked by severity, each with
file:line, the failure it allows, and the fix. - Model or prompt change: swap a model, edit instructions, change tools, retrieval, temperature or output limits. Run Evaluate before changing a model or prompt first. Use the
ai-cost-auditskill when the motive is cost.
A request that says "review", "check" or "is this safe" is Audit. A request to "add", "make", or "wire" is Build. Ask only when the request could be either and the answer decides whether files change.
Inspect first
Read before asking:
- the AI SDK and its installed major version (
package.jsonplus the lockfile), the providers, and every place a tool is defined or executed; - how the server identifies actor and tenant, and how that identity reaches a tool handler;
- the credit, quota or billing path, and whether requests can run concurrently or loop through tools;
- existing eval fixtures, golden outputs, prompt files and telemetry.
Ask only about choices that change the boundary: which tool actions need human approval, the charging policy for cancelled or failed work, and whether work must outlive the request (background job versus stream). Continue with labeled assumptions when the choice is reversible.
Authorize at tool execution time
Treat the tool name and arguments the model selects as untrusted input from the internet. Retrieved documents, emails and web pages can inject them. Authorizing the chat request does not authorize the action the model picks three steps later.
Inside every consequential tool handler (writes, sends, spends, deletes, grants access, or reads data outside the caller's own scope):
- Actor and tenant come from server-side context the model cannot see or write, never from tool arguments or prompt text. Pass identity through the SDK's server-only context or a closure. In AI SDK 7,
toolsContextandruntimeContextdo this (see the AI SDK reference). - Current resource state. Load the resource by ID scoped to that tenant. Re-check the policy against its state now, not its state when the conversation started: refundable amount, ownership, status, limits, time windows.
- Approval where the action is irreversible, financial, external or above a policy threshold. Bind the approval to the exact tool, normalized arguments and resource version. Expire it. One approval executes once. Re-check state between approval and execution.
- Idempotency around the external mutation. Derive the key from the tool call or approval ID. Send it to the provider when the provider supports idempotency keys. Otherwise record the intent under a unique constraint before calling out, and return the stored result on retry. Model retries, SDK retries and double-clicked approvals all replay tool calls.
- Minimal return. Return only what the next step needs. Tool output fed back to the model is also untrusted on the next turn.
- Audit record: actor, tenant, tool, argument hash, approval ID, idempotency key, outcome.
Read-only tools still scope every query by tenant. A tool that takes a raw resource ID with no tenant filter is a cross-tenant read.
Stop for the user's decision before letting a model trigger refunds, payments, deletions, outbound messages to third parties, or permission changes without a human approval step.
Reserve, then settle usage
When usage costs money or credits and requests can overlap or loop, a balance check followed by a deduction afterwards lets parallel requests each pass the check and overspend. Use reservation and settlement instead:
- Cap first. Bound steps, output tokens, tool calls and per-tool paid API cost. Without caps the worst case is unbounded and no reservation is safe.
- Reserve the capped worst case atomically before the first model call, keyed by an idempotency key from the client or request.
- Settle on actual usage across all steps plus paid tool calls. SDKs differ on whether
usagemeans the last step or the whole run. Check the installed major before reading it (the AI SDK changed this in v7). - Release the unused remainder. On failure, apply the stated policy for partial work.
- Abort and disconnect are not completion. Settle from the steps that completed plus a stated policy for the step in flight. Settlement runs on the server even when the client is gone.
- Recover. SDK callbacks can fire twice or not at all. Persist the reservation, make settlement idempotent by reservation ID, and sweep reservations that stay open past a timeout.
Use the credit-metering skill for the ledger, schema, purchases and provider webhooks. This section decides where reserve and settle sit in the AI request path.
Evaluate before changing a model or prompt
Never judge a model or prompt change on a few manual tries. Before the change ships:
- Build or reuse a set of representative cases (sampled from real traffic with personal data removed, or realistic stand-ins) and adversarial cases: prompt injection inside retrieved content, cross-tenant IDs in arguments, oversized and empty input, ambiguous requests, inputs that should be refused. With no existing set, start with about 20 representative and 10 adversarial cases. That is a working floor, not a statistical guarantee. Record the count.
- Score deterministic checks first: schema validity, correct tool and arguments, refusal when expected, citations that resolve, latency, cost per case.
- For subjective output (tone, helpfulness, summary quality), keep a held-out set the prompt author never tuned against. Before trusting an LLM judge, run it on examples a human labeled good and bad, and check that it ranks them correctly. Pin the judge model and judge prompt. Report disagreement instead of averaging it away. When taste decides quality (posts, captions, copy), use the
taste-evalsskill for the full method: blind pairwise comparison, judge calibration on real hits and flops, and a pre-registered decision rule. - Run baseline and candidate on the same set. Repeat nondeterministic cases. Ship only with no regression on must-pass cases, then canary with a rollback path.
If the user wants the change now and no set exists, build the minimal set first and say what it cannot detect.
UI state and failure matrix
Model the states the chosen interaction actually has: initial, submitted with no token yet, streaming, tool running, awaiting approval, partial, stopped by the user, refused, rate limited or out of credits, failed mid-stream, complete. For each failure, decide all three columns together:
| Failure | Server behavior | User sees | Charge |
|---|---|---|---|
| Slow first token | Keep the request alive within the timeout | Submitted state, Stop available | Reservation held |
| Mid-stream provider error | Stop, persist the partial result if useful | Partial text marked incomplete, Retry | Settle per partial-work policy |
| User presses Stop | Abort upstream | Partial text kept, Regenerate | Completed steps only |
| Client disconnects | Abort or finish deliberately, never by accident | Restored state on return if persisted | Settled server-side |
| Tool awaiting approval | Hold; no mutation | Exact action and arguments to approve | Nothing for the action yet |
| Tool rejected by authorization | Return a refusal to the model, log it | Plain explanation, no internal detail | Model usage only |
| Out of credits or rate limited | Reject before the model call | Balance or retry time, a next step | Nothing |
| Duplicate submit | Return the original via idempotency key | One answer | Once |
Vercel AI SDK
Detect the installed ai and @ai-sdk/react majors first. For API shapes, use Vercel's official ai-sdk agent skill when installed, or the docs for that major. Read the AI SDK reference for the version traps that break billing and validation, the abort behavior, and the caps. For other SDKs, apply the same rules and check that SDK's usage semantics for multi-step runs.
Verification
- Build: test the happy path, then each row of the failure matrix. For tools, test a prompt-injected argument, a cross-tenant resource ID, a state change between proposal and execution, a replayed approval, a provider retry, and a policy-limit breach. Fire concurrent requests against one balance and assert it never goes below the policy floor. Abort mid-run and confirm settlement reflects completed steps. Run the repository's lint, type, test and build commands.
- Audit: cite the line for each finding. Mark a finding confirmed only after reproducing it or tracing the full path. Otherwise label it suspected.
- Model or prompt change: show baseline and candidate scores on the same set, the judge calibration result for subjective cases, and the rollback path.
Output
- Build: chosen interaction and why, files changed, tool authorization per consequential tool, reservation and settlement behavior, state coverage, verification evidence, remaining provider or production setup.
- Audit: findings ranked by severity with
file:line, failure, fix, and confirmed or suspected. - Model or prompt change: eval set size and composition, scores before and after, regressions, judge calibration, ship or hold recommendation.
Vercel AI SDK: version traps for billing, validation and aborts
Read this when the project uses the Vercel AI SDK (ai). It holds only rules that change behavior and that the SDK's own docs do not flag as billing or security risks. It is not an API reference.
Facts below were checked on 2026-11-04 against AI SDK 7 (ai 7.0.162 on npm). Before acting on one, re-check the source if that date is more than about 90 days old or the installed major is not 5, 6 or 7.
Contents
- Route API shapes
- Usage semantics by major
- Other v7 renames that touch this skill
- Validate client messages
- Abort and disconnect
- Caps
- Identity in tool handlers
- Verification
- Sources checked 2026-11-04
Route API shapes
- Read the installed major from the lockfile or
npm ls ai @ai-sdk/react. Do not infer it frompackage.jsonranges alone. - For route handlers,
useChat, transports, message parts and tool definitions, use Vercel's officialai-sdkagent skill when installed (npx skills add vercel/ai). Otherwise read the docs for the installed major. Do not copy examples from a different major. - For a v6 to v7 upgrade, use the
migrate-ai-sdk-v6-to-v7skill from the same repository or the v7 migration guide and its codemods (npx @ai-sdk/codemod v7). Finish the migration. An import-only change leaves deprecated behavior in place.
v7 is ESM-only and requires Node.js 22 or later. A CommonJS project or an older Node runtime cannot take the upgrade without those changes first.
Usage semantics by major
The billing trap: the meaning of usage flipped in v7.
| What you need | v5 and v6 | v7 |
|---|---|---|
| Tokens across all steps (bill on this) | totalUsage |
usage (totalUsage is a deprecated alias) |
| Tokens for the last step only | usage |
finalStep.usage |
| Cache-read and reasoning tokens | top-level cachedInputTokens, reasoningTokens (deprecated in v6) |
inputTokenDetails.cacheReadTokens, outputTokenDetails.reasoningTokens (top-level fields removed) |
| Tool calls, sources, files across steps | per-step arrays; top-level holds the last step | top-level accumulates all steps; finalStep.* holds the last |
Rules:
- On v5 or v6, settling credits on
usageunder-bills every multi-step tool run. Settle ontotalUsage. - After a v6 to v7 upgrade, code that charged per tool call by iterating the top-level
toolCallsnow sees every step, not one. Re-check any count-based charge. - Price cache reads and reasoning tokens from the detail fields of the installed major. Missing fields read as
undefined, which silently becomes zero in arithmetic.
Other v7 renames that touch this skill
| v5 and v6 | v7 | Note |
|---|---|---|
onFinish |
onEnd |
onFinish is a deprecated alias. If both are set, onEnd takes precedence. |
onStepFinish |
onStepEnd |
Deprecated alias kept. |
system |
instructions |
Codemod: v7/rename-system-to-instructions. |
stepCountIs(n) |
isStepCount(n) |
Used in stopWhen. |
result.toUIMessageStreamResponse() |
createUIMessageStreamResponse({ stream: toUIMessageStream({ stream: result.stream }) }) |
Result methods (toUIMessageStreamResponse, pipeUIMessageStreamToResponse, toTextStreamResponse, pipeTextStreamToResponse, toUIMessageStream) still work in v7 with warnings and are removed in the next major. |
result.fullStream |
result.stream |
Codemod: rename-full-stream-to-stream. |
During a half-finished migration, do not split settlement across onFinish and onEnd. Keep it in one callback.
Validate client messages
z.array(z.custom<UIMessage>())validates nothing.z.customwith no predicate accepts any value.- Use
validateUIMessages(throws) orsafeValidateUIMessages(returns a result) fromai. Pass the sametools,dataSchemasandmetadataSchemathe route uses, so tool parts and custom parts are checked against real schemas. Confirm the installed major exports them. - Shape validation does not make client history trustworthy. A client can send forged assistant messages, tool outputs or approval parts. When chats are persisted, load history from the server store by chat ID and accept only the new user message from the client.
- Cap message count and total size before validation work.
Abort and disconnect
On v7 streamText (checked 2026-11-04):
- When
abortSignalfires during streaming, pending result promises such astextandstepsreject with the abort reason. They do not wait foronAbort. onAbortreceivessteps: the steps that finished before the abort. Usage for the step in flight is not in it.- Settle aborted runs inside
onAbortfrom the completed steps, plus your stated policy for the in-flight step (charge the reserved estimate, charge nothing, or reconcile later from provider usage reports). Do not assumeonEndruns for an aborted run. The docs route aborts toonAbort. finishReasonincludesinterruptedanderror. Map each to a settlement rule.- Whether a browser disconnect reaches
req.signaldepends on the runtime and host. Observe it in server logs on the deployed target. If the product keeps generating after disconnect (to persist the answer), settlement must still run.
Caps
streamTextstops after one step unlessstopWhenallows more (v7 defaultisStepCount(1)). Every multi-step loop needs an explicit step cap.- Set
maxOutputTokens. The v7timeoutoption acceptstotalMs,stepMs,firstChunkMs,chunkMs,toolMsand per-tool limits. Confirm the installed major supports it before relying on it. - The reservation equals the cost of these caps at worst case. Raising a cap without raising the reservation reopens overspend.
Identity in tool handlers
v7 adds runtimeContext (shared server-side state through the loop) and toolsContext (per-tool typed context declared with contextSchema). Pass actor, tenant and scoped permissions there, not in tool input. On earlier majors, close over server-derived identity when constructing the tools for each request. Either way, the handler still re-checks resource state and policy at execution time.
Verification
- A two-step tool run settles on the all-steps total, checked against provider usage logs.
- An aborted run settles from completed steps, and the in-flight step follows the stated policy.
- A forged assistant or tool part in the request body is rejected or ignored.
onFinishandonEndare not both registered for settlement.- No deprecated helper remains in new code on v7. Run the repository's lint, type, test and build commands.
Sources checked 2026-11-04
- https://ai-sdk.dev/docs/migration-guides/migration-guide-7-0 (Node 22, ESM-only,
onEnd,instructions,isStepCount, stream helpers, multi-step result shape, usage fields, codemods, migration skill) - https://ai-sdk.dev/docs/reference/ai-sdk-core/stream-text (
abortSignal,onAbort,onEnd,finishReason,stopWhendefault,timeout,toolsContext) - https://ai-sdk.dev/docs/reference/ai-sdk-core/validate-ui-messages (
validateUIMessages,safeValidateUIMessages) - https://ai-sdk.dev/docs/agents/overview (
runtimeContext,toolsContext) - https://skills.sh/vercel/ai (
ai-sdkandmigrate-ai-sdk-v6-to-v7skills) - npm registry,
npm view ai version(7.0.162)
Put this skill to work
Learn a workflow. Take the skill with you.
Build an image-editing skill with GPT Image 2.5
Turn reference images, successive edits, and visual checks into a reusable skill. Includes the package and an edit record.
Test an MCP event workflow before connecting ChatGPT
Build a local task-to-draft fixture and check signed callbacks, duplicate delivery, retries, restart, and revoked access.
Claude app, ChatGPT and ZIP download
local coding agent required
This skill requires project files, terminal commands, and network access. Uploading it to a chat app does not provide equivalent execution.
ChatGPT Skills
This workflow needs a local coding environment or capabilities that a chat-only Skills upload does not provide.
Package details
- Package
- ai-product-development/SKILL.md
- Author
- @tushaarmehtaa
- Added
- 7 Aug 2026
- Tags