typescript-circular-dependency

Detect and resolve circular import dependencies in TypeScript/JavaScript Node.js projects.

1|Updated Feb 27, 2026
One-click install
npx skills add https://github.com/gatieme/agent-toolkit --skill typescript-circular-dependency-gatieme
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: typescript-circular-dependency
Source: https://github.com/gatieme/agent-toolkit/tree/main/skills/claudeception/examples/typescript-circular-dependency
Command: npx skills add https://github.com/gatieme/agent-toolkit --skill typescript-circular-dependency-gatieme

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires madge, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill resolves "Cannot access 'X' before initialization" and other runtime errors caused by circular dependencies in TypeScript/JavaScript projects.

Core Features & Use Cases

  • Detects Cycles: Identifies circular import patterns using tools like madge.
  • Resolves Cycles: Provides strategies like dependency extraction, injection, and dynamic imports.
  • Prevents Cycles: Offers methods to integrate cycle detection into CI/build processes and ESLint.
  • Use Case: You're encountering ReferenceError: Cannot access 'UserService' before initialization in your Node.js application. This Skill will guide you through finding and fixing the root cause.

Quick Start

Use the typescript-circular-dependency skill to detect and resolve circular imports in the 'src/' directory.

Frequently Asked Questions about typescript-circular-dependency

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

FAQPage Schema
Why does my TypeScript project get a "Cannot access 'X' before initialization" runtime error?

A "Cannot access 'X' before initialization" runtime error in TypeScript is caused by circular import dependencies. This Skill detects these import cycles and provides refactoring strategies like dependency extraction or dynamic imports to resolve the initialization failure.

How do I find circular dependencies in a Node.js source directory?

You can find circular dependencies in a Node.js project by running detection tools like `madge` against your source code. This Skill automates this detection process to identify circular import patterns in your TypeScript or JavaScript files.

How can I prevent circular dependencies in my CI/CD build process?

You can prevent circular dependencies by integrating cycle detection into your CI/build processes and ESLint configuration. This Skill offers methods to automatically catch import cycles before they cause runtime errors in production.

Does this circular dependency detection work with plain JavaScript files?

Yes, this circular dependency detection works with both TypeScript and JavaScript projects in Node.js. It addresses unexpected `undefined` imports and initialization errors across both language environments using tools like `madge`.