setup-ts-deep-modules
Qué hace
Instala un comprobador de dependencias y reglas que impiden que el código entre en las partes ocultas de un paquete. Es para desarrolladores que trabajan en proyectos TypeScript con varios paquetes.
Cuándo usarla
- ✓Cuando quieres que cada paquete de un repositorio TypeScript tenga una interfaz pública pequeña.
- ✓Cuando otro código sigue importando archivos internos que no debería tocar.
- ✓Cuando quieres reglas que detecten importaciones indebidas automáticamente.
Link de la skill
https://github.com/mattpocock/skills/blob/main/skills/in-progress/setup-ts-deep-modules/SKILL.mdCópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.
Cómo usar
La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.
Mensaje listo para pegar
Para Claude Code, Codex o Cursor: ejecútalo en la carpeta del proyecto y la skill queda instalada.
Descarga el SKILL.md y ponlo en la carpeta de skills de tu agente.
Ejemplo de qué pedirle a la IA
“Prepara nuestro repositorio TypeScript para que otros paquetes solo puedan importar los archivos de entrada de cada paquete.”
5 skills nuevas por semana. 1 minuto de lectura.
Cómo funciona
El agente instala dependency-cruiser y añade cuatro reglas de error, y después comprueba que las reglas detectan infracciones reales. El código de implementación va en una carpeta lib y las pruebas en una carpeta tests.
Contenido técnico (SKILL.md original)
Texto original del autor, en inglés, directo de 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
Preguntas frecuentes
¿Qué herramienta instala?
Instala dependency-cruiser, una herramienta que comprueba cómo importan los archivos de código entre sí.
¿Qué carpetas quedan ocultas al código externo?
Todo lo que está en las subcarpetas de un paquete, como lib y tests, se trata como privado.
¿La skill comprueba que las reglas funcionan?
Sí. Comprueba que las reglas detectan realmente una infracción, para que sepas que funcionan.
Detalles
Descripción original del autor
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
Popularidad
- Estrellas en GitHub
- 310 mil
- Posición en el ranking
- #115
- Licencia
- MIT
- Actualizada
- 1/11/2026
Comentarios
- …
Más skills de este repositorio
ask-matt
310 milPermite que tu agente actúe como guía de un conjunto de skills de programación, señalándote la adecuada para tu situación, desde la idea hasta el código entregado.
code-review
310 milRevisa tus cambios frente a las normas de código de tu repositorio y la especificación original, ejecutando ambas revisiones a la vez antes de fusionar.
domain-modeling
310 milCrea un glosario compartido del proyecto y registra las decisiones de diseño clave, para que tu código use las mismas palabras que tu equipo.
implement-spec
310 milConvierte una especificación terminada y sus tickets en código funcional, gestionando los tickets en orden y reuniéndolos en una sola rama.
Skills parecidas
diffs
394 milPermite que tu agente genere un diff real y compartible de los cambios, como enlace de visualización o archivo de imagen, en lugar de un resumen escrito a mano.
coding-agent
394 milAyuda a tu agente a pasar un trabajo de programación grande a Codex, Claude Code u OpenCode como trabajador en segundo plano, y después revisar su progreso.
gh-issues
394 milAyuda a tu agente a encontrar incidencias de GitHub, elegir cuáles trabajar y abrir pull requests con correcciones, incluido el seguimiento de los comentarios de revisión.