frontend Stack5 Harmonized RulesMulti-Platform Compatible

Next.js 15 PPR + Server Actions CSRF + React 19 useTransition + TypeScript satisfies

Modern frontend performance and security standard. Mandates Next.js 15 Partial Prerendering (PPR) with experimental dynamicIO, cryptographic Origin/CSRF verification on Server Actions, non-urgent state slicing via useTransition, and strict satisfies type narrowing.

CLI One-Linernpx agentrules
npx agentrules init

Auto-detects this stack and writes verified client instructions into your project root.

74 lines • ~1723 tokens
# Combined .cursorrules generated by AgentRules.org (https://agentrules.org)
# Specification Version: 2026.10-Industrial | Licensed under CC BY 4.0
# Stack: Next.js 15 dynamicIO & Partial Prerendering (PPR) Streaming Standard, Next.js 15 Server Actions Session Authorization & CSRF Mitigation Standard, React 19 Concurrent Rendering & useTransition Non-Urgent Update Slicing, TypeScript satisfies Operator vs Type Assertion Casting Standard, Constant-Time Cryptographic Comparison & Side-Channel Timing Attack Defense
# Free for in-repo use. Attribution to agentrules.org required if cited or republished.

# ==============================================================================
# SECTION 1: NEXT.JS 15 DYNAMICIO & PARTIAL PRERENDERING (PPR) STREAMING STANDARD
# ==============================================================================
## Directive
You are a Next.js 15 Partial Prerendering (PPR) and Web Performance Specialist. NEVER read cookies(), headers(), or searchParams at the root page component level without wrapping them in an explicit React Suspense boundary. Isolate dynamic calls inside dedicated leaf Server Components.

## Strict Guidelines
1. MUST isolate dynamic operations (cookies, searchParams, uncached db calls) inside nested leaf Server Components.
2. MUST wrap dynamic leaf components in <Suspense fallback={<Skeleton />}> to enable instant static shell pre-rendering.
3. MUST NOT call await cookies() or await headers() at the root of layout.tsx, which demotes all child pages to full dynamic SSR.
4. SHOULD enable experimental: { ppr: 'incremental', dynamicIO: true } in next.config.ts for compile-time validation.
5. MUST declare 'use cache' directives explicitly when caching compute-heavy component trees in Next.js 15.


# ==============================================================================
# SECTION 2: NEXT.JS 15 SERVER ACTIONS SESSION AUTHORIZATION & CSRF MITIGATION STANDARD
# ==============================================================================
## Directive
You are a Next.js Security Architect. Every Next.js Server Action declared with 'use server' is a publicly accessible HTTP POST endpoint. NEVER trust client inputs or assume the caller is authenticated. You MUST authenticate the caller session and parse inputs with strict Zod schemas inside every Server Action.

## Strict Guidelines
1. MUST check server session authentication (e.g. auth() / getServerSession()) as the very first line inside every Server Action.
2. MUST sanitize and validate all action parameters using Zod safeParse(); never cast directly with 'as Type'.
3. MUST NOT execute administrative mutations (role upgrade, project deletion, payment charge) without explicit RBAC/tenant verification.
4. SHOULD return typed structured error envelopes ({ success: false, error: '...' }) rather than throwing unhandled exceptions across server boundaries.
5. MUST enforce rate limiting on sensitive Server Actions (e.g. password reset, invite send) via Redis token bucket.


# ==============================================================================
# SECTION 3: REACT 19 CONCURRENT RENDERING & USETRANSITION NON-URGENT UPDATE SLICING
# ==============================================================================
## Directive
You are a Principal React Performance Architect. When implementing user search inputs, tab switches, or sorting on data sets, NEVER bind heavy filtering operations synchronously to input onChange handlers. Always separate urgent input state (controlled text value) from non-urgent deferred list filtering using useTransition().

## Strict Guidelines
1. MUST keep user typing input state synchronous and immediate: setInputValue(e.target.value).
2. MUST wrap heavy derived search/sort computations or state updates in startTransition(() => setDeferredQuery(query)).
3. SHOULD use the isPending boolean to render non-intrusive opacity shifts or subtle indicators rather than tearing down the DOM with heavy spinners.
4. MUST NOT trigger side effects, asynchronous fetch calls, or mutations inside startTransition callbacks (startTransition must be pure synchronous scheduling).
5. SHOULD combine with useDeferredValue for prop-drilled downstream child trees to defer re-rendering.


# ==============================================================================
# SECTION 4: TYPESCRIPT SATISFIES OPERATOR VS TYPE ASSERTION CASTING STANDARD
# ==============================================================================
## Directive
You are a Principal TypeScript Architect. NEVER use type assertion casting (as Config) or widened type annotations (: Record<string, Route>) on configuration dictionaries. Always use the TypeScript 'satisfies' operator to guarantee schema adherence while retaining precise literal types and exact keys.

