/nextjs-architecture
Structure Next.js projects with Feature-Sliced Design layers, domain-grouped slices, and strict import hierarchy. Use when organizing features into FSD layers, enforcing slice boundaries, or keeping page.tsx thin.
$ npx -y skills add hoangnguyen0403/agent-skills-standard --skill nextjs-architecture --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/nextjs-architecture
Context preview
The summary Claude sees to decide when to auto-load this skill.
Structure Next.js projects with Feature-Sliced Design layers, domain-grouped slices, and strict import hierarchy. Use when organizing features into FSD layers, enforcing slice boundaries, or keeping page.tsx thin.
SKILL.md
nextjs-architecture.SKILL.mdname: nextjs-architecture
description: Structure Next.js projects with Feature-Sliced Design layers, domain-grouped slices, and strict import hierarchy. Use when organizing features into FSD layers, enforcing slice boundaries, or keeping page.tsx thin.
metadata:
triggers:
files:
- 'src/features/**'
- 'src/entities/**'
- 'src/widgets/**'
keywords:
- FSD
- Feature Sliced Design
- slices
- segmentsArchitecture (Feature-Sliced Design)
**Priority: P2 (MEDIUM)**
**Warning**: FSD introduces boilerplate. Use it only if project expected to grow significantly (e.g., 20+ features). For smaller projects, simple module-based structure preferred.
Workflow: Create New Feature Slice
1. **Create feature folder** — `src/features/auth/login/` with `ui/`, `model/`, `api/` segments. 2. **Add public API** — Export via `src/features/auth/login/index.ts`. 3. **Wire into page** — Import feature widget in `app/login/page.tsx` (thin page). 4. **Verify imports** — Ensure no upward or cross-slice imports violate layer hierarchy.
Layer Hierarchy
`App (app/) -> Widgets -> Features -> Entities -> Shared`
See [implementation examples](references/implementation.md) for thin page example.
Strategy
1. **RSC Boundaries**: Enforce strict serialization rules for props passed from Server to Client. See [RSC Boundaries & Serialization](references/RSC_BOUNDARIES.md). 2. **App Layer Thin**: `app/` directory (App Router) **only** for Routing.
- _Rule_: `page.tsx` should only import Widgets/Features. No business logic (`useEffect`, `fetch`) directly in pages.
3. **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.
4. **Layer Hierarchy**: Code can only import from _layers below it_.
- `App` -> `Widgets` -> `Features` -> `Entities` -> `Shared`.
5. **Avoid Excessive Entities**: not preemptively create Entities.
- _Rule_: Start logic in `Features` or `Pages`. Move to `Entities` **only** when data/logic strictly reused across multiple differing features.
- _Rule_: Simple CRUD belongs in `shared/api`, not `entities`.
6. **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 specific directory layout and layer definitions, see reference documentation.
- [**FSD Folder Structure**](references/fsd-structure.md)
- [**Bundling & Compatibility**](references/BUNDLING.md)
- [**Runtime Selection (Edge/Node)**](references/RUNTIME_SELECTION.md)
- [**Debug Tricks & MCP**](references/DEBUG_TRICKS.md)
Architecture Checklist (Mandatory)
- [ ] **Layer Imports**: any layer import from layer ABOVE it? (App > Widgets > Features > Entities > Shared)
- [ ] **Page Logic**: `page.tsx` thin, containing only Widgets/Features and zero `useEffect`/`fetch`?
- [ ] **RSC Boundaries**: Server Components isolated from Client Components with proper 'use client' boundaries?
- [ ] **Public API**: all access to slice performed via top-level `index.ts` (public API)?
- [ ] **Cross-Slice**: slices within same layer (e.g., two features) import from each other directly? (Prohibited)
- **Server Actions**: Place them in `model/` folder of Feature (e.g., `features/auth/model/actions.ts`).
- **Data Access (DAL)**: Place logic in `model/` folder of Entity (e.g., `entities/user/model/dal.ts`).
- **UI Components**: Base UI (shadcn) belongs in `shared/ui`. Feature-specific UI belongs in `features/*/ui`.
Anti-Patterns
- **No cross-slice imports**: Slices in same layer must not import from each other directly.
- **No business logic in `page.tsx`**: Pages import Widgets/Features only; zero `useEffect`/`fetch`.
- **No file-type folders**: Group by domain (`features/auth/`), not type (`components/`, `hooks/`).
- **No premature Entity creation**: Start in Features; move to Entities only on strict reuse.
Read more
name: nextjs-architecture
description: Structure Next.js projects with Feature-Sliced Design layers, domain-grouped slices, and strict import hierarchy. Use when organizing features into FSD layers, enforcing slice boundaries, or keeping page.tsx thin.
metadata:
triggers:
files:
- 'src/features/**'
- 'src/entities/**'
- 'src/widgets/**'
keywords:
- FSD
- Feature Sliced Design
- slices
- segmentsArchitecture (Feature-Sliced Design)
**Priority: P2 (MEDIUM)**
**Warning**: FSD introduces boilerplate. Use it only if project expected to grow significantly (e.g., 20+ features). For smaller projects, simple module-based structure preferred.
Workflow: Create New Feature Slice
1. **Create feature folder** — `src/features/auth/login/` with `ui/`, `model/`, `api/` segments. 2. **Add public API** — Export via `src/features/auth/login/index.ts`. 3. **Wire into page** — Import feature widget in `app/login/page.tsx` (thin page). 4. **Verify imports** — Ensure no upward or cross-slice imports violate layer hierarchy.
Layer Hierarchy
`App (app/) -> Widgets -> Features -> Entities -> Shared`
See [implementation examples](references/implementation.md) for thin page example.
Strategy
1. **RSC Boundaries**: Enforce strict serialization rules for props passed from Server to Client. See [RSC Boundaries & Serialization](references/RSC_BOUNDARIES.md). 2. **App Layer Thin**: `app/` directory (App Router) **only** for Routing.
- _Rule_: `page.tsx` should only import Widgets/Features. No business logic (`useEffect`, `fetch`) directly in pages.
3. **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.
4. **Layer Hierarchy**: Code can only import from _layers below it_.
- `App` -> `Widgets` -> `Features` -> `Entities` -> `Shared`.
5. **Avoid Excessive Entities**: not preemptively create Entities.
- _Rule_: Start logic in `Features` or `Pages`. Move to `Entities` **only** when data/logic strictly reused across multiple differing features.
- _Rule_: Simple CRUD belongs in `shared/api`, not `entities`.
6. **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 specific directory layout and layer definitions, see reference documentation.
- [**FSD Folder Structure**](references/fsd-structure.md)
- [**Bundling & Compatibility**](references/BUNDLING.md)
- [**Runtime Selection (Edge/Node)**](references/RUNTIME_SELECTION.md)
- [**Debug Tricks & MCP**](references/DEBUG_TRICKS.md)
Architecture Checklist (Mandatory)
- [ ] **Layer Imports**: any layer import from layer ABOVE it? (App > Widgets > Features > Entities > Shared)
- [ ] **Page Logic**: `page.tsx` thin, containing only Widgets/Features and zero `useEffect`/`fetch`?
- [ ] **RSC Boundaries**: Server Components isolated from Client Components with proper 'use client' boundaries?
- [ ] **Public API**: all access to slice performed via top-level `index.ts` (public API)?
- [ ] **Cross-Slice**: slices within same layer (e.g., two features) import from each other directly? (Prohibited)
- **Server Actions**: Place them in `model/` folder of Feature (e.g., `features/auth/model/actions.ts`).
- **Data Access (DAL)**: Place logic in `model/` folder of Entity (e.g., `entities/user/model/dal.ts`).
- **UI Components**: Base UI (shadcn) belongs in `shared/ui`. Feature-specific UI belongs in `features/*/ui`.
Anti-Patterns
- **No cross-slice imports**: Slices in same layer must not import from each other directly.
- **No business logic in `page.tsx`**: Pages import Widgets/Features only; zero `useEffect`/`fetch`.
- **No file-type folders**: Group by domain (`features/auth/`), not type (`components/`, `hooks/`).
- **No premature Entity creation**: Start in Features; move to Entities only on strict reuse.
The portable SDLC standards layer for AI coding agents. Sync once, then work in your own runtime.
Repo: hoangnguyen0403/agent-skills-standard
Other skills on agent-skills-standard.
- /android-agp-upgrade
Upgrade an Android project to Android Gradle Plugin (AGP) 9. Use when migrating to AGP 9, updating Gradle build files, migrating to built-in Kotlin, or adopting the new AGP DSL.
Open skill - /android-architecture
Apply Clean Architecture layering, modularization, and Unidirectional Data Flow in Android projects. Use when setting up project structure, placing code in layers, configuring feature/core modules, or implementing UDF patterns; defer Compose state and ViewModel/StateFlow
Open skill - /android-background-work
Implement WorkManager and background processing correctly on Android. Use when creating Worker classes, scheduling tasks, choosing between WorkManager and Foreground Services, or setting up Hilt in workers; defer FCM and notification delivery to android-notifications.
Open skill - /android-compose-migration
Migrate an Android XML View to Jetpack Compose following a structured 10-step workflow. Use when converting XML layouts to Compose, setting up Compose in an existing View-based project, or incrementally adopting Compose.
Open skill - /android-compose
Build high-performance declarative UI with Jetpack Compose. Use when writing Composable functions, optimizing recomposition, hoisting state, or working with LazyColumn and side effects; defer deep-link and navigation routing to android-navigation.
Open skill - /android-concurrency
Write correct coroutine scopes, lifecycle collection, and dispatcher injection in Android production code. Use for suspend functions, coroutine scopes, and dispatcher mechanics; defer ViewModel StateFlow/LiveData architecture, Fragment lifecycle recipes,
Open skill

