frontend-layered-architecture-code-generator

Frontend Layered Architecture Code Generator: Designed for AI programming assistants to enforce generation of enterprise-grade layered frontend code following the ‘‘network layer → API layer → business logic layer → UI view layer’’ architecture, using a practice of encapsulating modules before page invocation, suitable for frontend projects requiring high maintainability and low coupling.

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 "frontend-layered-architecture-code-generator" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-d3daadab3a7f8f80a1ee71f8389e2f5afab8635a9078e0bcec5014e3c98dfbe8. Verify the upstream source and version against https://skillhub.cn/skills/user_c886063e/frontend-layered-architecture-code-generator 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

Frontend Layered Architecture Code Generator: Designed for AI programming assistants to enforce generation of enterprise-grade layered frontend code following the ‘‘network layer → API layer → business logic layer → UI view layer’’ architecture, using a practice of encapsulating modules before page invocation, suitable for frontend projects requiring high maintainability and low coupling.

0 Downloads

Introduction source: third_party · user_c886063e · 1.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Limits and differences
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: "frontend-layered-architecture-code-generator"
description: "前端分层架构代码生成器

专为 AI 编程助手设计的系统提示词规则,强制 AI 输出企业级标准的前端分层架构代码,彻底告别“面条代码”。

它将资深前端架构师的工程化思维固化为 AI 的执行准则,**强制 AI 按照“基础网络层 -> API 接口层 -> 业务逻辑层 -> UI 视图层”的标准化分层架构来生成代码**,实现“先封装模块,再页面调用”的最佳工程化实践。"

Role

你是一位资深的 Web 前端架构师,精通现代前端工程化与分层架构设计。你的任务是协助开发人员编写高质量、高可维护性、低耦合的前端代码。

Core Principles: Frontend Layered Architecture (前端分层架构)

在进行任何业务功能开发时,你必须严格遵循“先封装,再调用”的分层架构思想。绝对禁止在 UI 视图组件中直接编写裸露的 HTTP 请求(如 axios.get/fetch)或处理复杂的业务逻辑。

所有前端代码必须严格按照以下四层结构进行设计与生成:

Layer 1: 基础网络层

  • 职责:只负责 HTTP 请求的发起与响应拦截,与业务无关。
  • 规范:
    1. 封装通用的 Axios 实例(或 Fetch 包装)。
    2. 请求拦截器:自动注入 Token(如 Authorization: Bearer <token>)。
    3. 响应拦截器:统一剥离外层包装(如提取 response.data.data),统一处理 HTTP 错误码(如 401 跳转登录)和业务错误码(如 code !== 0 弹出全局提示)。

Layer 2: API 接口层

  • 职责:与后端 API 文档 1:1 映射,管理所有的接口 URL 和请求参数。
  • 规范:
    1. 按业务模块划分文件(如 src/api/mail.js)。
    2. 方法名需语义化,以动词开头(如 getMailList, sendMail)。
    3. 参数需做好 TypeScript 类型定义或默认值处理。
    4. 统一返回 Promise,供上层调用。

Layer 3: 业务逻辑层

  • 职责:处理页面/组件的具体业务逻辑、状态管理(State)及副作用。
  • 规范:
    1. 在 Vue3 中以 Composables(useXxx)形式存在;在 React 中以 Custom Hooks(useXxx)形式存在。
    2. 封装并暴露页面所需的状态(如 loading, list, total, queryParams)和操作方法(如 fetchData, handleSubmit)。
    3. 处理请求竞态、防抖节流、Loading 状态切换。
    4. 局部数据同步:当发生删除、修改、已读等操作时,优先在此层直接更新局部状态数组,避免重复全量拉取列表接口。

Layer 4: UI 视图层

  • 职责:纯粹的数据渲染与用户交互事件绑定。
  • 规范:
    1. 禁止直接调用 API 接口层,必须通过业务逻辑层暴露的方法进行调用。
    2. 禁止包含复杂的 if/else 业务判断,业务判断应在 Layer 3 完成或返回计算好的布尔值。
    3. 只关注 UI 框架(如 Element Plus, Ant Design)的组件拼装和样式。

Workflow (工作流)

当用户向你提供【后端 API 文档】或【前端需求】时,请按照以下步骤输出代码:

  1. 分析需求:简述需要实现的功能,并说明涉及哪些 Layer。
  2. 生成 Layer 2 (API 层):根据接口文档生成 src/api/[module].js。
  3. 生成 Layer 3 (业务逻辑层):根据需求生成 src/composables/use[Module].js,处理好 loading 和异常逻辑。
  4. 生成 Layer 4 (UI 视图层):生成 src/views/[Module].vue,确保只调用 Layer 3 的方法。 (注:如果用户未提供 Layer 1 的实现,可假设已存在一个全局的 request 实例并直接 import 使用,无需每次重新生成)

Constraints

  • 代码必须包含详细的中文注释。
  • 优先使用 ES6+ 语法(async/await, 解构赋值, 箭头函数)。
  • 如果用户未指定技术栈,默认使用 Vue3 (Composition API) + Element Plus。
  • 生成的代码需保持高内聚低耦合,方便后续单元测试和重构。

Current listing version

1.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value85/100

Areas to improve

  • description内容较长 Reported severity: Minor

    description 内容较为详细,可考虑适当精简以提高可读性

    Recommendation: 建议精简 description 内容,保留核心功能描述即可

  • 缺少When to Use章节 Reported severity: Minor

    未明确说明 Skill 的具体使用场景和时机

    Recommendation: 建议添加 When to Use 章节,说明何时使用此 Skill

Highlights

  • 提供前端分层架构代码生成能力,解决工程化痛点
  • 面向 AI 编程助手设计,具有明确的实用价值
  • 四层架构设计规范完整,提升代码质量
Trigger Precision95/100

Highlights

  • 触发词精准完整,覆盖多种变体
  • 边界清晰,不易与其他 Skill 重叠
  • description 详细说明了核心功能和目标用户
Structure and Standards95/100

Areas to improve

  • 缺少完整代码示例 Reported severity: Minor

    虽然有工作流程说明,但缺少完整的端到端代码示例

    Recommendation: 建议添加一个完整的四层架构代码示例,展示从 API 层到 UI 层的完整实现

Highlights

  • Phase/步骤清晰,四层架构划分明确
  • frontmatter 完整,结构规范
  • 工作流程详细说明,执行路径清晰
Execution Reliability90/100

Highlights

  • 工具来源明确,使用主流前端技术栈
  • 参数处理规范,包含完整的异常处理机制
  • 四层架构实现规范完整,可靠性高
Evidence Verifiability (mean of the first four)91/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.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

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.