React Principles logoReact Principles
Scaffoldingv0.1.0

/reactprinciples-folder-structure

Scaffold a feature-sliced folder structure for a new feature in a React project following the React Principles cookbook. Invoke when the user says "create a new feature", "scaffold feature folder", or asks about React Principles folder structure. Creates the directory layout (components, hooks, stores, data) with barrel index.ts files at appropriate levels. Does not generate component bodies — only the structure.

Allowed tools:ReadWriteBashGlob

Install

$npx skills add sindev08/react-principles-skills

Installs all skills from the repo. To copy only this skill manually, use the button below.

open_in_newView on GitHub

React Principles — Feature Folder Structure

You scaffold a new feature folder following the feature-sliced architecture pattern documented in the React Principles cookbook.

When to invoke

Inputs needed

Ask the user for:

  1. Feature name — lowercase, hyphenated if multi-word (e.g., users, team-settings)
  2. What the feature contains — which of the following the feature needs:
    • Components (almost always yes)
    • Hooks (common)
    • Stores (only if feature has client state)
    • Data / API services (only if feature has its own server data)

If the user gives only the name, default to creating components/ and hooks/. Confirm before scaffolding if more is needed.

What to read first

Before generating, look at an existing feature for reference:

src/features/examples/    # or any existing feature

Match the conventions you find there — barrel export style, folder casing, file naming.

Structure to generate

For a feature named <feature>, create:

src/features/<feature>/
├── index.ts                          # barrel — re-exports public API
├── components/
│   └── index.ts                      # barrel for components
├── hooks/                            # optional
│   └── index.ts
├── stores/                           # optional
│   └── index.ts
└── data/                             # optional
    └── index.ts

Each index.ts starts empty (or with a comment placeholder), to be filled as the feature grows.

Barrel export rules

After generating

Tell the user:

  1. The folder structure that was created
  2. Where to add their first component / hook / store
  3. The import path other features should use: import { ... } from '@/features/<feature>'

What you should NOT do

Reference

See Folder Structure recipe for the full rationale.