Deep modules

From juanibiapina/dotfiles · View interactive version

Deep modules is an AI agent skill from the GitHub repository juanibiapina/dotfiles. How to deepen shallow modules safely, covering dependency categories, seam placement, adapter strategy, and testing at the new interface. Use when refactoring into deep modules, choosing seams, classifying dependencies, deciding adapter strategy, or planning tests around a refactor.

How to use this skill

Skill file

Deep Modules

How to deepen a cluster of shallow modules safely, given its dependencies. The aim is testability and AI-navigability.

Load skill: vocabulary.

Signals

Apply the deletion test to anything you suspect is shallow: would deleting it concentrate complexity, or just move it? A "yes, concentrates" is the signal you want.

Dependency categories

When assessing a deep-module candidate, classify its dependencies. The category determines how the deepened module is tested across its seam.

1. In-process

Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.

2. Local-substitutable

Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.

3. Remote but owned (Ports & Adapters)

Your own services across a network boundary (microservices, internal APIs). Define a port (interface) at the seam. The deep module owns the logic; the transport is injected as an adapter. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.

Recommendation shape: "Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."

4. True external (Mock)

Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.

Seam discipline

Testing strategy: replace, don't layer

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.