Core principles and project structure for React 19 SPA development. Covers stack overview, project organization, agent execution rules, and authoritative sources. Use when planning new projects, onboarding, or reviewing architectural decisions.
Installation
Details
Usage
After installing, this skill will be available to your AI coding assistant.
Verify installation:
skills listSkill Instructions
name: core-principles description: Core principles and project structure for React 19 SPA development. Covers stack overview, project organization, agent execution rules, and authoritative sources. Use when planning new projects, onboarding, or reviewing architectural decisions.
Core Principles for React 19 SPA Development
Production-ready best practices for building modern React applications with TypeScript, Vite, and TanStack ecosystem.
Stack Overview
- React 19 with React Compiler (auto-memoization)
- TypeScript (strict mode)
- Vite (bundler)
- Biome (formatting + linting)
- TanStack Query (server state)
- TanStack Router (file-based routing)
- Vitest (testing with jsdom)
- Apidog MCP (API spec source of truth)
Project Structure
/src
/app/ # App shell, providers, global styles
/routes/ # TanStack Router file-based routes
/components/ # Reusable, pure UI components (no data-fetch)
/features/ # Feature folders (UI + hooks local to a feature)
/api/ # Generated API types & client (from OpenAPI)
/lib/ # Utilities (zod schemas, date, formatting, etc.)
/test/ # Test utilities
Key Principles:
- One responsibility per file
- UI components don't fetch server data
- Put queries/mutations in feature hooks
- Co-locate tests next to files
Agent Execution Rules
Always do this when you add or modify code:
-
API Spec: Fetch latest via Apidog MCP and regenerate
/src/apitypes if changed -
Data Access: Wire only through feature hooks that wrap TanStack Query. Never fetch inside UI components.
-
New Routes:
- Create file under
/src/routes/**(file-based routing) - If needs data at navigation, add loader that prefetches with Query
- Create file under
-
Server Mutations:
- Use React 19 Actions OR TanStack Query
useMutation(choose one per feature) - Use optimistic UI via
useOptimistic(Actions) or Query's optimistic updates - Invalidate/selectively update cache on success
- Use React 19 Actions OR TanStack Query
-
Compiler-Friendly:
- Keep code pure (pure components, minimal effects)
- If compiler flags something, fix it or add
"use no memo"temporarily
-
Tests:
- Add Vitest tests for new logic
- Component tests use RTL
- Stub network with msw
-
Before Committing:
- Run
biome check --write - Ensure Vite build passes
- Run
"Done" Checklist per PR
- Route file added/updated; loader prefetch (if needed) present
- Query keys are stable (
as const),staleTime/gcTimetuned - Component remains pure; no unnecessary effects; compiler ✨ visible
- API calls typed from
/src/api; inputs/outputs validated at boundaries - Tests cover new logic; Vitest jsdom setup passes
-
biome check --writeclean; Vite build ok
Authoritative Sources
-
React 19 & Compiler:
- React v19 overview
- React Compiler: overview + installation + verification
<form action>/ Actions API;useOptimistic;use- CRA deprecation & guidance
-
Vite:
- Getting started; env & modes; TypeScript targets
-
TypeScript:
moduleResolution: "bundler"(for bundlers like Vite)
-
Biome:
- Formatter/Linter configuration & CLI usage
-
TanStack Query:
- Caching & important defaults; v5 migration notes; devtools/persisting cache
-
TanStack Router:
- Install with Vite plugin; file-based routing; search params; devtools
-
Vitest:
- Getting started & config (jsdom)
-
Apidog + MCP:
- Apidog docs (import/export, OpenAPI); MCP server usage
Final Notes
- Favor compile-friendly React patterns
- Let the compiler and Query/Router handle perf and data orchestration
- Treat Apidog's OpenAPI (via MCP) as the single source of truth for network shapes
- Keep this doc as your "contract"—don't add heavy frameworks or configs beyond what's here unless explicitly requested
Related Skills
- tooling-setup - Vite, TypeScript, Biome configuration
- react-patterns - React 19 specific patterns (compiler, actions, forms)
- tanstack-router - Routing patterns
- tanstack-query - Server state management with Query v5
- router-query-integration - Integrating Router with Query
- api-integration - Apidog + MCP patterns
- performance-security - Performance, accessibility, security
More by MadAppGang
View allChoose optimal external AI models for code analysis, bug investigation, and architectural decisions. Use when consulting multiple LLMs via claudish, comparing model perspectives, or investigating complex Go/LSP/transpiler issues. Provides empirically validated model rankings (91/100 for MiniMax M2, 83/100 for Grok Code Fast) and proven consultation strategies based on real-world testing.
CRITICAL - Guide for using Claudish CLI ONLY through sub-agents to run Claude Code with OpenRouter models (Grok, GPT-5, Gemini, MiniMax). NEVER run Claudish directly in main context unless user explicitly requests it. Use when user mentions external AI models, Claudish, OpenRouter, or alternative models. Includes mandatory sub-agent delegation patterns, agent selection guide, file-based instructions, and strict rules to prevent context window pollution.
MANDATORY tracking protocol for multi-model validation. Creates structured tracking tables BEFORE launching models, tracks progress during execution, and ensures complete results presentation. Use when running 2+ external AI models in parallel. Trigger keywords - "multi-model", "parallel review", "external models", "consensus", "model tracking".
XML tag structure patterns for Claude Code agents and commands. Use when designing or implementing agents to ensure proper XML structure following Anthropic best practices.