Skill站外收录 @skilllib/skill-2014279404656996353
core-principles
确立 React 19 单页应用开发的核心规范,涵盖技术栈选型、模块化项目结构、数据流约束(禁止 UI 层直连网络)、路由与服务端交互的标准化协作方式,以及以 OpenAPI 为唯一数据契约的全链路一致性保障。
软件开发 AI 技能
Skills.MD
# 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:**
1. **API Spec:** Fetch latest via Apidog MCP and regenerate `/src/api` types if changed
2. **Data Access:** Wire only through feature hooks that wrap TanStack Query. Never fetch inside UI components.
3. **New Routes:**
- Create file under `/src/routes/**` (file-based routing)
- If needs data at navigation, add loader that prefetches with Query
4. **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
5. **Compiler-Friendly:**
- Keep code pure (pure components, minimal effects)
- If compiler flags something, fix it or add `"use no memo"` temporarily
6. **Tests:**
- Add Vitest tests for new logic
- Component tests use RTL
- Stub network with msw
7. **Before Committing:**
- Run `biome check --write`
- Ensure Vite build passes
## "Done" Checklist per PR
- [ ] Route file added/updated; loader prefetch (if needed) present
- [ ] Query keys are stable (`as const`), `staleTime`/`gcTime` tuned
- [ ] 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 --write` clean; 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
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「core-principles」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次