Agent skill

Setup TS Deep Modules

by devcxl in devcxl/mattpocock-skills-zh

将 dependency-cruiser 接入 TypeScript 仓库,使每个 package 都是一个深度模块:实现隐藏在子文件夹中,只能通过入口点文件访问。由用户调用。

MITAuto-check passedDevelopment

Install Setup TS Deep Modules

skills CLI
$ npx skills add devcxl/mattpocock-skills-zh --skill setup-ts-deep-modules -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install devcxl/mattpocock-skills-zh setup-ts-deep-modules --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/devcxl/mattpocock-skills-zh.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/in-progress/setup-ts-deep-modules .claude/skills/setup-ts-deep-modules && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
setup-ts-deep-modules
GitHub stars
433
Token cost
~1.1k tokens
SKILL.md length
250 words
Files
3
Skills in repo
20
Repo updated
First seen
Licence
MIT

At a glance

将 dependency-cruiser 接入 TypeScript 仓库,使每个 package 都是一个深度模块:实现隐藏在子文件夹中,只能通过入口点文件访问。由用户调用。

  • Works in 7 steps: 探测环境 → 安装 dependency-cruiser → 写入配置 → …
  • Development work in your project
  • SKILL.md covers 它强制形成的结构, 流程 and 备注
  • Runs JavaScript scripts from its folder; calls npm

What it does

Setup TS Deep Modules is an agent skill from devcxl/mattpocock-skills-zh. 将 dependency-cruiser 接入 TypeScript 仓库,使每个 package 都是一个深度模块:实现隐藏在子文件夹中,只能通过入口点文件访问。由用户调用。

Its SKILL.md is about 1.1k tokens, which your agent loads only when the skill is triggered. The skill folder holds 3 other files (for example `agents/openai.yaml`).

It sits in Development. It works with TypeScript and pnpm. The repository describes itself as: Matt Pocock 技能集的中文翻译版 — 地道中文,原汁原味的技术术语。基于 mattpocock/skills 复刻。每日中午12点钟同步. The licence is MIT.

When your agent uses it

  • Development work in your project

Example prompts

  • “/setup-ts-deep-modules”

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. 探测环境
  2. 安装 dependency-cruiser
  3. 写入配置
  4. 接入检查流程
  5. 搭建示例 package
  6. 验证规则确实起作用
  7. 把约定写下来

What it can do on your machine

Read from SKILL.md and the folder at commit b72cc5b. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Ships script files (JavaScript), which the agent can run.

    Shell commands in SKILL.md call:

    • npm

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    Links to these hosts (documentation or services it may open):

    • github.com

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Setup TS Deep Modules loads about 1.1k tokens when it runs. Until then it costs about 28 tokens; SKILL.md has 250 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~28
When it runs · the whole SKILL.md, loaded when a task matches
~1.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from devcxl/mattpocock-skills-zh at commit b72cc5b, republished under its MIT licence (© devcxl). 250 words, ~1,062 tokens.

