fe-modularization
БесплатноБез исполняемых скриптовНе проверенDeciding where frontend code lives — tier model, move mechanics, extension points, side effects, naming, and the traps. Use when moving code between modules…
от metabase★ 50 742 звезды на GitHubОб этом скилле
Frontend modularization
The module is the unit of blast radius: dependency direction, test selection, bundle cones, and review scope all follow module boundaries. Every decision here serves one goal: make the file locations tell the truth about who owns what and who may depend on whom.
Hard rules (check these before anything else)
- NEVER add an
export … fromre-export at an old path, and NEVERexport *from a barrel. Move the code, codemod every call site, delete the old path, all in the same PR. - NEVER import past a module's
index.tswhen that module hasenforcePublicApi: true, and never pastmetabase/ui's index at all. If the barrel is heavy, the fix is making the module side-effect free (below), not a deep import. - NEVER rewrite a consumer to a lower-level idiom to make the linter pass. If the fix makes the consumer worse, the plan is wrong.
- NEVER give a new module
enforceSharedTiers: false; new modules ship enforced withenforcePublicApi: trueand an explicitindex.ts. - NEVER move code without the consumer-tier check (procedure step 2).
- ALWAYS delete a module's
enforceSharedTiers: falseline in the PR that takes it to zero violations. - ALWAYS measure
bun run module-boundariesbefore and after, and report the numbers. - ALWAYS import
dayjsfrommetabase/dayjs, routing frommetabase/router, Mantine frommetabase/ui, react-redux hooks frommetabase/redux; the raw specifiers are lint-forbidden.
Files that are ground truth
| what | where |
|---|---|
module elements, tiers, enforceSharedTiers, enforcePublicApi |
frontend/lint/module-boundaries.mjs |
| shared sub-tiers and levels, cluster rules | frontend/lint/shared-tiers.mjs |
| standalone boundaries lint (all violations, incl. grandfathered) | bun run module-boundaries (config eslint.config.module-boundaries.mjs) |
| PR lint (only enforced modules fail CI) | bun run lint-oxlint-pure |
| side-effect-free directories and their exceptions | frontend/build/shared/rspack/side-effect-free-modules.js (SIDE_EFFECT_FREE_PATHS, SIDE_EFFECT_PATHS) |
| the lint rules that enforce that promise | metabase/no-module-side-effects, metabase/no-base-api-access in frontend/lint/eslint-plugin-metabase/rules/ |
| public-api enforcement | metabase/enforce-module-public-api rule, driven by getPublicApiModules() |
The model
Tiers: lib < basic < shared < feature < app. Imports point downward, never
sideways at feature tier (features may not import features; app and EE may
import anything). The shared tier is subdivided in shared-tiers.mjs into
shared-utils (U0…), shared-platform (P0…), and shared-domain, each ordered
into levels. A module imports only strictly lower levels of its sub-tier
plus the sub-tiers below; same-level peers are deliberately forbidden, which
is what makes cycles structurally impossible. A domain may hold two seats
when consumers demand it: a low core and a high surface (metabase-lib below
questions below query_builder; viz-core below visualizations).
Enforcement is per module: enforceSharedTiers: false on an element exempts
it from the level rules (counted by bun run module-boundaries, invisible to
PR lint). Modules with enforcePublicApi: true may only be imported from
outside via metabase/<module>, and import relatively inside.
Deciding where code lives (apply in order; first decisive test wins)
- Who owns the concept? Code lives with the module that owns its concept, not the module that renders or calls it. A mode encoding dashboard click behaviour is dashboard code even if viz executes it. Metabot conversation state is metabot state even though the store registers it.
- Consumer-tier check. The destination must sit at or below the file's lowest consumer. A single consumer below the proposed home vetoes the move; report it, don't force it.
- Only four legitimate fixes for a bad edge: move the code to its terminal home; invert through a designed extension point (a prop, an injected component, a contract type owned by the socket); fix the tier placement when the declared level is wrong; delete a thin wrapper (a rename with no derivation isn't an abstraction — deleting it is the migration).
- A bridge lives above the lower endpoint. Code that needs both sides of a boundary belongs in or above the higher module.
- "Genuinely shared" is proven by consumers. A shared address needs two or more consumers the tier rules can't serve another way. One consumer pretending to be shared is a feature module at the wrong address.
Extension points
The socket's owner defines the contract; every plug lives with its extender.
Visualization owns the mode prop and click interfaces, each surface supplies
its mode; the editor owns its extension contract, metabot supplies tiptap
extensions; querying owns TemplateTagsSidebarProps, parameters implements
it.
- Prefer plain props/
Установить fe-modularization в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл fe-modularization?
Deciding where frontend code lives — tier model, move mechanics, extension points, side effects, naming, and the traps. Use when moving code between modules, carving new modules, fixing boundary violations, adding a barrel or an endpoint, or reviewing module-shape decisions.
Как установить скилл fe-modularization?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл fe-modularization запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic