界面已本地化;技能介绍与说明文档按所选语言由 AI 自动翻译,代码、命令、路径和专业术语保留原文,以原作者文档为准。
探索技能
设计与创意 · SKILL.md

deps

deps

【设计与创意】Visualize the project dependency graph and detect circular dependencies. Use this before refactoring, during architecture reviews, before adding new domains, or when evaluating module separation. Trigger immediately when cross-domain coupling seems high or circular references are suspected. Triggers on /deps, "dependency graph", or "check circular de…

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: deps description: Visualize the project dependency graph and detect circular dependencies. Use this before refactoring, during architecture reviews, before adding new domains, or when evaluating module separation. Trigger immediately when cross-domain coupling seems high or circular references are suspected. Triggers on /deps, "dependency graph", or "check circular dependencies". version: 1.1.0 updated: 2026-02-11

Dependency Graph Analysis

Visualize dependency relationships across the project, detect circular dependencies, and analyze coupling between domains.


Skill Triggers

  • /deps — Analyze all domain dependencies
  • /deps <domain> — Dependencies for a specific domain
  • /deps --cycles — Detect circular dependencies only
  • /deps <file> --tree — Dependency tree for a file
  • /deps --matrix — Cross-domain dependency matrix
  • "show me the dependency graph"
  • "check for circular dependencies"

Absolute Prohibitions

  1. Do not modify code — analysis only.
  2. Do not guess at dependencies — always parse actual import/require statements.
  3. Do not ignore circular dependencies — report any that are found.

Execution Steps

Receive /deps [target] [options]
    |
    v
[1] Scope Resolution
    |
    v
[2] Domain Discovery
    |
    v
[3] Import/Require Parsing (Dependency Extraction)
    |
    v
[4] Graph Construction
    |
    v
[5] Cycle Detection
    |
    v
[6] Cross-Domain Coupling Analysis
    |
    v
[7] Output results

Step 1: Scope Resolution

InputScope
(none)All project domains
Domain nameThat domain's internal + external dependencies
File + --treeFile's dependency tree

Step 2: Domain Discovery

Domain identification criteria (in priority order):

  1. domains definition in .claude/project-team.yaml
  2. domains/<domain-name>/ directory
  3. src/<domain-name>/ directory
  4. Top-level meaningful directories

Layers vs. Domains:

  • Layers (not domains): api/, services/, models/, utils/
  • Domains (analysis targets): order/, member/, product/, payment/

Step 3: Import/Require Parsing

LanguagePattern
Pythonfrom x.y import z, import x.y
JS/TSimport ... from '...', require('...')
Goimport "..."
# Python
grep -rn "^from \|^import " --include="*.py" <target-path>

# JS/TS
grep -rn "import.*from\|require(" --include="*.ts" --include="*.js" <target-path>

Step 4: Graph Construction

Node: Domain or module
Edge: Dependency relationship (directed)
  - from: the depending side
  - to:   the depended-on side
  - weight: number of imports

Step 5: Cycle Detection (DFS-based)

LevelDescriptionSeverity
Domain levelA -> B -> ACRITICAL
Module levelA -> B -> C -> AHIGH
File levelA <-> BMEDIUM

Step 6: Coupling Analysis

MetricDescriptionCalculation
Ca (Afferent)Incoming dependency countNumber of external domains that depend on this domain
Ce (Efferent)Outgoing dependency countNumber of external domains this domain depends on
I (Instability)Instability indexCe / (Ca + Ce)
GradeCross-dependenciesAssessment
Loose0–2Healthy
Moderate3–5Manageable
Tight6–10Consider refactoring
Tangled11+Refactoring required

Step 7: Output

See references/output-formats.md for detailed output format.


Architecture File Generation

Analysis results are saved to .claude/architecture/dependencies/:

  • domain-graph.mmd — Mermaid diagram
  • module-graph.json — Module-level dependencies
  • api-graph.json — API call relationships

Relationship with the Impact Skill

Aspect/impact/deps
Analysis unitSingle fileDomain / full project
Primary outputImpact reportMermaid diagram
Core functionChange impact scopeCircular deps, coupling
PurposePre-change analysisArchitecture review

Related Skill Integration

SkillWhen to LinkPurpose
/impact <file>When circular dependency is foundCheck file-level impact
/changelog <domain>When dependency changes occurRecent change history
/architectureAfter full analysisUpdate architecture documents

Reference Documents

  • references/output-formats.md — Output format details
  • references/examples.md — Usage examples
我的收藏