import-boundaries

Enforces layered import direction and feature-domain boundaries in a React component library.

10|3|Updated Oct 23, 2023
One-click install
npx skills add https://github.com/Layer-Fi/layer-react --skill import-boundaries-layer-fi
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: import-boundaries
Source: https://github.com/Layer-Fi/layer-react/tree/main/src
Command: npx skills add https://github.com/Layer-Fi/layer-react --skill import-boundaries-layer-fi

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Large React codebases decay when modules import freely across architectural layers, producing circular dependencies, untestable components, and unpredictable refactors. This Skill documents the twelve-layer import stack and per-domain import partitions of the Layer component library so contributors know which direction imports may point and how to resolve a lint-reported boundary violation. ## Core Features & Use Cases - Layer stack reference: Defines twelve layers from foundation (schemas, utils) up to the app root, with the rule that files may import only from strictly lower layers, and explains non-obvious placements such as context below generic hooks and stores below feature hooks. - Boundary error triage: Provides a decision procedure for fixing violations — move shared code down a layer, pass computed values as props, or relocate the file to the correct layer — instead of reaching for eslint-disable. - Feature-domain partitions: Lists the five domain-partitioned directory trees (schemas, components, hooks, providers, utils) with each partition's declared shared-domain set, plus import-order and translation-key ownership rules driven by the same alias table. - Use Case: A developer adds a hook that reads a Zustand store and an SWR endpoint, and the lint run fails. The Skill explains that this is a layer-5 store hook belonging under providers/features, not a layer-6 feature hook, and shows how to restructure the import. ## Quick Start Ask the AI to review a new cross-module import in the src tree against the layer stack and domain partitions, and to propose the correct fix for any boundary violation it finds.

Frequently Asked Questions about import-boundaries

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix an import boundary lint error in a layered React codebase?▼

Identify which of three cases applies: the imported helper belongs in a lower layer and should be moved down, the value is computed by a higher layer and should be passed as a prop, or the file itself sits in the wrong layer. Using eslint-disable hides the question rather than answering it.

What is the correct way to share code between feature domains?▼

A domain may import only itself plus its partition's declared shared set. To allow a new cross-domain import, either move the shared code down a layer or add the target domain to that partition's shared set in the eslint config table.

Why does context sit below generic hooks in the layer stack?▼

The SWR hook factories call useAuth and useBuildKeyInputs, which read LayerContext. Placing injected config at layer 2 below the factories keeps all endpoint hooks pointing downward; putting context above would make every factory import upward.

Are test files exempt from import boundary rules?▼

Yes. Test, spec, and story files are exempt from both boundary rules because tsconfig.build.json excludes them from the shipped artifact. The reverse rule still holds: production source may not import test utilities, fixtures, or story modules.

When should a Zustand store hook live under providers instead of hooks/features?▼

A hook that reads both a store and an endpoint is a layer-5 store hook, not a layer-6 feature hook. It belongs beside the store it feeds under providers/features/<domain>/, regardless of which directory it currently sits in.