1.3 KiB
1.3 KiB
name, description, license, triggers
| name | description | license | triggers | |||
|---|---|---|---|---|---|---|
| module-encapsulator | Groups related components, hooks, and types into feature-based modules (e.g., `modules/endorsements`) to improve encapsulation and reuse. | MIT |
|
Module Encapsulator
When to use this skill
- Use when several components, hooks, and types belong to a single feature and should be colocated.
- Triggered by requests to organize code by feature boundary rather than only by technical layer.
Instructions
-
First Step: Propose a module layout (e.g.,
src/modules/endorsements/{components,hooks,types,services}) and create anindex.tsto re-export public APIs. -
Second Step: Move or copy existing files into the module, update imports to use the module boundary (e.g.,
@/modules/endorsements). -
Third Step: Add tests and README.md inside the module describing its public surface and example usage.
Examples
- Module index:
export * from './components/EndorseButton'; export * from './hooks/useEndorsements';
Additional Resources
- Feature folder discussion: https://redux.js.org/style-guide/style-guide#structure
Notes
- Maintain clear public/private API: only
index.tsexports become public; internal helpers remain in the module scope.