setup-ts-deep-modules

Configures dependency-cruiser to enforce deep-module import boundaries in TypeScript packages.

Updated May 9, 2024
One-click install
npx skills add https://github.com/AceCodePt/dotfiles --skill setup-ts-deep-modules-acecodept
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: setup-ts-deep-modules
Source: https://github.com/AceCodePt/dotfiles/tree/main/.config/opencode/flows/setup-ts-deep-modules
Command: npx skills add https://github.com/AceCodePt/dotfiles --skill setup-ts-deep-modules-acecodept

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires dependency-cruiser.

What problem does it solve? TypeScript monorepos often leak internal implementation details because any file can import any other file, making packages shallow and tightly coupled. This Skill wires dependency-cruiser into a repo so each package becomes a deep module: implementation hidden in subfolders, reachable only through entry-point files at the package root. ## Core Features & Use Cases - Boundary rule installation: Copies a ready-made dependency-cruiser config with four error-level rules covering entry-point boundaries, intra-package freedom, tests-through-entrypoints, and cycle detection. - Environment detection: Detects the package manager (pnpm, yarn, bun, npm), the packages root (src/packages or packages), and merges into any existing dependency-cruiser config instead of overwriting it. - Proof the rules bite: Scaffolds an example package, then verifies the lint passes, fails on a deliberately added deep import, and passes again after reverting. - Use Case: A team adopting a packages/ monorepo wants to stop cross-package deep imports like import x from "other-pkg/lib/impl"; this Skill installs the rules, adds a lint:boundaries script to the existing check command, and documents the convention in the packages README. ## Quick Start Ask the agent to set up deep-module import boundaries with dependency-cruiser for this TypeScript repo and prove the rules fail on a deep import.

Frequently Asked Questions about setup-ts-deep-modules

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

FAQPage Schema
How do I enforce import boundaries between packages in a TypeScript monorepo?▼

Use dependency-cruiser with forbidden rules that block imports into package subfolders from outside the package. This Skill installs a config where only a package's root entry-point files are importable, and adds a lint:boundaries script to your existing check command.

How to set up dependency-cruiser in a pnpm or npm project?▼

Install dependency-cruiser as a devDependency with your detected package manager, then create a .dependency-cruiser.cjs config at the repo root. The Skill detects pnpm, yarn, bun, or npm from lockfiles and uses .cjs so the config works in type: module repos.

Can a package expose multiple entry points instead of one index.ts?▼

Yes. The public surface is every root file of the package, so you can expose several small entry points like index.ts, client.ts, and server.ts. Barrel files that re-export a whole subtree are discouraged in favor of small entry points.

Does dependency-cruiser work with an existing configuration file?▼

Yes. If a .dependency-cruiser config already exists, the Skill merges the four boundary rules and options into it rather than overwriting, and reports what was added.

Why does the boundary lint not fail on deep imports?▼

The rules are not wired correctly if a deep import passes. The Skill's completion criterion requires observing a pass on clean code, a failure on a temporary deep import, and a pass again after reverting; if the failure never occurs, the config paths or PACKAGES_ROOT need fixing.