stack-fe-react

Front-end tech stack, coding standards, and project scaffolding. For creating, developing, building, initializing, or refactoring any front-end project, React app, web app, SPA, or component library; includes a ready-to-use React 19 + TypeScript + Vite + Tailwind v4 project template (assets/frontend-template). Not applicable to pure back-end, non-React front-end frameworks, or prototype HTML/native mobile development.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "stack-fe-react" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-acb3ca3a33f7b29693ee00a487f4f269482db73949f6ae167f1ae483c6c3dc28. Verify the upstream source and version against https://skillhub.cn/skills/user_9501dc6b/stack-fe-react before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Front-end tech stack, coding standards, and project scaffolding. For creating, developing, building, initializing, or refactoring any front-end project, React app, web app, SPA, or component library; includes a ready-to-use React 19 + TypeScript + Vite + Tailwind v4 project template (assets/frontend-template). Not applicable to pure back-end, non-React front-end frameworks, or prototype HTML/native mobile development.

0 Downloads

Introduction source: third_party · user_9501dc6b · 2.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: stack-fe-react
slug: stack-fe-react
version: 2.0.1
displayName: stack-fe-react
description: >
  前端技术栈与编码规范及项目脚手架。当用户要求创建/开发/搭建/初始化/重构任何前端项目、React 应用、Web 应用、SPA、
  组件库开发,或涉及"前端""页面""界面""网站"的代码生成任务时必须使用;覆盖"用 React 写个 xxx""帮我搭个项目"
  "新建一个前端工程""写个组件""做个页面""重构前端代码"等场景,未明确提及框架但任务是前端相关时也应激活。
  内置可直接构建的 React 19 + TypeScript + Vite + Tailwind v4 项目模板(assets/frontend-template),新建项目时复制即用。
  不适用于:纯 Node.js 后端、Vue/Angular/Svelte 项目(用户明确指定时)、无需工程化的 HTML 原型、移动端原生开发。
license: MIT
disable: true

stack-fe-react — 前端技术栈规范

以 10 年经验前端架构师的标准生成、重构、解释所有前端代码。所有规范的可执行载体是 assets/frontend-template/:一个经过 pnpm install && pnpm build && pnpm test 验证的脚手架工程,含一个 features/projects 参考模块。写代码前先想清楚对应模板中的哪个位置、哪个文件,与其保持一致。

一、技术栈基准

类别 选型 关键约束
语言 TypeScript 最新稳定版 strict 必开;禁止 any
框架 React 19 仅函数式组件;开启 React Compiler
构建 Vite Compiler 依赖 Babel 管线用 @vitejs/plugin-react;不启用 Compiler 时可换 -swc 版提速
包管理 pnpm 禁止 npm / yarn
路由 React Router v7 默认库模式(纯 SPA);需 SSR/SEO 才用框架模式
服务端状态 TanStack Query 优先 useSuspenseQuery + Suspense 边界
客户端状态 Zustand 仅纯 UI 状态;严禁 Redux;Context 仅限低频更新
请求 Axios(可换 ofetch/ky) 统一实例 + 拦截器;禁止组件内裸 fetch
样式 Tailwind CSS v4 CSS-first @theme 配置,无 tailwind.config.ts;严禁 CSS-in-JS
组件库 shadcn/ui(Radix) CLI 添加组件;严禁 AntD/MUI/Element
图标 Lucide 按需导入
表单 React Hook Form + Zod zodResolver 声明式校验
工具库 es-toolkit / dayjs 严禁 lodash、moment
Lint Biome 替代 ESLint + Prettier
测试 Vitest + Testing Library 测行为非实现;E2E 按需 Playwright

二、新建项目:使用模板脚手架

新建任何前端项目时,必须从模板初始化,禁止从零手写工程文件:

  1. 复制 assets/frontend-template/ 到目标位置并改名
  2. pnpm install(lock 文件已锁定验证过的版本组合)
  3. 修改 package.json name、index.html title、src/index.css 的 @theme 主题 token
  4. 按需添加 shadcn 组件:npx shadcn@latest add <component>(配置已在 components.json)
  5. 保留 features/projects 模块作为分层参考实现,编写真实业务后删除
  6. 验证:pnpm build 与 pnpm test 必须全绿

模板已含:Vite + React Compiler 配置、Tailwind v4 @theme 入口、TS strict 三件套、Biome、Vitest + jsdom、Axios 统一实例、Zustand 示例 store、ErrorBoundary、shadcn 风格 Button 示例、@/ 路径别名。

三、代码组织铁律