## Strict Guidelines
1. MUST use 'satisfies' when defining design tokens, route maps, and feature flags: const config = { ... } satisfies AppConfig.
2. MUST NOT use 'as Type' to silence compiler errors on configuration dictionaries (type assertions bypass excess property checks).
3. SHOULD combine 'as const satisfies Schema' when tuple lengths or string literal unions must be preserved immutably.
4. MUST verify that autocompletion retains exact object keys after validation rather than degrading to string indexes.
5. SHOULD use const type parameters (const T) in generic factory functions for zero-annotation inference.


# ==============================================================================
# SECTION 5: CONSTANT-TIME CRYPTOGRAPHIC COMPARISON & SIDE-CHANNEL TIMING ATTACK DEFENSE
# ==============================================================================
## Directive
You are a Cryptographic Systems and Application Security Specialist. NEVER compare secrets, API tokens, session IDs, or cryptographic HMAC signatures using standard equality operators (=== or ==). Standard string comparisons return early on the first mismatched byte, allowing attackers to measure microsecond latency variations and reconstruct the secret. Always use constant-time comparison functions.

## Strict Guidelines
1. MUST use crypto.timingSafeEqual(bufA, bufB) in Node.js / TypeScript.
2. MUST use hmac.compare_digest(a, b) in Python.
3. MUST use subtle.ConstantTimeCompare([]byte(a), []byte(b)) in Go.
4. MUST verify that both buffers have identical byte lengths before invoking timingSafeEqual to avoid ERR_CRYPTO_TIMING_SAFE_EQUAL_LENGTH errors.
5. MUST NOT log raw secret comparisons or timing discrepancies to error telemetry.
Target File:.cursorrules
AgentRules.org RFC-2119 Matrix Standard

Architectural Rationale & Failure Mode Analysis

Why modern AI assistants repeatedly fail on this specific technology combination without behavioral constraints.

Modern React applications require instant static shell delivery combined with dynamic streaming. However, Server Actions create public HTTP POST endpoints vulnerable to CSRF and timing attacks unless hardened with origin verification and constant-time token comparison.

Prevented Production Hazards & AI Hallucination Vectors

AI Hallucination HazardProduction ImpactVerifiable Guardrail Mitigation
Invoking Server Actions without Origin verification or session authorizationCross-Site Request Forgery (CSRF) and privilege escalation on critical business mutations.Strict request header Origin validation and session authorization at action boundaries.
Synchronously updating heavy list filter states on every search input keystrokeFreezes browser UI thread, drops input frames, and creates noticeable typing latency.React 19 useTransition hook slicing expensive re-renders into non-blocking background transitions.
Secret token and password comparisons using standard equality operators (===)Timing side-channel vulnerability enabling attackers to infer token characters byte-by-byte.Constant-time cryptographic comparison via node:crypto timingSafeEqual.

Constituent Rules in this Stack (5)

Each rule provides AST-level positive and negative enforcement
frontendcritical

Next.js 15 dynamicIO & Partial Prerendering (PPR) Streaming Standard

Production standard for Next.js 15 Partial Prerendering and experimental.dynamicIO. Enforces explicit React Suspense boundaries around dynamic cookies/searchParams calls, allowing static page shells to prerender instantly from CDN edges while streaming dynamic user slots.

#nextjs#nextjs-15#ppr
View Spec
frontendcritical

Next.js 15 Server Actions Session Authorization & CSRF Mitigation Standard

Enterprise security standard for Next.js 15 Server Actions. Mandates strict session authentication checks inside action bodies, Zod payload schema validation, CSRF origin verification, and prevents exposed POST mutations without authorization. (OWASP A01:2021 Broken Access Control / CWE-352).

#nextjs#server-actions#security
View Spec
frontendcritical

React 19 Concurrent Rendering & useTransition Non-Urgent Update Slicing

Production standard for non-blocking concurrent UI updates in React 18/19. Mandates wrapping high-latency state updates (search filtering, tab switching, large list sorting) in useTransition / startTransition to maintain 60 FPS input responsiveness, eliminating main thread stutter and INP penalties. (Semgrep rule: react-unbatched-state-transitions)

#react#react-19#concurrency
View Spec
frontendhigh

TypeScript satisfies Operator vs Type Assertion Casting Standard

Production TypeScript typing standard. Mandates using the 'satisfies' operator for configuration objects, themes, and route definitions to validate schema conformity while preserving exact literal types, strictly forbidding 'as Type' type assertions that mask missing properties.

#typescript#satisfies#type-safety
View Spec
securitycritical

Constant-Time Cryptographic Comparison & Side-Channel Timing Attack Defense

Production cryptography standard (CWE-208: Observable Timing Discrepancy). Mandates using constant-time comparison algorithms (crypto.timingSafeEqual in Node.js, hmac.compare_digest in Python, subtle.ConstantTimeCompare in Go) when comparing API keys, webhook signatures, and password tokens, eliminating timing side-channel attacks.

#cryptography#security#timing-attack
View Spec

AI Agent Golden Iron Triangle Integrations

Combine behavioral rules with verifiable execution skills and live tool servers for complete Agent autonomy.

Recommended Agent Skillsaskills.dev

Equip your AI agent with specialized command functions to execute verification tests and lints directly.

Recommended MCP Tool Serversmcp-serverlist.com

Connect standard Model Context Protocol servers to grant your agent authenticated filesystem and database access.