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
- Repository
- jeremylongshore/tons-of-skills-marketplace
- 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
- 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.
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.
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
- Detect circular dependencies — find module A → B → A cycles using tools and import analysis
- Map dependency graphs — visualize the full import graph to understand cycle context
- Classify cycle severity — runtime cycles (crash risk) vs. type-only cycles (no runtime impact)
- Propose resolution strategies — extract shared modules, dependency inversion, lazy imports
- Identify barrel file problems — index.ts re-exports that inadvertently create cycles
- 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>&1If 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-exportsPhase 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:
- Shared types — two modules both need a type that belongs to neither → Extract types to a dedicated types.ts or shared/ module
- Barrel file fan-out — index.ts re-exports everything, creating artificial cycles → Import from specific files instead of the barrel
- Bidirectional business logic — Module A calls B and B calls A → Apply dependency inversion: extract an interface, depend on abstraction
- Utility function placement — a utility function lives in a module it doesn't belong to → Move to a utils/ module with no upstream dependencies
- 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:
- Files affected — how many files need import changes?
- Test impact — will test mocks or fixtures break?
- Public API change — does this change the module's public interface?
- 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
- React Specialist React 18+ expert covering hooks, concurrent features, server components, state management (Zustand/Redux Toolkit), and performance optimization. Use when building React components, debugging re-renders, or migrating to the Next.js App Router. Trigger with \"React component help\", \"hook optimization\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Rebase Interactive Guide through interactive rebase to clean commit history Slash Command · jeremylongshore/tons-of-skills-marketplace
- Ramp Pack Evidence-backed Ramp operator workflows for OAuth, cards, accounting, webhooks, security, reliability, and migration (24 skills) Plugin · jeremylongshore/tons-of-skills-marketplace
- Rank Designs retrieval reranking pipelines, relevance scoring systems, and learning-to-rank models with rigorous NDCG/MRR evaluation. Use when ranking quality is poor or a reranker is needed. Trigger with \"improve my search ranking\", \"design a reranking pipeline\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Cite Synthesizes case law, statutes, and regulatory guidance into actionable legal risk assessments sized for the company's stage. Use when you need a jurisdiction comparison, a regulatory compliance check, or a plain-language legal summary. Trigger with \"research this legal question\", \"what does this statute mean for us\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Cicd Agent Designs and maintains CI/CD pipelines (GitHub Actions, GitLab CI, CircleCI) including builds, tests, quality gates, secrets management, and deployment strategies, then reports conformity with sprint specs. Use when setting up or fixing CI/CD for a project. Trigger with "set up CI/CD", "fix pipeline". Subagent · jeremylongshore/tons-of-skills-marketplace
- Clause Analyzes contracts clause-by-clause for risk, scores exposure, and generates negotiation playbooks. Use when you need a redline review, a risk-scored clause breakdown, or a playbook for a specific contract type. Trigger with \"analyze this contract\", \"build a negotiation playbook\". Subagent · jeremylongshore/tons-of-skills-marketplace
- Ci Cd Expert Designs, optimizes, and troubleshoots CI/CD pipelines across GitHub Actions, GitLab CI, CircleCI, and Jenkins with production-ready YAML and setup instructions. Use when building or fixing a pipeline. Trigger with \"set up ci/cd\", \"optimize my pipeline\". Subagent · jeremylongshore/tons-of-skills-marketplace