मुख्य सामग्री पर जाएँ
Skillpedia
सामान्य कोडिंग310k · #115

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 पढ़कर निर्देशों का पालन करेगा।

पेस्ट करने के लिए तैयार मैसेज

इस skill से मेरी मदद करो: https://github.com/mattpocock/skills/blob/main/skills/in-progress/setup-ts-deep-modules/SKILL.md इस लिंक की SKILL.md फ़ाइल पढ़ो और मेरे काम में उसके निर्देशों का पालन करो।
क्या आप चाहते हैं कि आपका AI ऐसी skills खुद ढूँढे?मुफ़्त Skillpedia MCP इंस्टॉल करें: बस एक लाइन, और हर काम से पहले यह 15,000+ skills में खोजता है।1 मिनट में इंस्टॉल करें →

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:

  1. 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.
  2. Intra-package freedom: a package's own files import each other freely.
  3. Tests through the entry points: files under <pkg>/tests/ may import any package's entry points and their own tests/ fixtures, but never any package's subfolder internals (not even their own). Integration tests across packages are fine; deep imports are not.
  4. 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 use src/packages, else packages. 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:boundaries script: depcruise <packages-root> (or depcruise src).
  • Fold it into the repo's umbrella check command, the one that already runs typecheck (e.g. a check / ci / validate script). Do not touch tsconfig or add path aliases.
  • If there is no umbrella script, add lint:boundaries and 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.ts is 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 by index.ts, not reachable from outside.
  • tests/example.test.ts imports 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

क्या यह skill काम की है?

0

लॉग इन करें वोट करने के लिए।

कमेंट

  • …

इस repository की और skills

ask-matt

310k

यह आपके एजेंट को कोडिंग स्किल के एक सेट का मार्गदर्शक बनाती है, जो आपकी स्थिति के लिए सही स्किल की ओर इशारा करता है, विचार से लेकर भेजे गए कोड तक।

AI और एजेंटएजेंट

code-review

310k

यह आपके बदलावों को आपकी रिपॉज़िटरी के कोडिंग मानकों और मूल स्पेक के साथ जांचती है, merge से पहले दोनों समीक्षाएं साथ-साथ चलाकर।

कोडिंगसामान्य कोडिंग

domain-modeling

310k

यह एक साझा प्रोजेक्ट शब्दावली बनाती है और मुख्य डिज़ाइन फ़ैसले दर्ज करती है, ताकि आपका कोड वही शब्द इस्तेमाल करे जो आपकी टीम करती है।

कोडिंगसामान्य कोडिंग

implement-spec

310k

एक पूरे स्पेक और उसके टिकट्स को काम करने वाले कोड में बदलती है, टिकट्स को क्रम से संभालते हुए और उन्हें एक branch में जोड़ते हुए।

कोडिंगसामान्य कोडिंग

मिलती-जुलती skills