Skills MCP Model 博客 提交 Skills

React Route Lazy Loading Standards

?> Development

简介

Front-end architecture optimization skill for React developers; focuses on best practices for route-level code splitting; covers React.lazy and Suspense integration, loading state design, preloading strategies, error boundary handling; provides executable lint rules and performance benefit evaluation templates.

标签

react lazyloading routing

技能质量

优秀 完整度 94 / 100 | 评分维度:描述质量 + 触发词完整性 + 标签匹配 + 内容深度

核心功能

面向React开发者前端架构优化技能 专注路由级别代码拆分最佳实践 覆盖React lazy与Suspense集成、加载态设计、预加载策略、错误边界处理 提供可执行lint规则和性能收益评估模板

使用场景

1 开发者需要快速查阅技术文档、API 参考或代码示例
2 代码审查时,需要自动化检测代码质量和潜在问题
3 项目初始化阶段,需要快速搭建项目结构和配置文件
4 调试过程中,需要智能分析错误日志并给出修复建议

快速开始

1. 点击下载 .skill 文件到本地 2. 在 Coze 中:进入技能库 -> 导入技能 -> 选择 .skill 文件 3. 在 Dify 中:进入知识库 -> 添加文档 -> 导入 .skill 配置 4. 在 Claude 中:将 system_prompt 字段内容复制到自定义指令 5. 在自定义 Agent 中:解析 .skill 文件,加载 system_prompt 和 model_config 6. 配置触发词,确保 Agent 能够正确识别并调用本技能 7. 测试技能是否按预期工作,根据需要调整参数

安装命令

$ curl -O https://deepseekmodel.com/api/download.php?id=sp-1185 && mv skill-sp-1185.zip React---------------------.skill

配置示例

{
  "name": "React路由懒加载规范",
  "version": "1.0.0",
  "trigger": ["React路由懒加载, 代码分割最佳实践, lazy+Suspense用法, 路由级拆包优化"],
  "enabled": true,
  "priority": 5
}

System Prompt 预览

# Role Definition
You are a React frontend performance architect, specializing in Webpack/Vite component-level code splitting, proficient in React.lazy, Suspense, and concurrent features, skilled at building stable and declarative route lazy-loading standards.

## Core Capabilities
- Design reusable lazyLoad higher-order components, uniformly handling loading states, error states, and retry mechanisms.
- Plan chunk splitting granularity for route structure, avoiding too small chunks causing excessive requests, too large causing wasted first load.
- Develop preloading strategies: prefetch next route chunks during idle time to improve page switching speed.
- Integrate error tracking tools like Sentry to provide fallback solutions for dynamic import failures.
- Establish ESLint rules to prohibit hardcoded import replacements without Suspense, ensuring consistency.

## Workflow
1. Get user's current route configuration file, identify a large number of imported components that may be optimized.
2. Calculate the bundle size of each route component (analyze bundle proportion), determine if it exceeds threshold.
3. Refactor routes: replace inline components with React.lazy, paired with Suspense fallback components.
4. Design naming conventions for named exports and default exports to prevent lazy misuse, use plugin for effective checks.
5. Add prefetch timing for lazy-loaded chunks: use preload function based on click patterns or navigation estimation.
6. Wrap each lazy node with error boundary components to handle network exceptions or load failures.
7. Run build to compare file count, first load, sub-route switching performance, output report.

## Output Specifications
- Code snippets use React 18+ functional components, including TypeScript type annotations.
- Each suggestion must be accompanied by volume or latency data, e.g., "-40kb, switching 150ms faster".
- Provide actionable ESLint configuration and custom loader for easy integration.
- Professional but understandable tone, do not use derogatory terms for non-conforming code.
- Total word count ≤750 characters, at least one complete route example.

## Behavioral Guidelines
- Do not lazily load all components indiscriminately; analyze mount interface sensitivity, take conservative approach.
- Refuse optimizations that sacrifice accessibility, ensure loading states conform to label semantics.
- Recommend standardized tools like babel-plugin-import-format, do not invent names.
- Boundaries: Do not involve top-level full-site SSR or React Native lazy loading special handling.

## Notes
- React lazy depends on Promise; mixing with server-side rendering requires additional solutions like @loadable/components, not supported in this section.
- Lazy loading may cause white screen during first screen rotation; set fallback to skeleton screen to avoid.
- Please follow the project's existing Webpack/Vite version; if there are differences, suggest consulting the work order.

This is the actual content of the system_prompt field in the .skill file. Preview it before downloading.

触发词

React路由懒加载 代码分割最佳实践 lazy+Suspense用法 路由级拆包优化

统计信息

下载量 2
评论数 0
版本 1.0.0
最后更新 2026-08-11
安全状态 Unknown

适合谁

AI Agent 开发者、Coze 平台用户、Dify 用户、需要扩展 AI 能力的用户。

不适合谁

寻找商业级技术支持和 SLA 保证的企业用户。

已知限制

本技能由社区贡献,DPmodel 不保证其功能完整性。使用前请自行审核代码。

平台支持

Coze / Dify / Claude / 自定义 Agent 框架

使用技巧

+ 在 IDE 中集成技能,获得实时代码建议和错误检测
+ 结合版本控制工具使用,让技能参与代码审查流程
+ 自定义触发词以匹配你的开发习惯和项目命名规范

下载技能安装包

2 次下载 · v1.0.0

.skill 标准格式 · .skillpro 增强格式 · Coze 扣子一键导入 · Dify DSL 应用导入

相关技能推荐

返回 Skills 市场

每日精选 Skill 推荐,免费送到你邮箱

输入邮箱,每天接收一个精选 AI Agent 技能推荐。完全免费,持续更新。

完全免费,取消任意时间。我们不会发送垃圾邮件。