setup-ts-deep-modules
यह क्या करती है
यह एक dependency जांचने वाला टूल और ऐसे नियम इंस्टॉल करती है जो कोड को पैकेज के छिपे हिस्सों तक पहुंचने से रोकते हैं। यह उन डेवलपर्स के लिए है जो कई पैकेज वाले TypeScript प्रोजेक्ट पर काम करते हैं।
कब इस्तेमाल करें
- ✓जब आप चाहते हों कि TypeScript रिपॉज़िटरी में हर पैकेज का एक छोटा सार्वजनिक इंटरफ़ेस हो।
- ✓जब दूसरा कोड ऐसी आंतरिक फ़ाइलें इंपोर्ट करता रहे जिन्हें उसे छूना नहीं चाहिए।
- ✓जब आप ऐसे नियम चाहते हों जो गलत इंपोर्ट अपने-आप पकड़ लें।
Skill का लिंक
https://github.com/mattpocock/skills/blob/main/skills/in-progress/setup-ts-deep-modules/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“हमारी TypeScript रिपॉज़िटरी ऐसे सेट कीजिए कि दूसरे पैकेज केवल हर पैकेज की entry फ़ाइलों से ही इंपोर्ट कर सकें।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट dependency-cruiser इंस्टॉल करता है और चार error नियम जोड़ता है, फिर जांचता है कि नियम असली उल्लंघन पकड़ते हैं। इम्प्लीमेंटेशन कोड lib फ़ोल्डर में और टेस्ट tests फ़ोल्डर में रहते हैं।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Setup TS Deep Modules
Make every package in this repo a deep module: a lot of behaviour behind a small interface. A package's public surface is its entry points (the files at the package root), and everything in its subfolders is hidden. This skill installs dependency-cruiser and the rules that make the entry points the only way in, then proves the rules bite.
For the vocabulary (deep module, interface, seam, depth), call the Skill tool with "codebase-design" and use its language throughout.
The shape this enforces
src/packages/
<name>/
index.ts ← an entry point (public). Import this from outside.
client.ts ← another entry point. Packages may expose SEVERAL.
lib/ ← implementation: hidden from outside, free to import each other.
tests/ ← co-located tests + fixtures (a subfolder, so private).
The public surface is the package's root files, not one designated index.ts. By convention implementation lives in lib/ and tests in tests/, giving every package the same two-folder shape. The rule itself is general, though: anything in any subfolder is private, so you never extend the config to add a folder.
Four rules, all error:
- Entry-point boundary: code outside a package (app code or another package) may import only that package's entry points (its root files), never anything in its subfolders.
- Intra-package freedom: a package's own files import each other freely.
- Tests through the entry points: files under
<pkg>/tests/may import any package's entry points and their owntests/fixtures, but never any package's subfolder internals (not even their own). Integration tests across packages are fine; deep imports are not. - No cycles: no dependency cycles.
Entry points, not a barrel. Because the public surface is every root file, a package can expose several small entry points (index.ts, client.ts, server.ts) instead of funnelling everything through one giant index.ts. Barrel files that re-export a whole subtree are discouraged; keep entry points small and hide implementation in subfolders.
Layering (which packages may depend on which) is a different concern and is left as a commented stub in the config for this repo to fill in.
Steps
1. Detect the environment
- Package manager:
pnpm-lock.yaml→ pnpm,yarn.lock→ yarn,bun.lockb→ bun, else npm. Use it for every command below (pnpm/yarn/npm run/bunx). - Packages root: if
src/exists usesrc/packages, elsepackages. Confirm the choice with the user if the repo already has a different obvious convention. - Existing config: check for a
.dependency-cruiser.*file. If one exists, do not overwrite it: merge the four rules and the options in, and tell the user what you added.
Done when: package manager, packages root, and existing-config status are all known.
2. Install dependency-cruiser
Install dependency-cruiser as a devDependency with the detected package manager.
Done when: dependency-cruiser is in devDependencies.
3. Write the config
Copy dependency-cruiser.config.cjs to the repo root as .dependency-cruiser.cjs. Set PACKAGES_ROOT to the root detected in step 1. The rules are path-depth based and extension-agnostic, so nothing else needs adapting.
Done when: .dependency-cruiser.cjs exists with the correct PACKAGES_ROOT, and the four forbidden rules are present.
4. Wire it into the checks
- Add a
lint:boundariesscript:depcruise <packages-root>(ordepcruise src). - Fold it into the repo's umbrella check command, the one that already runs typecheck (e.g. a
check/ci/validatescript). Do not touchtsconfigor add path aliases. - If there is no umbrella script, add
lint:boundariesand tell the user to include it in CI.
Done when: lint:boundaries exists and runs as part of the same command as typecheck.
5. Scaffold the example package
Create a committed <packages-root>/example/ as a copy-me template:
index.tsis an entry point. Export one function that delegates to an internal file (so the package is visibly deep, not a pass-through).lib/impl.ts: an internal file in a subfolder, imported byindex.ts, not reachable from outside.tests/example.test.tsimports only../index(an entry point) and asserts ag
अक्सर पूछे जाने वाले सवाल
यह कौन-सा टूल इंस्टॉल करती है?
यह dependency-cruiser इंस्टॉल करती है, जो जांचता है कि कोड फ़ाइलें एक-दूसरे को कैसे इंपोर्ट करती हैं।
बाहरी कोड से कौन-से फ़ोल्डर छिपे रहते हैं?
किसी पैकेज के सब-फ़ोल्डर, जैसे lib और tests, निजी माने जाते हैं।
क्या स्किल जांचती है कि नियम काम करते हैं?
हां। यह जांचती है कि नियम सच में एक उल्लंघन पकड़ते हैं, ताकि आप जान सकें कि वे काम कर रहे हैं।
जानकारी
लेखक का मूल विवरण
Wire dependency-cruiser into a TypeScript repo so each package is a deep module, with implementation hidden in subfolders and reachable only through its entry-point files. User-invoked.
repo: mattpocock/skills
लोकप्रियता
- GitHub स्टार
- 310k
- रैंकिंग में स्थान
- #115
- लाइसेंस
- MIT
- अपडेट की गई
- 1/11/2026
कमेंट
- …
इस repository की और skills
ask-matt
310kयह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।
code-review
310kयह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।
domain-modeling
310kयह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।
implement-spec
310kएक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।
मिलती-जुलती skills
diffs
394kयह आपके एजेंट को बदलावों का असली diff बनाने देती है, जिसे व्यूअर लिंक या इमेज फ़ाइल के रूप में साझा किया जा सकता है, हाथ से लिखे सारांश के बजाय।
coding-agent
394kयह आपके एजेंट को बड़े कोडिंग काम Codex, Claude Code या OpenCode को बैकग्राउंड वर्कर के रूप में सौंपने, फिर उसकी प्रगति जांचने में मदद करती है।
gh-issues
394kयह आपके एजेंट को GitHub issues खोजने, उनमें से काम करने लायक चुनने, और सुधार के साथ pull requests खोलने में मदद करती है, जिसमें समीक्षा टिप्पणियों का फ़ॉलो-अप भी शामिल है।