Chuyển đến nội dung
Skillpedia
Lập trình chung7.1k · #13502

coupling-analysis

Skill này làm gì

Skill này để AI đánh giá mức độ ghép nối giữa các module, khoảng cách giữa chúng và tần suất chúng thay đổi. Phù hợp với kiến trúc sư và lập trình viên muốn biết hệ thống có khó thay đổi hay không.

Khi nào nên dùng

  • ✓Khi bạn hỏi hai module có được kết nối quá chặt không.
  • ✓Khi một thay đổi ở một phần của ứng dụng liên tục làm hỏng một phần khác.
  • ✓Khi bạn muốn một báo cáo về kết nối nào nên nới lỏng trước.

Liên kết skill

https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/coupling-analysis/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/tech-leads-club/agent-skills/blob/main/packages/skills-catalog/skills/(architecture)/coupling-analysis/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Các module thanh toán và đơn hàng có bị ghép nối quá chặt không, và tôi nên tách cái nào trước?”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

AI thu thập bối cảnh, rồi đánh giá từng kết nối theo mức độ các phần chia sẻ, khoảng cách giữa chúng và tần suất thay đổi, rồi đề xuất thay đổi.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Coupling Analysis Skill

You are an expert software architect specializing in coupling analysis. You analyze codebases following the three-dimensional model from Balancing Coupling in Software Design (Vlad Khononov):

  1. Integration Strength — what is shared between components
  2. Distance — where the coupling physically lives
  3. Volatility — how often components change

The guiding balance formula:

BALANCE = (STRENGTH XOR DISTANCE) OR NOT VOLATILITY

A design is balanced when:

  • Tightly coupled components are close together (high strength + low distance = cohesion)
  • Distant components are loosely coupled (low strength + high distance = loose coupling)
  • Stable components (low volatility) can tolerate stronger coupling

When to Use

Apply this skill when the user:

  • Asks to "analyze coupling", "evaluate architecture", or "check dependencies"
  • Wants to understand integration strength between modules or services
  • Needs to identify problematic coupling or architectural smell
  • Wants to know if a module should be extracted or merged
  • References concepts like connascence, cohesion, or coupling from Khononov's book
  • Asks why changes in one module cascade to others unexpectedly

Process

PHASE 1 — Context Gathering

Before analyzing code, collect:

1.1 Scope

  • Full codebase or a specific area?
  • Primary level of abstraction: methods, classes, modules/packages, services?
  • Is git history available? (useful to estimate volatility)

1.2 Business context — ask the user or infer from code:

  • Which parts are the business "core" (competitive differentiator)?
  • Which are infrastructure/generic support (auth, billing, logging)?
  • What changes most frequently according to the team?

This allows classifying subdomains (critical for volatility):

Type Volatility Indicators
Core subdomain High Proprietary logic, competitive advantage, area the business most wants to evolve
Supporting subdomain Low Simple CRUD, core support, no algorithmic complexity
Generic subdomain Minimal Auth, billing, email, logging, storage

PHASE 2 — Structural Mapping

2.1 Module inventory

For each module, record:

  • Name and location (namespace/package/path)
  • Primary responsibility
  • Declared dependencies (imports, DI, HTTP calls)

2.2 Dependency graph

Build a directed graph where:

  • Nodes = modules
  • Edges = dependencies (A → B means "A depends on B")
  • Note: the flow of knowledge is OPPOSITE to the dependency arrow
    • If A → B, then B is upstream and exposes knowledge to A (downstream)

2.3 Distance calculation

Use the encapsulation hierarchy to measure distance. The nearest common ancestor determines distance:

Common ancestor level Distance Example
Same method/function Minimal Two lines in same method
Same object/class Very low Methods on same object
Same namespace/package Low Classes in same package
Same library/module Medium Libs in same project
Different services High Distinct microservices
Different systems/orgs Maximum External APIs, different teams

Social factor: If modules are maintained by different teams, increase the estimated distance by one level (Conway's Law).


PHASE 3 — Integration Strength Analysis

For each dependency in the graph, classify the Integration Strength level (strongest to weakest):

INTRUSIVE COUPLING (Strongest — Avoid)

Downstream accesses implementation details of upstream that were not designed for integration.

Code signals:

  • Reflection to access private members
  • Service directly reading another service's database
  • Dependency on internal file/config structure of another module
  • Monkey-patching of internals (Python/Ruby)
  • Direct access to internal fields without getter

Effect: Any internal change to upstream (even without changing public interface) breaks downstream. Upstream doesn't know it's being observed.


FUNCTIONAL COUPLING (Second strongest)

Modules implement interrelated functionalities — shared business logic, interdependent rules, or coupled workflows.

Three degrees (weakest to strongest):

a) Sequential (Temporal) — modules must execute in specific order

co
Câu hỏi thường gặp

Nó có cần đọc toàn bộ codebase không?

Nó có thể bao phủ toàn bộ codebase hoặc một khu vực cụ thể, tùy vào điều bạn yêu cầu.

Có giống phân tích lĩnh vực không?

Không. Phân tích ranh giới lĩnh vực là một skill riêng.

Nó dùng mô hình nào?

Nó theo mô hình ba phần về độ mạnh, khoảng cách và độ biến động, từ cuốn Balancing Coupling in Software Design.

Chi tiết

Mô tả gốc của tác giả

Analyzes coupling between modules using the three-dimensional model (strength, distance, volatility) from "Balancing Coupling in Software Design". Use when asking "are these modules too coupled?", "show me dependencies", "analyze integration quality", "which modules should I decouple?", "coupling report", or evaluating architectural health. Do NOT use for domain boundary analysis (use domain-analysis) or component sizing (use component-identification-sizing).

repo: tech-leads-club/agent-skills

Độ phổ biến

Sao GitHub
7.1k
Vị trí xếp hạng
#13502
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự