/SKILL.md
Apply Feature-Sliced Design (FSD) v2.1 architectural methodology to frontend projects. Use when organizing code structure, decomposing features, creating new components or features, refactoring existing codebases, or when users mention "FSD", "Feature-Sliced", layers, slices, or frontend architecture patterns.
npx skillsauth add aiko-atami/fsd feature-sliced-designInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
An architectural methodology skill for scaffolding and organizing frontend applications using Feature-Sliced Design principles.
Feature-Sliced Design v2.1 is a compilation of rules and conventions for organizing frontend code to make projects more understandable, maintainable, and stable in the face of changing business requirements.
Version 2.1 introduces the "Pages First" approach - keeping more code in pages and widgets rather than prematurely extracting it to features and entities.
The fundamental principle of FSD v2.1: Keep code where it's used until you need to reuse it.
Instead of immediately extracting everything into entities and features, start by keeping code in pages and widgets. Only move code to lower layers when you actually need to reuse it.
✅ Large UI blocks that are only used on one page ✅ Forms and their validation logic specific to a page ✅ Data fetching and state management for page-specific data ✅ Business logic that serves only this page/widget ✅ API interactions needed only here
FSD uses 6 active standardized layers organized by responsibility and dependencies. Layers are ordered from most specific (top) to most generic (bottom):
app/ ← Application initialization, providers, global styles
pages/ ← Full page compositions with their own logic, routing
widgets/ ← Large composite UI blocks with their own logic
features/ ← Reusable user interactions and business features
entities/ ← Reusable business entities (user, product, order)
shared/ ← Reusable infrastructure code (UI kit, utils, API)
Note: Historically, FSD included processes/ as a 7th layer, but it is deprecated in v2.1. If you're using it, move the code to features/ with help from app/ if needed.
Import Rule: A module can only import from layers strictly below it.
features/ → entities/, shared/pages/ → widgets/, features/, entities/, shared/entities/ → features/ (upward import)features/comments/ → features/posts/ (same-layer cross-import)Slices group code by business domain meaning. Each slice represents a specific business concept:
features/
├── auth/ ← Authentication feature
├── comments/ ← Comments functionality
└── post-editor/ ← Post editing feature
entities/
├── user/ ← User business entity
├── product/ ← Product business entity
└── order/ ← Order business entity
Key Rules:
Segments group code within slices by technical purpose:
features/
└── auth/
├── ui/ ← React components, styles, formatters
├── api/ ← API requests, data types, mappers
├── model/ ← State management, business logic, stores
├── lib/ ← Internal utilities for this slice
├── config/ ← Configuration, feature flags
└── index.ts ← Public API (exports only what other slices need)
Standard Segments:
ui - UI components, styles, date formattersapi - Backend interactions, request functions, data typesmodel - Data models, state stores, business logiclib - Utility functions needed by this sliceconfig - Configuration files, feature flagsEvery slice must define a public API through an index file:
// features/auth/index.ts
export { LoginForm } from './ui/LoginForm';
export { useAuth } from './model/useAuth';
export { loginUser } from './api/loginUser';
// Internal files not exported remain private to the slice
Rule: Modules outside a slice can only import from the public API, not from internal files.
New in v2.1: You can now create explicit connections between slices on the same layer (typically entities) using the @x notation.
This allows entities to reference each other when there's a legitimate business relationship:
// entities/user/index.ts
export { UserCard } from './ui/UserCard';
export { userModel } from './model';
// entities/user/@x/order.ts
// Cross-import API specifically for the order entity
export { UserOrderHistory } from './ui/UserOrderHistory';
export { getUserOrders } from './api/getUserOrders';
// entities/order/index.ts
import { UserOrderHistory } from '@/entities/user/@x/order';
// Now order can import from user's cross-import API
When to use cross-imports:
Important: Regular cross-imports between slices (without @x) are still not allowed. Use @x notation to make cross-dependencies explicit and controlled.
Application-wide settings, providers, routing setup.
app/
├── providers/ ← Redux Provider, React Query, Theme Provider
├── styles/ ← Global CSS, resets, theme variables
├── index.tsx ← Application entry point
└── router.tsx ← Route configuration
Route-level compositions with their own logic and data management.
pages/
├── home/
│ ├── ui/
│ │ ├── HomePage.tsx
│ │ ├── HeroSection.tsx ← Large UI blocks
│ │ └── FeaturesGrid.tsx
│ ├── model/
│ │ └── useHomeData.ts ← Page-specific state
│ ├── api/
│ │ └── fetchHomeData.ts ← Page-specific API
│ └── index.ts
├── profile/
│ ├── ui/
│ │ ├── ProfilePage.tsx
│ │ ├── ProfileForm.tsx ← Forms specific to this page
│ │ └── ProfileStats.tsx
│ ├── model/
│ │ ├── profileStore.ts ← State for profile page
│ │ └── validation.ts ← Form validation
│ ├── api/
│ │ ├── updateProfile.ts
│ │ └── fetchProfile.ts
│ └── index.ts
└── settings/
v2.1 Approach: Pages can now contain:
Only extract to lower layers when you need to reuse the code elsewhere.
Complex, composite UI blocks with their own logic, used across multiple pages.
widgets/
├── header/
│ ├── ui/
│ │ ├── Header.tsx
│ │ ├── Navigation.tsx
│ │ └── UserMenu.tsx
│ ├── model/
│ │ └── headerStore.ts ← Widget state
│ ├── api/
│ │ └── fetchNotifications.ts ← Widget-specific API
│ └── index.ts
├── sidebar/
│ ├── ui/
│ ├── model/
│ │ └── sidebarState.ts
│ └── index.ts
└── footer/
v2.1 Approach: Widgets are no longer just compositional blocks. They can contain:
Only extract code to entities/features when other widgets or pages need it.
Reusable user interactions and complete business features used in multiple places.
features/
├── auth/
│ ├── ui/
│ │ ├── LoginForm.tsx
│ │ └── RegisterForm.tsx
│ ├── model/
│ │ └── useAuth.ts
│ ├── api/
│ │ ├── login.ts
│ │ └── register.ts
│ └── index.ts
├── add-to-cart/
├── like-post/
└── comment-create/
v2.1 Approach: Only create a feature when:
Don't create features prematurely. If a user interaction is only used in one place, keep it in the page or widget until you actually need to reuse it.
Reusable business entities - the core domain models used across the application.
entities/
├── user/
│ ├── ui/
│ │ ├── UserCard.tsx
│ │ └── UserAvatar.tsx
│ ├── model/
│ │ ├── types.ts
│ │ └── userStore.ts
│ ├── api/
│ │ └── userApi.ts
│ ├── @x/
│ │ └── order.ts ← Cross-import API for order
│ └── index.ts
├── product/
└── order/
v2.1 Approach: Only create an entity when:
Don't prematurely extract entities. If a data structure is only used in one place, keep it there until you need to share it.
Reusable infrastructure code with no business logic.
shared/
├── ui/ ← UI kit components
│ ├── Button/
│ ├── Input/
│ └── Modal/
├── lib/ ← Utilities
│ ├── formatDate/
│ ├── debounce/
│ └── classnames/
├── api/ ← API client setup, base config
│ ├── client.ts
│ └── apiRoutes.ts ← Route constants (v2.1: allowed!)
├── config/ ← Environment variables, constants
│ ├── env.ts
│ └── appConfig.ts
├── assets/ ← Images, fonts, icons
│ ├── logo.svg ← Company logo (v2.1: allowed!)
│ └── icons/
└── types/ ← Common TypeScript types
v2.1 Update: Shared can now contain application-aware code:
Still not allowed:
No slices in Shared - organized by segments only. Segments can import from each other within Shared.
Start simple - keep API logic in the page until you need to reuse it:
// pages/profile/api/fetchProfile.ts
export const fetchProfile = (id: string) =>
apiClient.get(`/users/${id}`);
// pages/profile/model/useProfile.ts
export const useProfile = (id: string) => {
const [user, setUser] = useState(null);
useEffect(() => {
fetchProfile(id).then(setUser);
}, [id]);
return user;
};
// pages/profile/ui/ProfilePage.tsx
import { useProfile } from '../model/useProfile';
const ProfilePage = () => {
const user = useProfile('123');
return <div>{user?.name}</div>;
};
Only move to entities when other pages need the same API:
// entities/user/api/userApi.ts
export const fetchUser = (id: string) =>
apiClient.get(`/users/${id}`);
// entities/user/model/userStore.ts
export const useUser = (id: string) => {
const [user, setUser] = useState(null);
useEffect(() => {
fetchUser(id).then(setUser);
}, [id]);
return user;
};
// entities/user/index.ts
export { useUser } from './model/userStore';
export type { User } from './model/types';
// Now multiple pages can use it:
// pages/profile/ui/ProfilePage.tsx
// pages/user-list/ui/UserListPage.tsx
import { useUser } from '@/entities/user';
Features can use entities and other features:
// features/post-card/ui/PostCard.tsx
import { UserAvatar } from '@/entities/user';
import { LikeButton } from '@/features/like-post';
import { CommentButton } from '@/features/comment-create';
export const PostCard = ({ post }) => (
<article>
<UserAvatar userId={post.authorId} />
<h2>{post.title}</h2>
<p>{post.content}</p>
<div>
<LikeButton postId={post.id} />
<CommentButton postId={post.id} />
</div>
</article>
);
Routes should be defined in the App layer, pages composed in Pages layer:
// app/router.tsx
import { HomePage } from '@/pages/home';
import { ProfilePage } from '@/pages/profile';
export const router = createBrowserRouter([
{ path: '/', element: <HomePage /> },
{ path: '/profile/:id', element: <ProfilePage /> },
]);
// app/index.tsx
import { RouterProvider } from 'react-router-dom';
import { router } from './router';
export const App = () => <RouterProvider router={router} />;
// shared/ui/Button/Button.tsx
export const Button = ({ children, onClick, variant = 'primary' }) => (
<button className={`btn btn-${variant}`} onClick={onClick}>
{children}
</button>
);
// shared/ui/Button/index.ts
export { Button } from './Button';
export type { ButtonProps } from './Button';
// Usage in feature
import { Button } from '@/shared/ui/Button';
const LoginForm = () => (
<form>
<Button variant="primary">Login</Button>
</form>
);
Use path aliases for clean imports:
// tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/app/*": ["src/app/*"],
"@/pages/*": ["src/pages/*"],
"@/widgets/*": ["src/widgets/*"],
"@/features/*": ["src/features/*"],
"@/entities/*": ["src/entities/*"],
"@/shared/*": ["src/shared/*"]
}
}
}
Start with: "Where is this code used?"
Is it reusable infrastructure?
Is it a complete user action?
Is it a business domain concept?
Is it app-wide setup?
"User profile form with validation"
pages/profile/ui/ProfileForm.tsxfeatures/profile-form/"Product card component"
pages/products/ui/ProductCard.tsxwidgets/product-card/ or entities/product/ui/ProductCard.tsxshared/ui/Card/"Fetch product data"
pages/product-detail/api/fetchProduct.tsentities/product/api/productApi.ts"Modal manager"
shared/ui/modal-manager/"When in doubt, keep it in pages/widgets. Extract to lower layers when you actually need to reuse it."
Don't try to predict reusability. Wait for actual reuse to emerge, then refactor.
❌ Premature extraction (v2.1 key anti-pattern)
// Immediately creating an entity/feature before knowing if it's needed
// entities/user-profile-form/ ← Used only on one page!
✅ Solution: Keep in page until actually needed elsewhere
// pages/profile/ui/ProfileForm.tsx ← Start here
// Only move to features/ when another page needs it
❌ Cross-imports between slices on same layer
// features/comments/ui/CommentList.tsx
import { likePost } from '@/features/like-post'; // BAD!
✅ Solution: Use @x notation for entities, or compose at higher layer
// For entities with business relationships:
// entities/user/@x/order.ts
export { UserOrderHistory } from './ui/UserOrderHistory';
// For features, compose at page level:
// pages/post/ui/PostPage.tsx
import { CommentList } from '@/features/comments';
import { LikeButton } from '@/features/like-post';
❌ Business logic in Shared
// shared/lib/userHelpers.ts
export const calculateUserReputation = (user) => { ... }; // BAD!
✅ Solution: Move to entities layer
// entities/user/lib/calculateReputation.ts
export const calculateUserReputation = (user) => { ... };
❌ Bypassing public API
import { LoginButton } from '@/features/auth/ui/LoginButton'; // BAD!
✅ Use public API
import { LoginButton } from '@/features/auth'; // GOOD!
❌ God slices (too much responsibility)
// features/user-management/ ← TOO BROAD
// - login, register, profile-edit, password-reset, etc.
✅ Split into focused features
// features/auth/
// features/profile-edit/
// features/password-reset/
If you have an existing FSD 2.0 project, migration to 2.1 is non-breaking. You can adopt the "pages first" approach gradually.
Audit current features and entities
Move page-specific code back to pages
pages/[page]/ui/pages/[page]/api/pages/[page]/model/Move widget-specific code to widgets
Keep truly reusable code in features/entities
Update Shared with application-aware code
shared/api/routes.tsshared/assets/Deprecate Processes layer
Consider using @x notation
Before (v2.0):
features/
└── user-profile-form/ ← Only used on profile page
├── ui/
├── model/
└── api/
pages/
└── profile/
└── ui/
└── ProfilePage.tsx ← Just composition
After (v2.1):
pages/
└── profile/
├── ui/
│ ├── ProfilePage.tsx
│ └── ProfileForm.tsx ← Moved here
├── model/
│ └── profileStore.ts ← Moved here
└── api/
└── updateProfile.ts ← Moved here
When migrating existing code to FSD:
shared/entities/features/app/Do it gradually - you don't need to refactor everything at once.
features/
└── todo-list/
├── ui/
│ └── TodoList.tsx
├── model/
│ ├── todoSlice.ts ← Redux slice
│ ├── selectors.ts ← Selectors
│ └── thunks.ts ← Async actions
└── index.ts
entities/
└── user/
├── ui/
├── api/
│ └── userQueries.ts ← React Query hooks
├── model/
│ └── types.ts
└── index.ts
Place FSD structure in src/ folder to avoid conflicts with Next.js app/ or pages/ folders:
my-nextjs-project/
├── app/ ← Next.js App Router (if using)
├── pages/ ← Next.js Pages Router (if using)
└── src/
├── app/ ← FSD app layer
├── pages/ ← FSD pages layer
├── widgets/
├── features/
├── entities/
└── shared/
project/
├── src/
│ ├── app/
│ ├── pages/
│ ├── widgets/
│ ├── features/
│ ├── entities/
│ └── shared/
├── tsconfig.json
├── vite.config.ts
└── package.json
project/
└── src/
├── app/
├── pages/
├── widgets/
├── features/
├── entities/
└── shared/
Layer Selection:
app/pages/widgets/features/entities/shared/Import Direction: App → Pages → Widgets → Features → Entities → Shared
Public API: Always create index.ts for slices to export public interface
For more detailed information and edge cases:
When implementing FSD in a project:
Steiger is an official linter that helps enforce FSD rules automatically:
Installation:
npm install -D @feature-sliced/steiger
Usage:
npx steiger src
Steiger is production-ready and actively maintained. It's the best way to ensure your team follows FSD conventions consistently.
Trigger this skill when:
"Start simple, extract when needed."
Don't try to predict the future architecture. Build features in pages and widgets first. When you see actual reuse patterns emerging, then extract to features and entities. This leads to:
This skill provides the foundational knowledge to structure any frontend application using Feature-Sliced Design v2.1 methodology. Always prioritize code cohesion, wait for actual reuse before extracting, and maintain proper layering to ensure maintainable and scalable code architecture.
development
Maintainer-only workflow for handling GitHub Secret Scanning alerts on OpenClaw. Use when Codex needs to triage, redact, clean up, and resolve secret leakage found in issue comments, issue bodies, PR comments, or other GitHub content.
development
Maintainer workflow for OpenClaw releases, prereleases, changelog release notes, and publish validation. Use when Codex needs to prepare or verify stable or beta release steps, align version naming, assemble release notes, check release auth requirements, or validate publish-time commands and artifacts.
development
Run, watch, debug, and extend OpenClaw QA testing with qa-lab and qa-channel. Use when Codex needs to execute the repo-backed QA suite, inspect live QA artifacts, debug failing scenarios, add new QA scenarios, or explain the OpenClaw QA workflow. Prefer the live OpenAI lane with regular openai/gpt-5.4 in fast mode; do not use gpt-5.4-pro or gpt-5.4-mini unless the user explicitly overrides that policy.
development
End-to-end Parallels smoke, upgrade, and rerun workflow for OpenClaw across macOS, Windows, and Linux guests. Use when Codex needs to run, rerun, debug, or interpret VM-based install, onboarding, gateway smoke tests, latest-release-to-main upgrade checks, fresh snapshot retests, or optional Discord roundtrip verification under Parallels.