frontend-ui-architecture
React + Next.js frontend architecture and code organization guide — where components, constants, utils/helpers, and business logic should live, how to split components, feature-based folder structure, colocation, and module boundaries. Use whenever deciding WHERE a new component, hook, constant, util, or business-logic function should go, when designing or reviewing a feature folder, or when a component/file is growing and needs to be split. This is about project structure and separation of concerns, not component internals, hooks correctness, or performance — for those use react-best-practices; for Next.js file conventions (routing, RSC, metadata) use next-best-practices.
- License 许可
- MIT
- 最近更新
- 2026-10-27
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- frontend-ui-architecture
- version
- 1.1.0
- description
- React + Next.js frontend architecture and code organization guide — where components, constants, utils/helpers, and business logic should live, how to split components, feature-based folder structure, colocation, and module boundaries. Use whenever deciding WHERE a new component, hook, constant, util, or business-logic function should go, when designing or reviewing a feature folder, or when a component/file is growing and needs to be split. This is about project structure and separation of concerns, not component internals, hooks correctness, or performance — for those use react-best-practices; for Next.js file conventions (routing, RSC, metadata) use next-best-practices.
02 资源文件 5
- 参考文档component-organization.md10.5 KB
- 参考文档folder-structure.md8.6 KB
- 参考文档nextjs-organization.md2.9 KB
- 参考文档README.md13.8 KB
- 参考文档RULES.md1.5 KB
03 SKILL.md 正文
Frontend UI Architecture
Guidance for where code lives, not how it's written. Covers React + Next.js project structure, component splitting, and the placement of constants, utils/helpers, and business logic.
- README.md — what this skill is, when it fires, and every source it's built on.
- folder-structure.md — top-level project layout, the decision order for where a new file goes, and folder-level anti-patterns (barrels, cross-feature imports, premature global folders).
- component-organization.md — when to split a component, where business logic lives (pure function vs. hook), and the constants/utils/helpers naming convention.
- nextjs-organization.md — route-local UI via private folders in the App Router, and how it interacts with the feature-based layout.
Relationship to sibling skills
- react-best-practices — component internals, hooks correctness, state/memoization anti-patterns. Read that for how a component or hook is written.
- next-best-practices — Next.js-specific file conventions (routing, RSC boundaries, metadata, async APIs). Read that for framework mechanics.
- onion-architecture — the backend counterpart: dependency direction for backend modules. Read that for anything about where backend code lives.
- This skill — where a file belongs and when to split it. If a question is "should this be a hook or a component," go to react-best-practices; if it's "which folder should this file live in," stay here.
Core Principle: Colocation Over Categorization
Default to organizing by feature/domain, not by technical type. Things
that change together should live together (Kent C. Dodds, paraphrasing Dan
Abramov). A folder structure of components/, hooks/, utils/,
services/ at the project root forces every change to touch multiple
folders and tells a new developer nothing about what the app does. See
folder-structure.md for the full layout this
principle produces.
Where Does New Code Belong? (quick routing)
- A new component, feature file, or top-level folder decision → folder-structure.md.
- Splitting a growing component, or deciding hook vs. plain function vs. constant → component-organization.md.
- Anything inside
app/in the Next.js App Router → nextjs-organization.md, then fall back to folder-structure.md for the shared-layer rules.
Each linked file ends with its own review checklist — use those directly when reviewing a PR rather than re-deriving the rules here.
04 同仓库更多 Skills
workflow-retro
Retrospective of a finished multi-agent workflow run (e.g. /sdd-engineering:run-plan, a code review, spec → plan → execution) — collects run facts (agents spawned, spawn order and waves, tokens per agent and per type, fix rounds, caps hit, human interventions), extracts insights per agent type (what was hard, what was easy, what information was duplicated, what each gate missed and who caught it later) and turns them into concrete, evidence-backed proposals for agent/skill/plan changes. Writes a ledger entry to docs/retro/ledger/ and a summary in chat. Data source is the current conversation by default; --deep also parses the session transcripts on disk. Invoked only by the user as /sdd-engineering:workflow-retro — never automatically, never by another skill or agent.
run-plan
Runs the Spec Driven Development execution workflow for an already-written Implementation Plan (docs/plans/<slug>.md) — implementer tasks wave by wave along the plan's DAG, one plan-verifier pass with a fix loop, an architecture-review loop (review → fix → re-review until clean or the round cap), then one full test run. Accepts the plan, optionally the spec, extra requirements text and design files. Does NOT run spec-creator or implementation-planner (those are run manually first). Invoked only by the user as /sdd-engineering:run-plan.
engineering-insights
Captures a non-obvious engineering insight (a working pattern, an antipattern/dead end, a decision with its reason, or a recurring error and fix) found while working in this repo, and files it into the INSIGHTS.md of the package the session touched. Use at the end of a session that learned something substantial, or immediately when something surprising comes up — skip when nothing non-obvious happened.
flaky-patterns
Reference catalogue of flaky-test causes — for each class, how it shows up in a stack trace, the real fix, the masking fixes to reject, and how to reproduce it deterministically without running the test many times. Use when diagnosing or reviewing a fix for a test that passes and fails on the same code.
flaky-fix
Triage and fix one flaky test without extra pipeline or test runs — from the test name, a stack trace, the date it became flaky and its failure rate to a Jira issue, a fix branch, a reviewed commit and a PR, with verification left to the normal runs of main after merge. Invoked only by the user as /flaky-fix:flaky-fix.
zod
Zod schema validation best practices for type safety, parsing, and error handling. This skill should be used when defining z.object schemas, using z.string validations, safeParse, or z.infer. This skill does NOT cover form-library integration (e.g. React Hook Form resolvers) or OpenAPI client generation.