feature-slicing

from ccheney/robust-skills

Robust skills for Agents

1 stars0 forksUpdated Jan 24, 2026
npx skills add https://github.com/ccheney/robust-skills --skill feature-slicing

SKILL.md

Feature-Sliced Design Architecture

Frontend architecture methodology with strict layer hierarchy and import rules for scalable, maintainable applications. FSD organizes code by business domain rather than technical role.

Official Docs: feature-sliced.design | GitHub: feature-sliced


THE IMPORT RULE (Critical)

Modules can ONLY import from layers strictly below them. Never sideways or upward.

app → pages → widgets → features → entities → shared
 ↓      ↓        ↓          ↓          ↓         ✓
 ✓      ✓        ✓          ✓          ✓      (external only)
ViolationExampleFix
Cross-slice (same layer)features/authfeatures/userExtract to entities/ or shared/
Upward importentities/userfeatures/authMove shared code down
Shared importing upshared/entities/Shared has NO internal deps

Exception: app/ and shared/ have no slices, so internal cross-imports are allowed within them.


Layer Hierarchy

LayerPurposeHas SlicesRequired
app/Initialization, routing, providers, global stylesNoYes
pages/Route-based screens (one slice per route)YesYes
widgets/Complex reusable UI blocks (header, sidebar)YesNo
features/User interactions with business value (login, checkout)YesNo
entities/Business domain models (user, product, order)YesNo
shared/Project-agnostic infrastructure (UI kit, API client, utils)NoYes

Minimal setup: app/, pages/, shared/ — add other layers as complexity grows.


Quick Decision Trees

"Where does this code go?"

Code Placement:
├─ App-wide config, providers, routing    → app/
├─ Full page / route component            → pages/
├─ Complex reusable UI block              → widgets/
├─ User action with business value        → features/
├─ Business domain object (data model)    → entities/
└─ Reusable, domain-agnostic code         → shared/

"Feature or Entity?"

Entity (noun)Feature (verb)
user — user data modelauth — login/logout actions
product — product infoadd-to-cart — adding to cart
comment — comment datawrite-comment — creating comments
order — order recordcheckout — completing purchase

Rule: Entities represent THINGS with identity. Features represent ACTIONS with side effects.

"Which segment?"

Segments (within a slice):
├─ ui/      → React components, styles
├─ api/     → Backend calls, data fetching, DTOs
├─ model/   → Types, schemas, stores, business logic
├─ lib/     → Slice-specific utilities
└─ config/  → Feature flags, constants

Naming: Use purpose-driven names (api/, model/) not essence-based (hooks/, types/).


Directory Structure

src/
├── app/                    # App layer (no slices)
│   ├── providers/          # React context, QueryClient, theme
│   ├── routes/             # Router configuration
│   └── styles/             # Global CSS, theme tokens
├── pages/                  # Page slices
│   └── {page-name}/
│       ├── ui/             # Page components
│       ├── api/            # Loaders, server actions
│       ├── model/          # Page-specific state
│       └── index.ts        # Public API
├── widgets/                # Widget slices
│   └── {widget-name}/
│       ├── ui/             # Composed UI
│       └── index.ts
├── features/               # Feature slices
│   └── {feature-name}/
│       ├── ui/             # Feature UI
│       ├── api/            # Feature API calls
│       ├── model/          # State, schemas
│       └── index.ts
├── entities/               # Entity slices
│   └── {entity-name}/
│       ├── ui/             # Entity UI (Card, Avatar)
│       ├── api/            # CRUD operations
│       ├── model/          # Types, mappers, validation
│       └── index.ts
└── shared/                 # Shared layer (no slices)
    ├── ui/                 # Design system components
    ├── api/                # API client, interceptors
    ├── lib/                # Utilities (dates, validation)
    ├── config/             # Environment, constants
    ├── routes/             # Route path constants
    └── i18n/               # Translations

Public API Pattern

Every slice MUST expose a public API via index.ts. External code imports ONLY from this file.

// entities/user/index.ts
export { UserCard } from './ui/UserCard';
export { UserAvatar } from './ui/UserAvatar';
export { getUser, updateUser } from './api/userApi';
export type { User, UserRole } from './model/types';
export { userSchema } from './model/schema';
// ✅ Correct
import { UserCard, type User } from '@/entities/user';

// ❌ Wrong
import { UserCard } fro

...
Read full content

Repository Stats

Stars1
Forks0
LicenseMIT License