React Native + Expo SDK 52 + Expo Router + Zod
Architectural rules for React Native and Expo SDK 52. Guards native bridge performance, enforces Expo Router typed routes, and prevents plain-text storage of API keys on mobile clients.
Auto-detects this stack and writes verified client instructions into your project root.
# Combined .cursorrules generated by AgentRules.org (https://agentrules.org)
# Specification Version: 2026.10-Industrial | Licensed under CC BY 4.0
# Stack: React Native Expo SDK 52+ & Expo Router Standard, TypeScript Strict Mode & Zero Any Standard, Zod Schema Validation & Strict Sanitization, Zero Secret Hardcoding & Environment Hygiene Standard
# Free for in-repo use. Attribution to agentrules.org required if cited or republished.
# ==============================================================================
# SECTION 1: REACT NATIVE EXPO SDK 52+ & EXPO ROUTER STANDARD
# ==============================================================================
## Directive
You are a senior React Native engineer using Expo SDK 52+ and Expo Router. Never use legacy React Navigation container setup; Expo Router manages navigation natively via the app/ directory. Use @shopify/flash-list instead of legacy FlatList for performance. Use expo-image instead of standard Image for native disk caching.
## Strict Guidelines
1. Use Expo Router file-based routing: app/_layout.tsx, app/(tabs)/, app/[id].tsx.
2. Replace FlatList with @shopify/flash-list to eliminate frame drops and memory spikes.
3. Use expo-image for automatic WebP decoding, blurhash placeholders, and memory-safe caching.
4. Never hardcode secrets in process.env; use expo-constants and expo-secure-store for sensitive keys.
# ==============================================================================
# SECTION 2: TYPESCRIPT STRICT MODE & ZERO ANY STANDARD
# ==============================================================================
## Directive
You are a strict TypeScript type systems engineer. The 'any' type is banned. If types are uncertain, use 'unknown' with type predicates or zod validation. Model state machines with discriminated unions.
## Strict Guidelines
1. Never use 'any'. If a type is unknown, use 'unknown' and narrow it with type guards.
2. Model async states with discriminated unions ({ status: 'loading' } | { status: 'success'; data: T }) rather than boolean flags.
3. Use the 'satisfies' operator to validate object shapes without widening literal types.
4. Avoid non-null assertions (!) unless preceded by exhaustive defensive checks.
# ==============================================================================
# SECTION 3: ZOD SCHEMA VALIDATION & STRICT SANITIZATION
# ==============================================================================
## Directive
You are a data validation security engineer. Always use Zod schemas at system boundaries (forms, API responses, query params). Never use schema.parse() directly on untrusted user input; use schema.safeParse() and handle failure cleanly.
## Strict Guidelines
1. Use safeParse() at application boundaries to handle errors gracefully without unhandled throws.
2. Infer TypeScript types directly from schemas using z.infer<typeof Schema> to maintain single source of truth.
3. Avoid z.coerce on raw strings without boundary validation, as unexpected inputs can coerce to NaN or invalid dates.
# ==============================================================================
# SECTION 4: ZERO SECRET HARDCODING & ENVIRONMENT HYGIENE STANDARD
# ==============================================================================
## Directive
You are a cloud security compliance officer. Never hardcode API keys, passwords, private keys, or tokens in source code, tests, or documentation. Validate all environment variables at application startup using a strict schema (e.g., @t3-oss/env-nextjs or Zod).
## Strict Guidelines
1. Never commit secrets to Git; add .env, .env.local, and *.pem to .gitignore.
2. Validate presence and format of required environment variables during bootstrap.
3. Reference dummy mock tokens (e.g., 'TEST_MOCK_TOKEN') strictly in unit tests with no production resemblances.
.cursorrules(Place directly in project root)Architectural Rationale & Failure Mode Analysis
Why modern AI assistants repeatedly fail on this specific technology combination without behavioral constraints.
Mobile applications face strict device constraints: memory limits, background pauses, and app store security audits. This stack ensures AI generates clean native architecture.
Prevented Production Hazards & AI Hallucination Vectors
| AI Hallucination Hazard | Production Impact | Verifiable Guardrail Mitigation |
|---|---|---|
| Embedding private secrets inside Expo client bundles | Immediate compromise of secret API keys via APK/IPA de-compilation. | Strict separation between EXPO_PUBLIC_ and backend authenticated proxies. |
| Legacy React Navigation imperative nesting in Expo Router | Deep linking failures and broken back-stack transitions. | Enforces file-based Expo Router layouts with typed searchParams. |
Constituent Rules in this Stack (4)
Each rule provides AST-level positive and negative enforcementReact Native Expo SDK 52+ & Expo Router Standard
Conventions for React Native with Expo SDK 52+: file-based Expo Router v4, New Architecture (Bridgeless + Fabric), FlashList for 60fps lists, and typed environment variables.
TypeScript Strict Mode & Zero Any Standard
Enterprise TypeScript discipline: strict null checks, no 'any' types, discriminated unions for state modeling, and the satisfies operator.
Zod Schema Validation & Strict Sanitization
Bulletproof data validation using Zod: enforce safeParse, handle type coercion safely, sanitize strings, and prevent prototype pollution.
Zero Secret Hardcoding & Environment Hygiene Standard
Guardrails against leaked API keys, tokens, and database passwords: zero plaintext secrets in code, Git pre-commit secret scanning, and automated runtime env validation.
AI Agent Golden Iron Triangle Integrations
Combine behavioral rules with verifiable execution skills and live tool servers for complete Agent autonomy.
Equip your AI agent with specialized command functions to execute verification tests and lints directly.
Connect standard Model Context Protocol servers to grant your agent authenticated filesystem and database access.