Download SKILL.mdSave it as .claude/skills/setup-ts-deep-modules/SKILL.md (or your agent's skills folder). This skill also uses 2 other files; get the full folder from GitHub.
name
setup-ts-deep-modules
description
将 dependency-cruiser 接入 TypeScript 仓库,使每个 package 都是一个深度模块:实现隐藏在子文件夹中,只能通过入口点文件访问。由用户调用。
disable-model-invocation
true

设置 TS 深度模块

让此仓库中的每个 package 都成为一个深度模块:小接口背后隐藏大量行为。一个 package 的公开表面是其入口点:package 根目录下的文件:而其子文件夹中的所有内容都是隐藏的。本技能安装 dependency-cruiser 与让入口点成为唯一通路的规则,然后验证规则确实起作用。

关于相关词汇(深度模块、接口、接缝、depth),请调用 Skill 工具并传入 "codebase-design":在后续内容中使用它的术语。

它强制形成的结构

src/packages/
  <name>/
    index.ts        ← 一个入口点(公开)。外部从这里导入。
    client.ts       ← 另一个入口点。Package 可以暴露多个。
    lib/            ← 实现:对外部隐藏,内部可以自由相互导入。
    tests/          ← 与实现并列的测试与 fixtures(一个子文件夹,所以是私有的)。

公开表面是 package 的根文件,而不是某个指定的 index.ts。按惯例实现放在 lib/,测试放在 tests/,让每个 package 都拥有相同的"两个子文件夹"结构。不过规则本身是普适的:任何子文件夹里的任何文件都是私有的,所以你永远不需要为了新增文件夹而扩展配置。

四条规则,全部为 error:

  1. 入口点边界:package 外部的代码(应用代码或其他 package)只能导入该 package 的入口点(即其根文件),绝不能导入其子文件夹中的任何内容。
  2. 包内自由:package 自己的文件可以自由地相互导入。
  3. 测试通过入口点:<pkg>/tests/ 下的文件可以导入任何 package 的入口点以及它自己的 tests/ fixtures,但不能导入任何 package 的子文件夹内部内容(包括它自己的)。跨 package 的集成测试可以,但深路径导入不行。
  4. 无循环依赖:不允许存在依赖循环。

入口点,而非桶文件(barrel)。 由于公开表面是每个根文件,所以一个 package 可以暴露多个小型入口点(index.ts、client.ts、server.ts),而不是把一切都集中塞进一个巨大的 index.ts。不要用桶文件来再导出整棵子树;保持入口点小而精,把实现藏在子文件夹里。

分层(哪些 package 可以依赖哪些 package)是另一回事,本仓库把它以注释桩(commented stub)的形式留在配置里供填充。

流程

1. 探测环境
  • 包管理器:pnpm-lock.yaml → pnpm;yarn.lock → yarn;bun.lockb → bun;否则 npm。后续所有命令都使用该包管理器(pnpm / yarn / npm run / bunx)。
  • packages 根目录:如果存在 src/ 则使用 src/packages,否则使用 packages。如果仓库已经有明显不同的约定,请与用户确认。
  • 已有配置:检查是否存在 .dependency-cruiser.* 文件。若已有,不要覆盖:把四条规则与 options 合并进去,并告知用户你新增了什么。

**完成条件:**包管理器、packages 根目录、是否有已有配置:这三项都已确认。

2. 安装 dependency-cruiser

使用上面探测到的包管理器,把 dependency-cruiser 安装为 devDependency。

完成条件:dependency-cruiser 已出现在 devDependencies 中。

3. 写入配置

将 dependency-cruiser.config.cjs 复制到仓库根目录,命名为 .dependency-cruiser.cjs。把 PACKAGES_ROOT 设置为步骤 1 探测到的根目录。规则是基于路径深度且与扩展名无关的,所以不需要做其他适配。

完成条件:.dependency-cruiser.cjs 存在,PACKAGES_ROOT 正确,且四条禁用规则都已写入。

4. 接入检查流程
  • 新增 lint:boundaries 脚本:depcruise <packages-root>(或 depcruise src)。
  • 将其并入仓库的"总检查"命令:那个已经运行 typecheck 的命令(例如 check / ci / validate 脚本)。不要改动 tsconfig,也不要新增路径别名。
  • 如果没有总检查脚本,就新增 lint:boundaries 并告诉用户在 CI 中加入它。

完成条件:lint:boundaries 已存在,并作为与 typecheck 同一条命令的一部分运行。

5. 搭建示例 package

创建一个会被提交的 <packages-root>/example/,作为"复制即用"的模板:

  • index.ts 是一个入口点。导出一个委托给内部文件的函数(这样 package 看起来就是深的,而不是一个简单的透传)。
  • lib/impl.ts:一个位于子文件夹中的内部文件,被 index.ts 导入,从外部无法触达。
  • tests/example.test.ts 只导入 ../index(一个入口点),并针对公开函数进行断言。

告诉用户这是一个可以复制或删除的起始模板。

**完成条件:**示例 package 已存在,通过根入口点暴露行为,并把 impl 隐藏在子文件夹中。

6. 验证规则确实起作用

这是整项技能的完成判定标准:一个在违反时不会失败的配置毫无价值。

  1. 运行 lint:boundaries。在干净的示例上必须通过。
  2. 临时向 tests/example.test.ts 中添加一个深路径导入(例如 import { thing } from "../lib/impl")。再次运行 lint:boundaries;它必须以 tests-through-entrypoints 报错失败。
  3. 撤销那个深路径导入。再运行一次,必须通过。

**完成条件:**你已经观察到了"通过 → 在深路径导入时失败 → 再撤销后又通过"这一完整流程。如果步骤 2 没有失败,说明规则没有正确接入,请修复后再结束。

7. 把约定写下来

在 packages 文件夹中写一份 README.md(即 <packages-root>/README.md,放在它所管辖的 packages 旁边),内容覆盖:src/packages/<name>/ 的目录结构(根目录的入口点、lib/ 放实现、tests/ 放测试)、"只能通过 package 的入口点(即根文件)导入"以及如何运行 lint:boundaries。显式劝阻桶文件:暴露多个小型入口点,而不是通过一个 index 再导出一整棵子树。控制在"复制即用片段 + 四条规则各一段"的范围。

然后在仓库的 agent-instructions 文件(优先 CLAUDE.md,否则 AGENTS.md,若两者都不存在则新建 AGENTS.md)中添加一个上下文指针指向它。一行就够,例如 Packages are deep modules: see [src/packages/README.md](./src/packages/README.md) before adding or importing one. 这正是让 agent 在踩到边界规则之前先发现它的关键。

完成条件:<packages-root>/README.md 存在且劝阻桶文件,且仓库的 CLAUDE.md/AGENTS.md 中有指向它的链接。

备注

  • 配置中的 $1 反向引用(dependency-cruiser 的 group matching)正是让一个 package 可以触达自己的内部、而外部却不能触达的关键。不要把它们拆成多个独立的 per-package 规则。
  • 公开 vs 私有由深度决定:package 的根文件是入口点;任何子文件夹里的内容都是私有的。约定俗成的子文件夹是 lib/(实现)和 tests/,但规则并未硬编码它们:任何子文件夹都是私有的,所以新增文件夹永远不需要改配置。新增入口点只是新增一个根文件(不需要桶文件)。
  • Package 是扁平的:根目录下只有一层直接的子目录。Package 的内部可以嵌套任意深度;但 package 内不能再放另一个 package。
  • 使用 .cjs(而不是 .js),这样即使在 "type": "module" 的仓库里,配置中的 module.exports 也能正常工作。

© devcxl, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 2 other files in skills/in-progress/setup-ts-deep-modules of devcxl/mattpocock-skills-zh.

  • SKILL.md
  • agents/openai.yaml
  • dependency-cruiser.config.cjs

Open the folder on GitHubat commit b72cc5b

Compare with similar skills

Setup TS Deep Modules next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Setup TS Deep Modules compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Setup TS Deep Modules this skilldevcxl/mattpocock-skills-zh433—~1.1kAutomated safety check: PassMIT
Link Workspace Packagesnomcopter/react-mosaic4.8k5 repos~760Automated safety check: PassCustom licence
Pnpm Engineteambit/bit18k—~1.9kAutomated safety check: PassCustom licence
Testing Changespnpm/pnpm37k—~1.1kAutomated safety check: PassMIT
evlog Adapter Creatorevloghq/evlog1.9k—~2.9kAutomated safety check: PassMIT
Dep Refszai-org/ZCode7.5k—~552Automated safety check: PassApache-2.0

Similar skills

  • Link Workspace Packages

    nomcopter/react-mosaic

    Link workspace packages in monorepos (npm, yarn, pnpm, bun).

    4.8k GitHub starsUsed in 5 repos~760 tokens
    DevelopmentAuto-check passed
  • Pnpm Engine

    teambit/bit

    Work on the pnpm Rust engine (@pnpm/napi, the pacquet crates) that bit install runs through.

    18k GitHub stars~1.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Run the tests that cover a change in the pnpm repository, in the Rust workspace (pnpm/, pnpr/) or the TypeScript CLI (pnpm11/), and recognize the cases where a scoped run passes without testing…

    37k GitHub stars~1.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Walks through adding a new built-in evlog drain adapter for an observability platform: source, build config, exports, tests, docs and PR scope.

    1.9k GitHub stars~2.9k tokensUpdated today
    DevelopmentAuto-check passed
  • Dep Refs

    zai-org/ZCode

    A skill your agent uses when needs to inspect TypeScript export references in the z-code workspace, list exports from a file, verify whether an export is unused before deletion, investigate who…

    7.5k GitHub stars~552 tokensUpdated 8 days ago
    DevelopmentAuto-check passed
  • Linea Dependency Maintenance

    Consensys-Incorporated/linea-attestation-registry

    Safely plan and execute dependency maintenance for JavaScript/TypeScript (npm, pnpm) and GitHub Actions, including npm lockfiles, pnpm workspaces, catalogs, overrides, SHA-pinned action versions…

    177 GitHub starsUsed in 1 repo~3.7k tokens
    DevelopmentAuto-check: warnings

More from devcxl/mattpocock-skills-zh

All 20 skills in this repo
  • Triage

    devcxl/mattpocock-skills-zh

    将 issue 和外部 PR 推过一组分诊角色的状态机——分类、验证、必要时盘问,并写出 agent 就绪的任务简报. An agent skill from devcxl/mattpocock-skills-zh.

    433 GitHub starsUsed in 1 repo~816 tokens
    Auto-check passed
  • Git Guardrails Claude Code

    devcxl/mattpocock-skills-zh

    设置 Claude Code 钩子,在危险 Git 命令(push、reset --hard、clean、branch -D 等)执行前将其拦截。当用户想要防止破坏性 Git 操作、添加 Git 安全钩子或在 Claude Code 中阻止 git push/reset 时使用。

    433 GitHub stars~420 tokensUpdated yesterday
    Auto-check passed
  • Codebase Design

    devcxl/mattpocock-skills-zh

    设计深度模块的共享词汇。当用户想要设计或改进模块的接口、寻找深化机会、决定 seam 的位置、让代码更可测试或更易被 AI 导航,或者其他 skill 需要深度模块词汇时使用。

    433 GitHub stars~809 tokensUpdated yesterday
    Auto-check passed
  • Diagnosing Bugs

    devcxl/mattpocock-skills-zh

    针对棘手 bug 和性能回归的诊断循环。当用户说"诊断"/"调试这个",或报告某处崩溃/报错/不正常/缓慢时使用. An agent skill from devcxl/mattpocock-skills-zh.

    433 GitHub stars~958 tokensUpdated yesterday
    Auto-check passed
  • Domain Modeling

    devcxl/mattpocock-skills-zh

    构建和完善项目的领域模型。当讨论代码库术语、编写或编辑 GLOSSARY.md,或记录或编辑 ADR 时使用. An agent skill from devcxl/mattpocock-skills-zh.

    433 GitHub stars~412 tokensUpdated yesterday
    Auto-check passed
  • Migrate To Shoehorn

    devcxl/mattpocock-skills-zh

    将测试文件从 as 类型断言迁移到 @total-typescript/shoehorn。当用户提到 shoehorn、想要在测试中替换 as、或需要部分测试数据时使用。

    433 GitHub stars~522 tokensUpdated yesterday
    Auto-check passed

Works with

Categories

Questions about Setup TS Deep Modules

What does Setup TS Deep Modules do?

将 dependency-cruiser 接入 TypeScript 仓库,使每个 package 都是一个深度模块:实现隐藏在子文件夹中,只能通过入口点文件访问。由用户调用。. Setup TS Deep Modules is an agent skill from devcxl/mattpocock-skills-zh.

When should I use Setup TS Deep Modules?

Setup TS Deep Modules fits situations like: development work in your project.

How do I install Setup TS Deep Modules in Claude Code?

Run `npx skills add devcxl/mattpocock-skills-zh --skill setup-ts-deep-modules -a claude-code`. Or copy the skill folder (skills/in-progress/setup-ts-deep-modules in devcxl/mattpocock-skills-zh) into .claude/skills/setup-ts-deep-modules in your project. Claude Code loads it when a task matches its description.

How do I install Setup TS Deep Modules in Codex?

Run `npx skills add devcxl/mattpocock-skills-zh --skill setup-ts-deep-modules -a codex`. Or copy the skill folder (skills/in-progress/setup-ts-deep-modules in devcxl/mattpocock-skills-zh) into .agents/skills/setup-ts-deep-modules in your project. Codex loads it when a task matches its description.

Can I use Setup TS Deep Modules in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add devcxl/mattpocock-skills-zh --skill setup-ts-deep-modules -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/setup-ts-deep-modules, .gemini/skills/setup-ts-deep-modules, .github/skills/setup-ts-deep-modules and .opencode/skills/setup-ts-deep-modules in your project.

What does Setup TS Deep Modules need to run?

Going by SKILL.md and its folder, Setup TS Deep Modules needs JavaScript for the scripts in its folder and the command-line tools its instructions call (npm).

Does Setup TS Deep Modules access the network?

SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.

Is Setup TS Deep Modules safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Setup TS Deep Modules use?

Setup TS Deep Modules is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Setup TS Deep Modules use?

About 1.1k tokens (SKILL.md is roughly 4.2k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Setup TS Deep Modules?

Skills that share tags, products or a category with Setup TS Deep Modules: Link Workspace Packages (nomcopter/react-mosaic, 4.8k stars), Pnpm Engine (teambit/bit, 18k stars), Testing Changes (pnpm/pnpm, 37k stars) and evlog Adapter Creator (evloghq/evlog, 1.9k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Setup TS Deep Modules?

devcxl (a GitHub user) maintains it in devcxl/mattpocock-skills-zh, which has 433 GitHub stars. The repository holds 20 skills in this directory. The repository was last updated on October 5, 2026.

Source: devcxl/mattpocock-skills-zh on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.