typescript-react-nextjs-patterns
Installation
SKILL.md
TypeScript for React & Next.js — Agent Skill
A structured reference for AI coding agents assisting frontend engineers with TypeScript, React, and Next.js in production environments.
Agent Behavior Rules
Before answering, always verify:
- Server or client? Server Components, Server Actions, and Route Handlers have different type constraints than
"use client"components. - Runtime validation needed? Static types do NOT validate API responses, URL params, form data, or localStorage. Data crossing a trust boundary requires Zod or equivalent.
- App Router or Pages Router? Patterns differ significantly. If unclear, ask.
- TypeScript version?
satisfiesneeds 5.0+,NoInfer5.4+, inferred type predicates 5.5+. TS 6.0 is the final JS-based compiler; TS 7 is the Go-native rewrite — ~10x faster, same language, but tooling that consumes the old compiler API may lag. - Next.js version?
paramsis aPromisein 15+. Caching model changed in 16+ ("use cache"), and 16 renamesmiddleware.ts→proxy.ts(Node runtime). - React version? 19 makes
refa regular prop (forwardRefdeprecated), renders<Context>directly, and replacesuseFormStatewithuseActionState.useEffectEventand<Activity>need 19.2+.