break-coupling
Skill1 starsChanged 2 months agoMITView on GitHub
Break a circular dependency or an over-tight coupling — a forwardRef triad, two modules that import each other, a service reaching across a boundary it shouldn't. Find what actually needs to cross, move it, invert the direction. Use when a build warns about a cycle, a review flags forwardRef / a cross-import, or the user says "these two modules are tangled".
In this repository73 other files it gives its agents.
- AGENTS.mdAGENTS.md
- bigquery-analyticsSkill
- cache-invalidationSkill
- mongo-aggregationSkill
- mongo-modelingSkill
- postgres-aggregationSkill
- postgres-indexingSkill
- redis-coordinationSkill
- redis-patternsSkill
- review-querySkill
- code-migrationSkill
- cut-releaseSkill
- data-migrationSkill
- deploy-serviceSkill
- hotfixSkill
- rollbackSkill
- design-endpointSkill
- design-eventSkill
- design-schemaSkill
- evolve-contractSkill
- scaffold-nestjs-moduleSkill
- scaffold-projectSkill
- incident-responseSkill
- investigate-bugSkill
- on-callSkill
- postmortemSkill
- audit-skillsSkill
- distill-review-styleSkill
- write-skillSkill
- debug-with-tracesSkill
- define-alertsSkill
- instrument-serviceSkill
- evaluate-dependencySkill
- grillSkill
- handoffSkill
- orientSkill
- phased-deliverySkill
- spikeSkill
- to-questionnaireSkill
- write-adrSkill
- write-prdSkill
- devops-pr-reviewSkill
- go-backend-pr-reviewSkill
- nestjs-backend-pr-reviewSkill
- python-backend-pr-reviewSkill
- react-frontend-pr-reviewSkill
- bisectSkill
- dead-code-sweepSkill
- deslopifySkill
- extract-moduleSkill
- rebase-cleanSkill
- resolve-merge-conflictsSkill
- split-commitSkill
- tddSkill
- wait-whatSkill
- wide-renameSkill
- bullmqSkill
- kafkaSkill
- sqs-consumerSkill
- audit-dependenciesSkill
- The first 60 shown.
The file
Files
Break coupling
Straight from the NestJS review notes: "question whether the cross-import is needed at all if nothing injects the service yet".
Diagnose
- Draw the cycle. A → B → A. Name exactly what A takes from B and what B takes from A.
- Is one direction spurious? Often one side imports the other for a type, a constant, or a helper that doesn't belong there. If nothing actually uses the cross-import at runtime, delete it — done.
- Is there a shared thing? Both A and B depend on some concept X that's currently living inside one of them. Extract X to its own module; A and B both depend on X, cycle gone.
Fixes, in order of preference
- Delete the unused cross-import.
- Extract the shared piece (a type, an interface, an enum, a small service)
into a module both sides import — no cycle. For NestJS, shared connection/config
modules should be
global: true, not re-imported per feature. - Invert the dependency — B shouldn't call A; A should pass B a callback, or B should emit an event A listens for. The consumer declares the small interface it needs (especially in Go — define the interface on the consumer, not the producer).
forwardRefis the last resort, not a fix. If you reach for it, write a comment explaining why the cycle is unavoidable.
Verify
- The cycle-detection warning is gone.
grepthe removed import name — zero hits.- Tests green, and a test that would have caught a wiring break.
- Commit
refactor: break <A>/<B> circular dependency.
Anti-patterns
- ❌ Adding
forwardRefand calling it done. - ❌ Extracting a "shared" module that's just a dumping ground.
- ❌ Breaking the cycle by merging A and B into one bigger module.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

