Back to list
HoangNguyen0403

nextjs-architecture-fsd

by HoangNguyen0403

A collection of Agent Skills Standard and Best Practice for Programming Languages, Frameworks that help our AI Agent follow best practies on frameworks and programming laguages

111🍴 40📅 Jan 23, 2026

SKILL.md


name: Next.js Architecture (FSD) description: Scalable project structure using Feature-Sliced Design (FSD). metadata: labels: [nextjs, architecture, fsd, folder-structure] triggers: files: ['src/features/', 'src/entities/', 'src/widgets/**'] keywords: [FSD, Feature Sliced Design, slices, segments]

Architecture (Feature-Sliced Design)

Priority: P2 (MEDIUM)

Adopt Feature-Sliced Design (FSD) for scalable applications. Warning: FSD introduces boilerplate. Use it only if the project is expected to grow significantly (e.g., 20+ features). For smaller projects, a simple module-based structure is preferred.

Strategy

  1. App Layer is Thin: The app/ directory (App Router) is only for Routing.
    • Rule: page.tsx should only import Widgets/Features. No business logic (useEffect, fetch) directly in pages.
  2. Slices over Types: Group code by Business Domain (User, Product, Cart), not by File Type (Components, Hooks, Utils).
    • Bad: src/components/LoginForm.tsx, src/hooks/useLogin.ts
    • Good: src/features/auth/login/ containing both.
  3. Layer Hierarchy: Code can only import from layers below it.
    • App -> Widgets -> Features -> Entities -> Shared.
  4. Avoid Excessive Entities: Do not preemptively create Entities.
    • Rule: Start logic in Features or Pages. Move to Entities only when data/logic is strictly reused across multiple differing features.
    • Rule: Simple CRUD belongs in shared/api, not entities.
  5. Standard Segments: Use standard segment names within slices.
    • ui (Components), model (State/actions), api (Data fetching), lib (Helpers), config (Constants).
    • Avoid: components, hooks, services as segment names.

Structure Reference

For the specific directory layout and layer definitions, see the reference documentation.

Integration with Next.js Core

  • Server Actions: Place them in the model/ folder of a Feature (e.g., features/auth/model/actions.ts).
  • Data Access (DAL): Place logic in the model/ folder of an Entity (e.g., entities/user/model/dal.ts).
  • UI Components: Base UI (shadcn) belongs in shared/ui. Feature-specific UI belongs in features/*/ui.

Score

Total Score

85/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

+5
最近の活動

1ヶ月以内に更新

+10
フォーク

10回以上フォークされている

+5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

+5

Reviews

💬

Reviews coming soon