setup-ts-deep-modules
Skill8 starsChanged 2 months agoMITView on GitHub
Enforce TypeScript package boundaries, entry points, and cyclic dependency rules with dependency-cruiser. Use when structuring monorepo packages, establishing public API entry points, or preventing circular imports — even if the user says \"fix TS package boundaries\". Do NOT use for non-TypeScript repositories.
We split this skill into the rules it gives an agent
8 rules. 0 are common, 1 is distinctive, and 7 are very specific to this project.
0
Common
Most of the 43 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 17
Mandatory Biting Proof: Before completing setup, deliberately introduce a forbidden deep import to verify that lint:boundaries fails fast.
- Very specific: line 46
Key Point: Check for existing .dependency-cruiser.* configuration to merge rules rather than overwriting.
- Very specific: line 51
Key Point: Use .cjs extension so CommonJS exports function seamlessly in ESM / "type": "module" projects.
- Very specific: line 58
Action: Add "lint:boundaries": "depcruise <packages-root>" to package.json and create an example deep package:
- Very specific: line 66
Run lint:boundaries $\rightarrow$ must PASS on clean repo.
- Very specific: line 67
Add deep import import { impl } from "../lib/impl" in test $\rightarrow$ must FAIL.
- Distinctive: line 69
Key Point: Never sign off on boundary rules without observing an intentional test failure.
- Very specific: line 73
Action: Create <packages-root>/README.md explaining layout and rules, and add a single-line context pointer in AGENTS.md / CLAUDE.md.
“Common” is measured: kept by at least 6 in 10 of the 43 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Setup TS Deep Modules
Configure and verify strict deep-module boundaries across TypeScript packages using dependency-cruiser, ensuring public interfaces exist exclusively at package root files while private implementations remain sealed inside subdirectories.
Core Invariants
- Root Files as Exclusive Entry Points: External callers and consumers may only import package root files (
index.ts,client.ts,server.ts); all subdirectories (lib/,internal/,tests/) are private. - Four Strict Dependency Rules: Enforce (1) Entry-point boundary, (2) Intra-package internal freedom, (3) Tests import entry-points only, (4) Zero dependency cycles.
- Barrels Strongly Discouraged: Expose focused, multiple root entry points instead of giant barrel files that re-export whole subtrees.
- Mandatory Biting Proof: Before completing setup, deliberately introduce a forbidden deep import to verify that
lint:boundariesfails fast. - No Speculative Path Aliases: Wire boundary checks directly through dependency-cruiser rather than altering
tsconfig.jsonpaths or building complex build-time layers.
Architecture & Map of Content (MOC)
src/packages/
<package-name>/
index.ts ◄── Public Entry Point (exported to other packages)
client.ts ◄── Additional Public Entry Point
lib/ ◄── Private Implementation (sealed from outsiders)
tests/ ◄── Tests (import only root entry points)| Rule | Enforcement | Target |
| Entry Boundary | not-to-subfolder | Outside code $\rightarrow$ root files only |
| Test Boundary | tests-through-entrypoints | tests/ $\rightarrow$ root entry points only |
| Cycle Prevention | no-circular | Disallow all circular dependencies |
| Verification Gate | lint:boundaries script | Automated CI failure on breach |
Step-by-Step Procedure (TWI)
Step 1: Detect Environment & Package Manager
- Action: Detect the package manager (
bun.lockb$\rightarrow$ bun,pnpm-lock.yaml$\rightarrow$ pnpm,yarn.lock$\rightarrow$ yarn, else npm) and locate the packages root (src/packagesorpackages). - Key Point: Check for existing
.dependency-cruiser.*configuration to merge rules rather than overwriting. - Why: Preserving existing project package manager standards ensures zero friction with current CI scripts.
Step 2: Install and Configure Dependency Cruiser
- Action: Install
dependency-cruiseras a devDependency and copydependency-cruiser.config.cjsto.dependency-cruiser.cjswith updatedPACKAGES_ROOT. - Key Point: Use
.cjsextension so CommonJS exports function seamlessly in ESM /"type": "module"projects. - Inline Checklist:
- Package manager identified correctly
dependency-cruiseradded todevDependencies.dependency-cruiser.cjsconfigured with 4 core rules
Step 3: Wire Scripts & Scaffold Clean Example
- Action: Add
"lint:boundaries": "depcruise <packages-root>"topackage.jsonand create an example deep package:<packages-root>/example/index.ts(public entry point delegating tolib/)<packages-root>/example/lib/impl.ts(hidden implementation)<packages-root>/example/tests/example.test.ts(imports../index)
- Why: A reference package serves as living documentation and a starter template for developers.
Step 4: Prove the Rules Bite (Verification Gate)
- Action: Execute three validation passes:
- Run
lint:boundaries$\rightarrow$ must PASS on clean repo. - Add deep import
import { impl } from "../lib/impl"in test $\rightarrow$ must FAIL. - Revert deep import and run
lint:boundaries$\rightarrow$ must PASS.
- Run
- Key Point: Never sign off on boundary rules without observing an intentional test failure.
- Why: Unproven linter configs frequently have syntax or glob errors that silently pass all code.
Step 5: Document Package Conventions & Agent Pointer
- Action: Create
<packages-root>/README.mdexplaining layout and rules, and add a single-line context pointer inAGENTS.md/CLAUDE.md. - Key Point: Explicitly explain why barrel files are discouraged.
- Why: Agent pointers ensure future autonomous sessions respect package boundaries from their first prompt.
Anti-Rationalization Guardrails
| Tempting Rationalization | Binding Rule | Engineering Rationale |
| "Skip testing whether the rule fails on bad imports." | Mandatory 3-step proof (Pass $\rightarrow$ Fail $\rightarrow$ Pass). | Linters with invalid glob configurations pass silently without enforcing anything. |
| "Export all submodules through a giant root index.ts barrel." | Discourage large barrel files. | Giant barrels destroy tree-shaking and create hidden cyclic import dependencies. |
| "Import directly from lib/ in unit tests for convenience." | Enforce tests through public entry points only. | Deep imports in tests tightly couple test suites to volatile internal refactors. |
Other versions49 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 49
- mattpocock/skills★ 309ksame name
- vinvcn/mattpocock-skills-zh-CN★ 5.5ksame name
- devcxl/mattpocock-skills-zh★ 522same name
- loulanyue/skills★ 231same name
- tt-a1i/matt-skills-with-to-goal★ 192same name
- VoDaiLocz/kilo-kit-mcp★ 28same name
- WenWuZhiDao/mattpocock-skills-zh★ 27same name
- ivanrvpereira/.agents★ 19same name
- George-RD/design-studio★ 10same name
- caterpi11ar/giclaw★ 9same name
39 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use batch-grill-me, chief-of-staff and 2 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
boyingliu01Skillbatch-grill-me
A relentless interview that asks every frontier question at once, round by round. Thin alias of `grilling` (#540) — upstream mattpocock/skills absorbed this protocol into grilling; XP-Gate keeps this name as the sprint-flow Phase 2 entry point so orchestration docs stay stable.
Also in 5 projects that use this
getnaoSkillchief-of-staff
Also in 9 projects that use this
GitHubSkillsetup-skills
Configures shared sources and drafts context with independent writers. Plain/fresh setup offers installation of user-named packages and reuses built-in browser capabilities, adding browser tooling only for an evidenced required-check gap. Use for setup, source repair, writing context or refreshing drafts. Configure-only skips tooling and authoring; installations and activation require separate approval.
Also in 3 projects that use this
VercelSkillfind-skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
Also in 3 projects that use this
In this repository42 other files it gives its agents.
- AGENTS.mdAGENTS.md
- ai-data-remediationSkill
- ai-engineeringSkill
- codebase-designSkill
- code-reviewSkill
- diagnosing-bugsSkill
- domain-modelingSkill
- engineering-workflow-guideSkill
- git-safety-guardrailsSkill
- goalSkill
- grillingSkill
- grill-meSkill
- grill-with-docsSkill
- handoffSkill
- implementSkill
- implement-specSkill
- improve-codebase-architectureSkill
- j-spaceSkill
- migrate-to-shoehornSkill
- ml-best-practicesSkill
- prototypeSkill
- researchSkill
- resolving-merge-conflictsSkill
- retroSkill
- scaffold-exercisesSkill
- setup-engineering-workflowsSkill
- setup-pre-commitSkill
- skill-conductorSkill
- tddSkill
- teachSkill
- to-questionnaireSkill
- to-specSkill
- to-ticketsSkill
- triageSkill
- wait-whatSkill
- wayfinderSkill
- wizardSkill
- workflow-designerSkill
- writing-beatsSkill
- writing-for-agentsSkill
- writing-fragmentsSkill
- writing-shapeSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

