mattpocock/skills

setup-ts-deep-modules

把dependency-cruiser接进TypeScript项目,约束包外部只能导入包根文件,不能深导入子目录实现;包内正常实现仍可自由互引,并禁止循环依赖。它让模块入口约定变成能实际失败的检查。

  • SKILL.md 已保存
  • 中文用法已整理
  • 安装与运行未实测
先判断是否解决你的问题

setup-ts-deep-modules 是什么?

把dependency-cruiser接进TypeScript项目,约束包外部只能导入包根文件,不能深导入子目录实现;包内正常实现仍可自由互引,并禁止循环依赖。它让模块入口约定变成能实际失败的检查。

中文说明由本站依据来源整理;英文原文保留在页面下方。

按客户端选择安装入口

怎么接入你的 Agent?

  1. 定位完整 Skill 目录

    打开本项目来源,核对 SKILL.md 及其引用的脚本和资料。

  2. 交给你正在用的 Agent

    在下面选择客户端,展开并复制安装指令,让 Agent 读取来源后选择安装方式。

  3. 确认识别,再做具体任务

    让 Agent 回报安装目录和识别到的名称 setup-ts-deep-modules,然后按本页使用示例提供材料。

展开并复制给 Codex 的安装指令
发送给 Codex

安装并检查 setup-ts-deep-modules

请在 Codex 的当前工作环境中安装并检查 setup-ts-deep-modules 这个 Skill。

项目身份:mattpocock/skills / setup-ts-deep-modules
来源:https://github.com/mattpocock/skills/blob/5863806dd4e15c63174bee4e7515a4256792ecfa/skills/in-progress/setup-ts-deep-modules/SKILL.md
已定位的源文件:skills/in-progress/setup-ts-deep-modules/SKILL.md

1. 先阅读真实 SKILL.md 和它引用的必要文件,确认触发条件、安装方式、依赖与权限;尊重源文件要求的审批步骤。
2. 按当前客户端支持的方式安装完整 Skill 目录,保留已有配置,不只复制一段提示词。涉及缺失凭证、目标目录或权限时先列出缺项并向我确认。
3. 安装后回读实际目录、Skill 名称和识别结果,说明哪些步骤已完成,哪些只是文档检查,不得把安装成功当作任务已经实测。
4. 如来源提供了可安全验证的示例,在我提供所需输入后做一个最小任务;创建、修改、删除、部署或发送内容前,按源文件和我的授权执行。
准备输入,再按步骤执行

装好以后,具体怎么用?

准备哪些材料

  • 确认包管理器、packages根目录和已有dependency-cruiser配置,完整目录需保留dependency-cruiser.config.cjs;本流程会新增开发依赖和示例包。

会得到什么

  • 真正接入检查链的依赖边界规则、example包及通过→失败→通过的验证记录。

实际使用顺序

  1. 检测packages根和现有配置,安装dependency-cruiser;已有配置只合并规则,不覆盖。
  2. 按附带模板配置入口、包内自由、测试仅过入口和无环规则,加入lint:boundaries及现有总检查命令,不随意改tsconfig或路径别名。
  3. 建立可删除的example包:根入口调用lib内部实现,tests只从根入口导入。
  4. 先在正常示例观察通过,再临时加入测试深导入观察tests-through-entrypoints失败,撤销后再次通过;把规则写入包目录README并从已有协作规则链接。
使用示例

从一个具体任务开始

本站根据源文件编写的使用示例,未在本站实际运行。示例中的文件由你提供。

安装并识别 Skill 后发送

复制一个具体任务

教学示例:用setup-ts-deep-modules给当前TypeScript项目设置包边界。先读已有depcruise配置和check脚本,合并不覆盖;把包根文件作为多个可用入口,子目录视为实现。用example包做pass/fail/pass验证,保留我已有路径约定,不制造全仓重构。
预期结果

预期深导入确实被检查阻止,正常入口可通过;本站未执行本例。

使用前先看这些限制

使用条件与边界

  • 检查按路径深度判断公开/私有,不限制只能有一个index.ts,也不要求巨大barrel文件。
  • 包依赖分层是另一问题,该来源只留配置桩,不自动决定业务层级。
针对这个 Skill 的疑问

常见问题

配置文件存在就说明规则生效了吗?

不够。来源把故意违规能失败、撤销后又通过作为完成条件,否则可能只是配置没接到实际检查链。

需要核对时再展开原文

来源原文与资料状态

源文件
已保存 SKILL.md,抓取于 2026-11-16T12:36:35.145Z
中文使用说明
已针对下方源文件版本整理用途、用法和常见问题
安装与任务测试
本站未执行安装或任务测试
来源复核
本页中文用法已对照保存版本的完整 SKILL.md 阅读整理
展开 SKILL.md 原文、章节与历史收录资料

skills/in-progress/setup-ts-deep-modules/SKILL.md · 抓取时间 2026-11-16T12:36:35.145Z

以下保留源文件的 description、章节及摘录,供核对中文说明;完整文件通过上方链接打开。

抓取成功不代表已完成安装或任务测试。

来源 description(原文)

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.

查看源文件章节 / Source sections
  • 原文:Setup TS Deep Modules
  • 原文:The shape this enforces
  • 原文:Steps
  • 原文:1. Detect the environment
  • 原文:2. Install dependency-cruiser
  • 原文:3. Write the config
  • 原文:4. Wire it into the checks
  • 原文:5. Scaffold the example package
  • 原文:6. Prove the rules bite
  • 原文:7. Document the convention
  • 注意事项 / Notes
原文: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](https://github.com/sverweij/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.

原文: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`](./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.

文件 SHA256:29acca66ac99d4532e2a6f0370d8125d7cba1e87c9ac66573203c75189d3e6c7

仓库许可证记录:MIT;repository-license-recorded-scope-unverified,查看来源。

SKILL.md原文description · 2026-11-16T12:36:35.145Z

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.

查看历史简介来源

历史收录数据

来源仓库mattpocock/skills
Skill源路径skills/in-progress/setup-ts-deep-modules/SKILL.md

安装前请让使用的Agent先读取这个SKILL.md及其所在目录,确认依赖和所需权限。此页不生成未经来源验证的安装命令。

返回 Skills 目录,按任务继续筛选 · MCP与Skills教程与资源