skills/code-quality/cleanup-cycles/SKILL.md
Detect and untangle circular dependencies. Runs madge/skott (TS), pycycle (Py), or compiler-only checks (Go/Rust). Auto-fixes leaf-extractable cycles; reports core cycles for human review. Use when the user asks to find circular imports, fix dependency cycles, or untangle module graph.
npx skillsauth add raintree-technology/claude-starter cleanup-cyclesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Detect circular import dependencies and break them where it's mechanically safe. Cycles between leaf utilities can be fixed by extraction; cycles between core modules need architectural decisions and are reported, not auto-fixed.
package.json (TS/JS), pyproject.toml (Py), go.mod (Go), Cargo.toml (Rust). Note: Go and Rust prevent cycles at compile time, so this skill is mostly TS/Py work..claude/cleanup-reports/ exists.package.json for cycle:check or similar — if the repo already wires up madge with config, prefer their config over defaults.# Madge is the standard. Skott is faster for large repos.
npx madge --circular --extensions ts,tsx,js,jsx --json . > /tmp/madge.json
Each entry is an array describing one cycle: ["a.ts", "b.ts", "a.ts"].
pipx run pycycle --here --verbose > /tmp/pycycle.txt 2>&1 || true
# Fallback: import-linter with auto-config
pipx run import-linter > /tmp/import-linter.txt 2>&1 || true
# Go enforces acyclic at compile; this just confirms build is clean.
go build ./... 2>&1
# Optional: visualize with goda for ergonomics
go install github.com/loov/goda@latest 2>/dev/null
goda graph ./... > /tmp/goda.dot 2>/dev/null || true
If go build fails with import cycle, that's the report.
cargo build 2>&1 # rustc rejects cycles
# For visibility into module graph: cargo-modules
cargo install cargo-modules 2>/dev/null
cargo modules generate tree 2>/dev/null || true
Write .claude/cleanup-reports/cleanup-cycles-{YYYY-MM-DD}.md:
# Circular Dependencies Assessment — YYYY-MM-DD
## Summary
- Total cycles: N
- HIGH confidence (auto-fixable by leaf extraction): X
- MEDIUM confidence (refactor needed): Y
- LOW (architectural redesign): Z
## Cycles
### Cycle 1 — HIGH
- Path: `a/util.ts → b/helper.ts → a/util.ts`
- Shared piece: `formatCurrency` defined in `b/helper.ts`, called by `a/util.ts`. `b/helper.ts` imports a single constant `LOCALE` from `a/util.ts`.
- Plan: Extract `LOCALE` to new `a/constants.ts`. `b/helper.ts` imports from there. Cycle broken.
### Cycle 2 — MEDIUM
- Path: `domains/user/index.ts → domains/account/index.ts → domains/user/index.ts`
- Both modules export and consume each other's primary types. No leaf to extract.
- Recommendation: introduce a `domains/shared/types.ts` for cross-domain types, OR invert one direction with dependency injection.
## Critical Assessment
[2-3 paragraphs: what does the cycle pattern reveal about the architecture? Are cycles concentrated in one area? Is there a missing layer?]
Auto-fix HIGH-confidence leaf-extraction cycles only.
HIGH (auto-apply):
MEDIUM (report only):
LOW (note for human):
src/<area>/<name>.ts. Prefer placing inside the consumer that has fewer outside imports.chore(cleanup): cleanup-cycles — N cycles broken via leaf extraction.# Re-run cycle detection — should report 0 for HIGH-applied cycles
npx madge --circular . 2>&1
pycycle --here 2>&1
go build ./... 2>&1
cargo build 2>&1
# Then standard typecheck/test/lint (see cleanup-unused for full list)
npm run check 2>&1 || (npx tsc --noEmit && npx eslint .)
pytest 2>&1
If verify fails or new cycles appear: git revert HEAD, mark fixes as MEDIUM, escalate.
index.ts re-exports) as the cycle-breaking solution — they often hide cycles instead of fixing them.types.ts god-file — prefer co-location with the smallest scope that breaks the cycle.development
Whop platform expert for digital products, memberships, and community monetization. Covers memberships API, payments, courses, forums, webhooks, OAuth apps, and checkout integration. Build SaaS, course platforms, and gated communities. Triggers on Whop, memberships, digital products, course platform, community monetization, Whop API, license keys.
development
Token-Oriented Object Notation (TOON) format expert for 30-60% token savings on structured data. Auto-applies to arrays with 5+ items, tables, logs, API responses, database results. Supports tabular, inline, and expanded formats with comma/tab/pipe delimiters. Triggers on large JSON, data optimization, token reduction, structured data, arrays, tables, logs, metrics, TOON.
development
Plaid banking API expert for financial data integration. Covers Plaid Link, Auth (account/routing numbers), Transactions, Identity verification, Balance checking, and webhooks. Build fintech apps with bank connections, ACH transfers, and transaction history. Triggers on Plaid, banking API, Plaid Link, bank connection, ACH, financial data, transaction history.
development
Helius Solana RPC and API expert. High-performance infrastructure for Solana including RPC nodes, DAS API for NFTs/tokens, LaserStream real-time streaming, webhooks, Priority Fee API, Enhanced Transactions, and ZK Compression. Triggers on Helius, Solana RPC, DAS API, Digital Asset Standard, NFT metadata, Solana webhooks, priority fees, LaserStream, ZK compression.