typescript-circular-dependency

Detect and resolve circular import dependencies in TypeScript and JavaScript projects.

12|Updated Dec 13, 2025
One-click install
npx skills add https://github.com/ckorhonen/claude-skills --skill typescript-circular-dependency-ckorhonen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-circular-dependency
Source: https://github.com/ckorhonen/claude-skills/tree/main/skills/continuous-learning/examples/typescript-circular-dependency
Command: npx skills add https://github.com/ckorhonen/claude-skills --skill typescript-circular-dependency-ckorhonen

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Circular import dependencies in TypeScript and JavaScript projects cause runtime initialization errors, undefined imports, and flaky tests when modules reference each other in a cycle.

Core Features & Use Cases

  • Detect cycles using tooling guidance (madge, TypeScript compiler checks) to identify circular import paths.
  • Provide robust resolution strategies including extracting shared interfaces, dependency injection, dynamic imports, and type-only imports.
  • Applicable to real-world scenarios where import order changes or tests fail due to circular dependencies.

Quick Start

Run a cycle-detection workflow on your TS/JS project to identify circular imports and apply the recommended fixes.

Frequently Asked Questions about typescript-circular-dependency

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix TypeScript circular dependencies causing undefined imports?

TypeScript circular dependencies causing undefined imports can be fixed by extracting shared interfaces, applying dependency injection, using dynamic imports, or switching to type-only imports to break the initialization cycle.

What is the best way to detect circular dependencies in a JavaScript project?

The best way to detect circular dependencies in a JavaScript project is using static analysis tooling like madge or TypeScript compiler checks to automatically identify circular import paths across modules.

Why does my test pipeline fail due to circular imports in JavaScript?

Test pipelines fail due to circular imports in JavaScript because modules referencing each other in a cycle cause runtime initialization errors and receive undefined values when import order changes during execution.

Can I use dynamic imports to resolve TypeScript module resolution cycles?

Yes, you can use dynamic imports to resolve TypeScript module resolution cycles by deferring the import execution until runtime, effectively breaking the immediate circular dependency link between modules.

What are the limitations of using type-only imports for circular dependency refactoring?

Type-only imports for circular dependency refactoring are limited to type checking and do not solve runtime value initialization cycles, requiring alternative remedies like dependency injection if runtime logic is circular.