feature-slicing/SKILL.md
Apply Feature-Sliced Design (FSD) architecture when creating or modifying frontend code. Routes code to correct layers (app/pages/widgets/features/entities/shared) and enforces strict downward-only import rules. Use when creating components, pages, features, or restructuring React/Next.js/Vue/Remix projects. Do NOT use for backend services, non-UI libraries, single-file scripts, or projects with fewer than 5 components.
npx skillsauth add sanurb/skills feature-slicingInstall 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.
Apply FSD layer hierarchy and import rules when creating or modifying frontend code. Organizes code by business domain, not technical role.
Determine where the code belongs:
Where does it go?
├─ Reusable infrastructure, no business logic? → shared/
├─ Business domain data model (noun)? → entities/{name}/
├─ User interaction with business value (verb)?
│ ├─ Reused across pages → features/{name}/
│ └─ Single page only → pages/{page}/ (keep in page slice)
├─ Complex reusable UI composition? → widgets/{name}/
├─ Full page / route component? → pages/{name}/
└─ App-wide config, providers, routing? → app/
Entity vs Feature: Entities are THINGS with identity (user, product, order). Features are ACTIONS with side effects (auth, add-to-cart, checkout).
Minimal setup: Start with app/, pages/, shared/. Add entities/, features/, widgets/ as complexity grows.
Place code in purpose-driven segments within the slice:
| Segment | Contents |
|---------|----------|
| ui/ | React components, styles |
| api/ | Backend calls, data fetching, DTOs |
| model/ | Types, schemas, stores, business logic |
| lib/ | Slice-specific utilities |
| config/ | Feature flags, constants |
Expose a public API via index.ts with explicit named exports:
// entities/user/index.ts
export { UserCard } from './ui/UserCard';
export { getUser } from './api/userApi';
export type { User } from './model/types';
For cross-entity references, use @x/ notation — see public-api.md.
Check that all imports flow strictly downward:
app → pages → widgets → features → entities → shared
| Violation | Fix |
|-----------|-----|
| Cross-slice (same layer): features/a → features/b | Extract shared logic to entities/ or shared/ |
| Upward: entities/user → features/auth | Move shared code to a lower layer |
| shared/ importing from any layer | Shared has zero internal deps — only external packages |
| Direct internal import: @/entities/user/ui/UserCard | Import from public API: @/entities/user |
index.ts with explicit named exports. No wildcard re-exports (export *).ui/, api/, model/). Never generic (components/, hooks/, types/).index.ts only, never from internal paths.shared/ contains zero business domain logic.app/ and shared/ have no slices (internal cross-segment imports are allowed within them).Created/modified files placed in the correct layer → slice → segment with a valid index.ts public API. All imports validated against the layer hierarchy.
| File | When to read | |------|-------------| | layers.md | Detailed layer specs when routing is ambiguous | | public-api.md | @x cross-entity notation, tree-shaking, barrel files | | implementation.md | Code patterns: entities, features, widgets with React Query | | nextjs.md | Next.js App Router / Pages Router integration | | migration.md | Migrating a legacy codebase to FSD incrementally | | cheatsheet.md | Quick reference, import matrix |
development
Sets up an `## Agent skills` block in AGENTS.md/CLAUDE.md and `docs/agents/` so the engineering skills know this repo's issue tracker (GitHub, GitLab, fp, or local markdown), triage label vocabulary, and domain doc layout. Run before first use of `fp-plan`, `fp-implement`, `fp-review`, `to-issues`, `to-prd`, `triage`, `diagnose`, `tdd`, `improve-codebase-architecture`, or `zoom-out` — or if those skills appear to be missing context about the issue tracker, triage labels, or domain docs.
development
Build a throwaway prototype to flush out a design before committing to it. Routes between two branches — a runnable terminal app for state/business-logic questions, or several radically different UI variations toggleable from one route. Use when the user wants to prototype, sanity-check a data model or state machine, mock up a UI, explore design options, or says "prototype this", "let me play with it", "try a few designs".
tools
Control herdr (a terminal-native agent multiplexer) from inside it. Manage workspaces and tabs, split panes, spawn sibling agents, read pane output, and wait for state changes — all via CLI commands that talk to the running herdr instance over a local unix socket. Use when running inside herdr (HERDR_ENV=1). Do not use outside herdr.
documentation
Compact the current conversation into a handoff document for another agent to pick up.