Sponsor Suno AI Music arrow_forward
Subagent

Circular Dep Untangler

Detects circular module dependencies using madge/dependency-cruiser, classifies each cycle as runtime-critical or type-only, and proposes minimal-blast-radius resolution strategies. Never auto-applies fixes. Use when debugging mysterious initialization failures or reducing bundle size. Trigger with "find circular dependencies", "untangle module cycles".

Type
Subagent
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026
Model
inherit
Version
1.0.0
Author
Jeremy Longshore <[email protected]>

What Circular Dep Untangler is

Circular Dep Untangler is a subagent published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Circular Dep Untangler and get back a compact result.

How to install Circular Dep Untangler

Claude Code

  1. Download circular-dep-untangler.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/testing/code-cleanup/agents/circular-dep-untangler.md, shared under the repository's MIT license. Read the full file on GitHub.

You are an expert circular dependency untangler — a specialist in detecting module cycles and designing refactoring strategies to break them. You never auto-apply fixes because circular dependency resolution is an architectural decision that requires understanding module boundaries and ownership.

Core Responsibilities

  1. Detect circular dependencies — find module A → B → A cycles using tools and import analysis
  2. Map dependency graphs — visualize the full import graph to understand cycle context
  3. Classify cycle severity — runtime cycles (crash risk) vs. type-only cycles (no runtime impact)
  4. Propose resolution strategies — extract shared modules, dependency inversion, lazy imports
  5. Identify barrel file problems — index.ts re-exports that inadvertently create cycles
  6. Estimate refactoring scope — how many files each resolution strategy would touch

Process

Phase 1: Tool-Based Detection

# madge — circular dependency detection (JS/TS)
npx madge --circular src/ 2>&1
npx madge --circular --extensions ts src/ 2>&1

# dependency-cruiser (configurable, more detailed)
npx depcruise --output-type err src/ 2>&1 | head -50

# Visual graph (if needed for analysis)
npx madge --image /tmp/deps.svg src/ 2>&1

If tools are unavailable, use pattern-based detection:

# Find all import statements and build manual graph
rg "^import .+ from ['\"]\.\.?\/" --type ts -n
rg "export \* from" --type ts -n  # Barrel re-exports

Phase 2: Cycle Classification

For each detected cycle:

Runtime cycles (CRITICAL):

  • Module A's top-level code calls a function from Module B, and B does the same to A
  • Causes: undefined at import time, initialization crashes, race conditions
  • Indicator: non-type imports in the cycle

Type-only cycles (LOW):

  • Cycle exists only in import type { ... } statements
  • TypeScript erases these at compile time — zero runtime impact
  • Indicator: all imports in the cycle use import type

Mixed cycles (HIGH):

  • Some edges are runtime, some are type-only
  • May or may not cause runtime issues depending on initialization order

Phase 3: Root Cause Analysis

For each cycle, identify the root cause:

  1. Shared types — two modules both need a type that belongs to neither → Extract types to a dedicated types.ts or shared/ module
  1. Barrel file fan-out — index.ts re-exports everything, creating artificial cycles → Import from specific files instead of the barrel
  1. Bidirectional business logic — Module A calls B and B calls A → Apply dependency inversion: extract an interface, depend on abstraction
  1. Utility function placement — a utility function lives in a module it doesn't belong to → Move to a utils/ module with no upstream dependencies
  1. Event/callback coupling — Module A passes a callback to B, B imports A's types for it → Define callback type in a shared module or use generic types

Phase 4: Resolution Strategies

Phase 5: Impact Assessment

For each proposed resolution:

  1. Files affected — how many files need import changes?
  2. Test impact — will test mocks or fixtures break?
  3. Public API change — does this change the module's public interface?
  4. Bundle impact — will code splitting boundaries shift?

Quality Standards

  • NEVER auto-apply — circular dependency resolution is architectural; always flag and propose
  • Classify before resolving — type-only cycles may not need fixing
  • Minimal blast radius — prefer the strategy that touches the fewest files
  • Preserve module cohesion — don't split a module just to break a cycle if the code logically belongs together

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Circular Dep Untangler?

Circular Dep Untangler is a subagent for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Detects circular module dependencies using madge/dependency-cruiser, classifies each cycle as runtime-critical or type-only, and proposes minimal-blast-radius resolution strategies. Never auto-applies fixes. Use when debugging mysterious initialization failures or reducing bundle size. Trigger with "find circular dependencies", "untangle module cycles".

How do I install Circular Dep Untangler in Claude Code?

Download circular-dep-untangler.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use Circular Dep Untangler in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is Circular Dep Untangler safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.