circular-check
Detect circular imports in src/ and report any cycles with fix guidance. Use after a change session as a quality gate, when adding a module that imports several others, or when a dynamic import is used to break a cycle.
- License 许可
- MIT
- 最近更新
- 2026-11-12
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- circular-check
- tags
- [ "react-dev", "quality", "imports", "architecture" ]
- type
- skill
- agents
- [ "claude", "codex", "cursor", "gemini", "copilot" ]
- author
- Aliendreamer
- version
- 0.1.0
- description
- Detect circular imports in src/ and report any cycles with fix guidance. Use after a change session as a quality gate, when adding a module that imports several others, or when a dynamic import is used to break a cycle.
- user-invocable
- true
- disable-model-invocation
- false
03 SKILL.md 正文
Circular Dependency Check
Detect circular imports in src/ and report any cycles with fix guidance.
When to use
- After every
/opsx:applysession (mandatory quality gate) - When a new module is added that imports from multiple existing modules
- When a dynamic import is added as a cycle-breaking workaround — verify it was actually needed
Steps
-
Run the check
pnpm check:circularThis runs:
madge --circular --extensions ts,tsx --ts-config tsconfig.json src/- TypeScript path aliases (
@/) are resolved viatsconfig.json - Dynamic
import()calls ARE tracked as edges — if a dynamic import forms a cycle, it is still reported src/gql/__generated__/follows a one-way import pattern and will not produce cycles
- TypeScript path aliases (
-
Interpret results
No cycles:
✔ No circular dependency found!Report: "✓ No circular imports — N files checked."
Cycles found:
✖ Found N circular dependencies! 1) lib/a.ts > lib/b.ts > lib/a.tsFor each cycle, report it and suggest a fix (see below).
-
Fix guidance — for each reported cycle
Option A — Extract the shared dependency (preferred)
The cleanest fix: identify what
b.tsneeds froma.ts(or vice versa) and move it to a third filec.tsthat neither imports. Then botha.tsandb.tsimport fromc.ts.Common pattern: types/interfaces that are needed by both sides → extract to a
*-types.tsfile.Before: a.ts ↔ b.ts (cycle) After: a.ts → c.ts ← b.ts (no cycle)Option B — Restructure module boundaries
If the cycle reveals that two modules are too tightly coupled, consider merging them into one or reorganising the dependency direction so it flows one way.
Option C — Dynamic import (last resort only)
A dynamic
import()breaks the static import graph but does NOT eliminate the runtime coupling. Use only when:- The import is genuinely lazy (not needed at module initialisation time)
- Options A and B were considered and ruled out
- The dynamic import MUST carry an explanatory comment:
// Dynamic import: breaks the static cycle between device.ts and auth.ts. // _getStoredDeviceId is only called inside an async function, never at // module load time, so the deferred resolution is safe. const { _getStoredDeviceId } = await import("@/lib/db/auth");Without this comment, the next developer will not understand why dynamic import was used and may remove it, re-introducing the cycle.
-
Report format
Clean:
✓ circular-check — No circular imports (77 files checked)Issues found:
✗ circular-check — N cycles detected Cycle 1: lib/api/config.ts → lib/api/config-parser.ts → lib/api/config.ts Fix: Extract AppConfig/MainMenuItem to lib/api/config-types.ts Cycle 2: ...
Notes
- madge tracks dynamic imports — they are not an automatic exemption. If a dynamic import creates a cycle, it must still be resolved unless Option C is justified and documented.
- Type-only imports (
import type) also form cycles in madge's graph. The fix is the same: extract the shared type to a neutral file. - The
check:circularscript is defined inpackage.json. Do not inline the madge command — use the script so the flags stay in one place.
04 同仓库更多 Skills
setup-git-credentials
Use when the user wants Git to stop using a PAT in the remote URL or a plain-text credential store, wants Git Credential Manager (GCM) with OAuth for GitHub, GitLab or Azure DevOps on Ubuntu/Debian or WSL2, or sees 'cannot persist Microsoft authentication token cache securely' / 'using plain-text fallback token cache'. Asks whether this is WSL, which Git hosts and which parts to set up, checks what is already done, sets git config itself after confirmation and hands every sudo or interactive step (apt, gpg, pass init, secret-tool, first sign-in) to the user. Bundles gcm-keyring-session.sh to start or reuse a D-Bus + GNOME Keyring session without systemd. Trigger terms - git credentials, PAT in URL, token in remote, git credential manager, gcm, github auth, gitlab auth, azure devops auth, pass, gpg store, secret service, gnome keyring, msal token cache, wsl git auth.
setup-flow
Use when onboarding a repository or agent to the standard development workflow — installs the required skills from the ai.skills store, installs or updates a MANDATORY workflow block in the agent's instruction file (CLAUDE.md, AGENTS.md, GEMINI.md, Copilot or Cursor rules), AND configures .claude/settings.json with Serena MCP, sandbox, permissions, hooks, and plugins. Hooks are wired to the context-hooks kit, which speaks once per session instead of injecting text on every turn; re-running replaces earlier inline hooks rather than adding to them. Also writes .vscode/settings.json to hide the empty shell dotfiles an agent sandbox leaves in the repo root. Use when setting up a new repo, switching agents, or refreshing the workflow rules.
developer-flow
Use when starting, implementing, or completing any feature, change, or fix in any software project — at feature start, before writing code, and before claiming a change is done, fixed, working, or green. A strict ordered flow with a gate per phase; stack-agnostic and repo-agnostic (OpenSpec optional, gates discovered).
daily-log-check
Use to check whether everyone on duty filed their Azure DevOps time-log Tasks for a given day, per platform — reports tickets, hours and activities per person against the headcount you give. Fires on "did everyone log yesterday", "check web 4 mobile 3", "who is missing for 8.09", "daily log check". Read-only. Org and project come from configuration.
daily-activity-log
Use at end of day to file the Azure DevOps time-log Tasks — one closed Task per Activity worked that day, Original Estimate in decimal hours, parented to the current sprint's Feature. Fires on "log my day", "fill my tasks", "close my daily tasks", "I had 2h meetings and 4h development". Org and project come from configuration.
conventional-commits
Write commit messages that follow the Conventional Commits specification so tooling can derive versions and changelogs.