Feature-Sliced Design (FSD) v2.1 — deciding which layer, slice and segment a piece of frontend code belongs to, plus the fozy-labs conventions.
Ships in fozy-labs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Based on FSD v2.1. The layer model is stack-agnostic; examples assume the fozy-labs fronted stack (simplest-di + rx-toolkit).
Core principle: Start simple, extract when needed. Place code in pages/ first.
Duplication across pages is acceptable.
Lower layers exist only when a piece is genuinely shared across 2+ slices and the team agrees to extract.
Strictness is a per-project choice — break a rule only as a deliberate decision, and document why.
app → pages → widgets → features → entities → shared
Imports flow downward only. Same-layer cross-imports between slices are forbidden.
| Layer | Responsibility |
|---|---|
app/ | Global providers, styles, error boundaries, entry point, router (default). |
pages/ | Route-level composition; owns substantial logic, not a thin wrapper. |
widgets/ | Composite UI blocks reused across 2+ pages. |
features/ | Reusable user interactions (2+ consumers). |
entities/ | Reusable business domain models (2+ consumers). |
shared/ | Infrastructure with no business logic: UI kit, API client, auth, route consts, framework tooling. |
Projects may add their own layers between existing ones (e.g. a
modals/layer for route-aware modal containers).
pages/ slice.shared/.features/.entities/.app/.Golden rule: when in doubt, keep it in pages/.
Worked single-use vs shared placements: references/practical-examples.md.
Upward imports and same-layer cross-slice imports are both forbidden. When two slices genuinely need to share, follow the resolution order in §5.
index.tsExternal consumers import from a slice's index.ts. Internal paths are not part of the contract.
import { LoginForm } from "@/features/auth"; // ✅
import { LoginForm } from "@/features/auth/ui/LoginForm"; // ❌
Name files after the business domain. Technical-role names mix unrelated concerns into one file.
❌ model/types.ts, model/utils.ts, api/endpoints.ts
✅ model/user.types.ts, model/order.store.ts, api/fetch-profile.ts
shared/ is infrastructure onlyUI kit, HTTP client, auth, route constants, framework hooks, assets. No business calculations, domain rules, or workflows — those belong in entities/ or higher.
Every file except the exceptions below carries a domain-prefixed type suffix, so its role is obvious from the filename alone.
| Suffix | Contents |
|---|---|
*.types.ts | TypeScript types / interfaces |
*.schema.ts | zod schemas + inferred DTOs |
*.api.ts | @injectable class with createResource / createCommand |
*.store.ts | @injectable class holding signals / state |
*.service.ts | @injectable class with behavior, no UI |
*.const.ts | Literal constants / enums |
*.model.ts | inject.define contracts and plain models |
*.router.ts(x) | Route tables |
*.guards.ts(x) | Route / auth guard components |
*.mock.ts | Test / fixture data |
*.test.ts(x) | Unit tests |
use*.ts | Custom React hooks |
Exceptions (no suffix): React components (PascalCase .tsx), pure utility functions (kebab-case verb — group-by.ts), index.ts, framework-required names (main.tsx, vite-env.d.ts).
Whether a store deserves DI at all is answered by fozy-labs-di / architecture.md, not here. Placement is orthogonal to the state-management choice — §1–§3 apply identically with Redux Toolkit, TanStack Query, or anything else.
When two same-layer slices need to share, try in order:
entities/; UI stays in features/ / widgets/.@x notation — last resort, between entities only; document why 1–3 do not apply.Inside a slice, group code by technical purpose.
| Segment | Contents | Typical files |
|---|---|---|
ui/ | Visual components and their styles. | UserAvatar.tsx |
model/ | Domain types, stores, business logic, validation. | user.types.ts, user.store.ts |
api/ | Backend integration — request functions and *.api.ts classes. | user.api.ts, fetch-profile.ts |
react/ | React code that renders nothing — hooks, contexts, HOCs. | use-current-user.ts, UserContext.tsx |
lib/ | Slice-internal, framework-agnostic utilities. | group-by.ts |
config/ | Slice-internal configuration. | user.const.ts |
app/ and shared/: segments only, no slices — segments may import each other within the layer.pages/, widgets/, features/, entities/: slices first, segments inside.pages/.shared/http/ is enough until domain logic attaches.user-management/) — split into login-form/, profile-edit/, password-reset/.app/ + pages/ + shared/; add layers when they earn their place.user.store.ts, never store.ts).Load these only when the specific situation applies — do not preload.
| Situation | File |
|---|---|
| Creating or reorganizing layers and slices; what belongs in each layer | references/layer-structure.md |
Picking a segment, naming a file, writing index.ts, path aliases | references/segments-and-naming.md |
Two same-layer slices need each other; @x; too many thin entities | references/cross-import-patterns.md |
| references/migration-guide.md | |
Concrete placement lookups — auth, DTO vs domain type, *Moving a non-FSD codebase onto FSD, or FSD v2.0 → v2.1, .api.ts, stores, hooks | references/practical-examples.md |
layer-structure.md and segments-and-naming.md are the two halves of one lookup — the first answers which layer and slice, the second which segment and filename. Load one; load both only when scaffolding a project from scratch.
practical-examples.md assumes both. Load it instead of them when the question names a concrete artifact (a login form, a DTO, an *.api.ts, a store), and after them only once the structural decision is settled.
What SKILL.md sets; muted values are Claude Code's defaults
Other plugins' skills for the same job
/fozy-labs:fozy-labs-fsdfrom fozy-labs
npx claudepluginhub fozy-labs/astp --plugin fozy-labs4 skills in this plugin
/fozy-labs-diDependency injection for js/ts projects based on @fozy-labs/simplest-di package.
/fozy-labs-rx-apiServer-state layer for js/ts projects based on the Query module of @fozy-labs/rx-toolkit (createApi / createResource / createCommand) — caching, SWR, optimistic updates, React hooks.
/fozy-labs-signalsReactive state primitives via @fozy-labs/rx-toolkit — Signal.state / compute / effect, LocalSignal, RxJS interop and the useSignal React hook.