360 Secure SkillHub
360 安全技能中心

React Project Standard

面向 React + TypeScript 中大型仓库,按识别仓库约定、判定目标层级、先设计边界再实现、输出质量项的顺序,给出目录与组件分层、Hooks 与路由组织、状态归属、API 层与错误处理约定,并附四份参考文件;表单、数据获取、测试、无障碍、安全等专项转交其说明的专门 Skill。

bovinphang
bovinphang
热度 61.50
最近更新 2026-09-26 22:45:10
分类:开发依赖:读写文件 / 内部调用大模型应用场景:代码生成 / 代码审查 / 模板

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add fec-react-project-standard
Metadata
name
fec-react-project-standard
description
Use when designing or reviewing React + TypeScript project structure, feature/module boundaries, component architecture, hooks organization, routing composition, state/API/error/styling defaults, or repository-wide React conventions. Prefer narrower skills for forms, data fetching, tests, accessibility, virtualization, animation, or security deep dives; Chinese triggers include React project specification, React component architecture.

React project specifications

Suitable for medium and large module construction, page reconstruction and engineering structure design in React + TypeScript warehouse.

Purpose

Provide engineering structure, module boundaries and default implementation conventions for React + TypeScript projects to ensure clear architecture and maintainable code.

Procedure

This skill mainly solves the problem of "how to design and implement" React engineering tasks, without repeating the basic coding bottom line. When handling React engineering tasks, perform them in the following order:

  1. Identify the warehouse and have an agreement

    • Directory organization
    • Style system
    • Status management solution
    • Request packaging method
    • Testing framework
    • UI component library/design system
  2. Determine which layer the target belongs to

    • Routing page -Page private components
    • feature business module
    • Global common components
    • hooks / services / stores / utils
  3. Design the boundaries before writing the code

    • What logic belongs to page layout
    • Which logic belongs to feature
    • Which logic should be transferred to general capabilities?
    • Which state should be managed locally and which should be handed over to store/query/URL
    • When the status ownership is complex, use the status management process to make a status list first
    • When the boundaries of DTO, public props, generic components or tsconfig are complex, first use the TypeScript project specification process to converge cross-framework type contracts
  4. Complete key quality items when outputting

    • loading / error / empty / data status
    • Error handling and retrying
    • Type constraints
    • Key test entrance
    • Diversion of necessary special skills
    • Check whether the dependency already exists in package.json. If it is missing, give the installation command first and then use it.
    • Whether heavy UI capabilities (animation, charts, 3D, editors, maps) are isolated as leaf components and loaded on demand
    • Whether images, videos, fonts and other resources are localized and cacheable, and avoid placeholder URLs from entering delivery
    • Whether page-level Error Boundary, module-level fallback, API error mapping and user-recoverable actions are consistent
    • Whether Tailwind token/variant or responsive layout requirements should be diverted to the corresponding special skill
  • Perform lightweight screening for obvious architectural performance risks, such as heavy dependency boundaries, too wide Context, high-frequency derived values and lazy loading fallback; enter the performance optimization workflow when indicator evidence is needed

Detailed reference

Load more detailed reference files as needed:

Constraints

  • Comply with the existing global rules and React rules of the warehouse by default
  • If the warehouse already has a clear directory structure, style system, status management or request encapsulation, the warehouse convention will be used first.
  • The size of the component file should be approximately 300 lines; if it exceeds 500 lines or is too complex, it must be split into sub-components, Hooks, utils, and types.
  • It is forbidden to add new class components (Error Boundary uses libraries such as react-error-boundary)
  • Disable bypassing module exports and importing from feature deep paths
  • Do not use useEffect + setState to simulate derived values that can be calculated directly
  • Avoid prop drilling too deep without considering composition or partial encapsulation
  • Do not synchronously introduce GSAP, Three.js, Lottie, rich text editor or map SDK into common page components; use dynamic import, route-level subcontracting or leaf component isolation when necessary.
  • No bare fetch, API URL, token refresh or upload processes scattered around React components; cross-border requests should be converged to the API integration layer.
  • Do not use Error Boundary to handle normal API failures; request errors should first fall into the loading/error/empty/data state and recoverable operations.
  • Do not write React performance recommendations as global memo without evidence; first locate request waterfall, bundle boundaries, repeated rendering or effect misuse.

Expected Output

  • Component boundaries are clear, pages/features/components are clearly layered
  • The Props type is complete and clear; the narrowing of complex public types or external data has been diverted to the TypeScript project specification process
  • Reusable logic has been extracted into hooks, and the loading/error/empty/data status is complete
  • The API layer has type constraints and unified error handling, and status management conforms to the proximity principle
  • URL status, server status, form status and global client status have clear boundaries
  • Key behaviors are covered by tests, and key modules have been wrapped with react-error-boundary
  • The long list has been evaluated for virtualization, and pop-up/composite components have keyboard and focus support
  • Respect the current situation of the warehouse first, and then recommend the structure
  • Give necessary suggestions for file division
  • Explain why this is layered if necessary
  • For new modules, give priority to outputting the smallest floor-mountable structure rather than over-designing it all at once
  • For reconstruction tasks, give priority to ensuring portability and risk controllability
  • For performance-related React changes, describe the triggered risk categories, evidence sources, and verification commands