lib-layers

Enforces layered library import boundaries and barrel re-export rules in Nx monorepos.

1|Updated Jan 14, 2024
One-click install
npx skills add https://github.com/Eyhenij/rt-tools --skill lib-layers-eyhenij
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: lib-layers
Source: https://github.com/Eyhenij/rt-tools/tree/main/.claude/skills/lib-layers
Command: npx skills add https://github.com/Eyhenij/rt-tools --skill lib-layers-eyhenij

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Monorepos with many internal libraries drift into tangled imports, hidden re-exports, and unchecked dependency cycles. This Skill encodes the concrete rules for who may import whom, where shared symbols must live, and how barrels, tags, and boundary configs are kept consistent. ## Core Features & Use Cases - Layer and boundary rules: Defines the layer ladder (api, data-access, feature, shell, ui, util), tag naming, and how missing import rights are added as commented lines in ESLint boundary configs. - Re-export and cycle detection guidance: Forbids both forms of foreign-symbol re-export in barrels and explains how import cycles start through directory barrels and how to break them with direct file imports or tokens. - Use Case: When adding a shared symbol used by two domains, follow the flowchart to decide whether it belongs in the family base or a domain, add the boundary line with a reason, and verify the check by introducing a deliberate violation. ## Quick Start Ask the assistant to apply the lib-layers rule to decide where a new shared symbol should live and which boundary config line to add.

Frequently Asked Questions about lib-layers

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

FAQPage Schema
How do I enforce import boundaries between libraries in an Nx monorepo?

Assign each lib a scope tag derived from its path, then declare allowed edges as commented lines in per-domain ESLint boundary config files. A missing import right is added explicitly with a reason rather than relying on an import that just worked.

How do I decide where a shared symbol should live in a monorepo?

Symbols about a subject live in that subject's domain; mechanics shared by several domains live in the family base, not a new domain. If the import is not permitted, either add the boundary line with a reason or move the symbol where both sides can see it.

Why are re-exports of foreign symbols forbidden in barrels?

Both export-from of a foreign module and the import-then-export pair hide the true origin of a symbol and bypass boundary checks. Barrels may only expose their own lib's files, via relative paths or the lib's own alias.

How do import cycles start through index.ts barrels?

A cycle starts when a file imports its neighbor through the directory's index.ts, which itself re-exports the importing file. Break it with a direct file import, move shared types to their own file, or replace parent injection with a token.

Why is a green lint run not enough to accept a boundary check?

Checks without tests can silently pass while doing nothing. Acceptance requires introducing a deliberate violation, watching the run turn red, then reverting the edit to prove the check actually fires.