src/
├── components/     # 通用组件(ui/ 为 shadcn 组件)
├── features/       # 按业务模块组织,每模块内含 api/ types/ components/ hooks/
├── lib/            # 工具函数、请求实例
├── stores/         # Zustand stores
├── hooks/          # 全局自定义 hooks
├── types/          # 全局 TS 类型
└── test/           # 测试 setup
  • 业务代码一律进 features/<模块>/,禁止散落在 components/ 或页面文件里
  • feature 内部自包含:API hooks(api/)、Zod schema(types/)、组件(components/)
  • index.html 必须在项目根目录,严禁放 public/

四、数据获取铁律(违反视为严重错误)

  • 服务端状态一律 useSuspenseQuery/useQuery + TanStack Query 缓存;严禁 useEffect + useState + fetch 手写请求(最常见反模式)
  • loading/error 交给 <Suspense> + <ErrorBoundary> 边界;组件内不写 if (isLoading) return ...
  • API 响应用 Zod z.parse() 解析,类型从 schema 推导(z.infer)
  • 表单提交用 useMutation,成功后精确失效相关 queryKey

五、UI 与样式铁律

  • 样式首选 Tailwind 工具类;复杂动画/全局覆盖可写 .css 文件;严禁 styled-components/emotion
  • 主题 token 统一定义在 src/index.css 的 @theme 中,使用方引用 bg-primary、text-text-muted 等语义类
  • 类名合并用 cn()(clsx + tailwind-merge)
  • shadcn 组件缺失时用 CLI 添加,不手写仿造

六、常见场景速查

需求 应该做 不应该做
发请求获取数据 useSuspenseQuery + 统一请求实例 useEffect + fetch + useState
提交表单 React Hook Form + zodResolver 手动控 value + onChange
全局 UI 状态 Zustand store Redux / 高频 Context
写样式 Tailwind 工具类 CSS-in-JS
加图标 Lucide 按需引 FontAwesome 全量引
工具函数 es-toolkit lodash
性能优化 依赖 React Compiler 堆 useMemo/useCallback/memo
日期处理 dayjs / date-fns moment.js
测试组件 Vitest + Testing Library Jest(除非历史项目)

七、提交前自检清单

  • [ ] 无 useEffect 内手写数据请求?服务端状态都走 TanStack Query?
  • [ ] 数据组件被 Suspense + ErrorBoundary 包裹?无散落 isLoading 分支?
  • [ ] API 响应经 Zod 解析?无手写 as any 断言?
  • [ ] 无 any?strict 编译零错误?
  • [ ] 无 Redux/lodash/moment/styled-components 等禁用库?
  • [ ] 样式走 Tailwind?主题 token 来自 @theme 而非硬编码色值?
  • [ ] 无手动 useMemo/useCallback/React.memo(Compiler 已处理)?
  • [ ] 业务代码在 features/ 内自包含?
  • [ ] 核心逻辑(utils/hooks/api)有测试?
  • [ ] pnpm build 与 pnpm test 全绿?

详细库选型规则、React Compiler 说明、Router 模式选择见 references/stack-rules.md;代码质量、注释、测试规范见 references/coding-style.md。

Current listing version

2.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Highlights

  • 提供完整的前端技术栈规范与可直接使用的 React 19 + TypeScript + Vite + Tailwind v4 项目模板
  • 覆盖高频刚需场景:新建前端项目、组件开发、代码重构等
  • 具有明确实用价值和广泛受众
Trigger Precision90/100

Highlights

  • 适用场景描述清晰:创建/开发/搭建前端项目、React 应用等
  • 不适用场景明确排除:Node.js 后端、Vue/Angular 等
  • 触发词覆盖全面,边界清晰
Structure and Standards90/100

Areas to improve

  • description 内容重复 Reported severity: Minor

    顶层 frontmatter 和 skill_body 内部均包含完整 description,存在冗余

    Recommendation: 建议只保留一处 description,避免重复

Highlights

  • 文档结构清晰,分技术栈基准、新建项目流程、代码组织等章节
  • 有详细步骤和示例,frontmatter 完整
Execution Reliability90/100

Areas to improve

  • 引用文件缺失 Reported severity: Minor

    skill_body 中引用了 references/stack-rules.md 和 references/coding-style.md,但未传入对应文件

    Recommendation: 请补充被引用的参考文件,或移除引用链接

Highlights

  • 工具来源明确(React 19、Vite、Tailwind v4 等),参数正确
  • 覆盖主要异常(如禁用库、反模式),新建项目流程有验证机制
Evidence Verifiability (mean of the first four)89/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 47

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.