Agent skill
feature-slicing
Apply Feature-Sliced Design (FSD) architecture to frontend projects. Use when creating new frontend features, components, pages, or restructuring existing code. Triggers on tasks involving React/Next.js/Vue project organization, layer architecture, feature isolation, module boundaries, or when user mentions FSD, feature slicing, or scalable frontend structure.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/feature-slicing-ccheney-robust-skills-5260dd24
SKILL.md
Feature-Sliced Design Architecture
Overview
Feature-Sliced Design (FSD) is an architectural methodology for scaffolding frontend applications with rules and conventions for organizing code to remain understandable and stable amid changing business requirements.
Official Documentation: https://feature-sliced.design/llms.txt
Core Principles
-
Layers - 7 standardized horizontal levels (top to bottom):
app/→ routing, entrypoints, global styles, providersprocesses/→ (deprecated) complex cross-page scenariospages/→ full pages or nested routing sectionswidgets/→ self-contained UI blocks delivering complete use casesfeatures/→ reused product functionality with business valueentities/→ business domain objects (user, product, order)shared/→ reusable, project-detached functionality
-
Import Rule - Modules can only import from layers strictly below them. Never import sideways or upward.
-
Slices - Business-domain partitions within layers (e.g.,
user,product,cart). Cannot reference other slices at the same layer. -
Segments - Purpose-based groupings within slices:
ui/→ components, formatters, stylesapi/→ backend interactions, data typesmodel/→ schemas, stores, business logiclib/→ slice-specific utilitiesconfig/→ feature flags, configuration
-
Public API - Each slice exposes functionality via
index.tsbarrel file.
Quick Reference Structure
src/
├── app/ # Layer: Application initialization
│ ├── providers/ # Context providers, store setup
│ ├── routes/ # Router configuration
│ └── styles/ # Global styles
├── pages/ # Layer: Route-based screens
│ └── {page-name}/
│ ├── ui/
│ ├── api/
│ └── index.ts # Public API
├── widgets/ # Layer: Complex reusable blocks
│ └── {widget-name}/
│ ├── ui/
│ └── index.ts
├── features/ # Layer: User interactions
│ └── {feature-name}/
│ ├── ui/
│ ├── api/
│ ├── model/
│ └── index.ts
├── entities/ # Layer: Business entities
│ └── {entity-name}/
│ ├── ui/
│ ├── api/
│ ├── model/
│ └── index.ts
└── shared/ # Layer: Shared infrastructure
├── ui/ # UI kit, design system
├── api/ # API client, request functions
├── lib/ # Utilities (dates, validation)
├── config/ # Environment, constants
└── i18n/ # Internationalization
When Implementing FSD
- Creating a new feature: Place in
features/if reused across pages, otherwise keep inpages/ - Creating a new entity: Place in
entities/withui/,api/,model/segments - Creating shared utilities: Place in
shared/lib/orshared/ui/ - Integrating with Next.js: Place App Router in
src/app/(no rootapp/), which serves as both routing and FSD app layer
Reference Documentation
For detailed implementation guidance, consult these reference files:
- Layer Details - Complete layer specifications and guidelines
- Public API Patterns - Export patterns, barrel files, cross-imports
- Implementation Patterns - Code examples, entity/feature patterns
- Next.js Integration - App Router and Pages Router setup
- Migration Guide - Migrating existing projects to FSD
- Cheatsheet - Quick decision guide and common patterns
Key Anti-Patterns to Avoid
- Importing from higher layers (breaks unidirectional flow)
- Cross-slice imports at the same layer (use lower layers instead)
- Generic segment names like
components/,hooks/,types/ - Wildcard exports (
export * from) in public APIs - Storing business logic in
shared/layer
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?