重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
code-modularization-evaluator by dotneet/claude-code-marketplace
npx skills add https://github.com/dotneet/claude-code-marketplace --skill code-modularization-evaluator使用 Vlad Khononov 的《软件设计中的平衡耦合》中的平衡耦合模型来评估代码模块化。此技能有助于识别有问题的耦合模式,并提供可操作的重构指导。
耦合本身并不坏——设计不当的耦合才是坏的。 目标是平衡耦合,而非零耦合。
基本公式:
MODULARITY = (STRENGTH XOR DISTANCE) OR NOT VOLATILITY
当满足以下条件时,系统即实现模块化:
始终从以下三个维度评估耦合:
从最强(最差)到最弱(最好):
| 级别 | 类型 | 描述 | 示例 |
|---|---|---|---|
| 1 | 侵入式 | 使用非公开接口 | 直接访问另一服务的数据库,通过反射访问私有字段 |
| 2 | 功能性 | 共享业务逻辑/规则 | 两处重复相同的验证逻辑,存在顺序依赖的操作 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 3 | 模型 | 共享领域模型 | 两个服务使用相同的实体定义 |
| 4 | 契约 | 仅通过显式接口 | 设计良好的 API、DTO、协议 |
从最近到最远:
使用领域驱动设计的子域分类:
评估代码时,应用此矩阵:
| 集成强度 | 距离 | 结果 |
|---|---|---|
| 高 | 高 | ❌ 复杂度(分布式单体) |
| 低 | 低 | ❌ 复杂度(不必要的抽象) |
| 高 | 低 | ✅ 模块化(相关事物在一起) |
| 低 | 高 | ✅ 模块化(独立组件分离) |
例外:如果波动性为低,则耦合不匹配是可接受的。
使用共生性来识别特定的耦合类型。详细示例请参见 references/connascence-types.md。
按从弱到强排序:
按从弱到强排序: 6. 执行共生:方法调用顺序很重要 7. 时序共生:执行时序很重要 8. 值共生:多个值必须一起变更 9. 标识共生:必须引用同一实例
分析代码时,检查是否存在:
a.b().c().d()(违反德米特法则)侵入式 → 契约耦合:
功能性 → 模型耦合:
模型 → 契约耦合:
| 从 | 到 | 技术 |
|---|---|---|
| 含义共生 | 名称共生 | 用命名常量/枚举替换魔法值 |
| 位置共生 | 名称共生 | 使用命名参数、建造者模式或参数对象 |
| 算法共生 | 名称共生 | 将算法提取到单一位置,通过名称引用 |
| 类型共生 | 名称共生 | 使用鸭子类型或接口 |
| 执行共生 | 显式化 | 使用状态机、建造者模式或构造函数注入 |
| 标识共生 | 显式化 | 使用依赖注入并显式配置 |
高强度 + 高距离(分布式单体):
低强度 + 低距离(过度抽象):
当被要求评估代码模块化时:
映射组件结构
评估集成强度
测量距离
评估波动性
应用公式
识别共生性
提出建议
将评估结果组织为:
## 模块化评估
### 摘要
[耦合健康状况的简要概述]
### 组件映射
[描述模块/服务结构]
### 耦合分析
| 组件对 | 强度 | 距离 | 波动性 | 平衡性 |
|---------------|----------|----------|------------|---------|
| A → B | 模型 | 高 | 高 | ❌ |
### 共生性问题
1. [特定共生性类型]: [位置] - [影响]
### 建议
1. **优先级 1**: [行动] - [理由]
2. **优先级 2**: [行动] - [理由]
### 重构计划
[针对最高优先级项目的分步方法]
references/connascence-types.mdreferences/coupling-metrics.mdreferences/refactoring-patterns.md每周安装数
59
仓库
首次出现
2026年1月21日
安全审计
安装于
claude-code46
codex41
opencode41
gemini-cli40
github-copilot33
cursor32
Evaluate code modularization using the Balanced Coupling Model from Vlad Khononov's "Balancing Coupling in Software Design." This skill helps identify problematic coupling patterns and provides actionable refactoring guidance.
Coupling is not inherently bad—misdesigned coupling is bad. The goal is balanced coupling, not zero coupling.
The fundamental formula:
MODULARITY = (STRENGTH XOR DISTANCE) OR NOT VOLATILITY
A system achieves modularity when:
Always evaluate coupling across these three dimensions:
From strongest (worst) to weakest (best):
| Level | Type | Description | Example |
|---|---|---|---|
| 1 | Intrusive | Using non-public interfaces | Direct database access to another service, reflection on private fields |
| 2 | Functional | Sharing business logic/rules | Same validation duplicated in two places, order-dependent operations |
| 3 | Model | Sharing domain models | Two services using identical entity definitions |
| 4 | Contract | Only explicit interfaces | Well-designed APIs, DTOs, protocols |
From closest to most distant:
Use Domain-Driven Design subdomain classification:
When evaluating code, apply this matrix:
| Integration Strength | Distance | Result |
|---|---|---|
| High | High | ❌ COMPLEXITY (Distributed monolith) |
| Low | Low | ❌ COMPLEXITY (Unnecessary abstraction) |
| High | Low | ✅ MODULARITY (Related things together) |
| Low | High | ✅ MODULARITY (Independent components apart) |
Exception : If volatility is LOW, coupling mismatches are acceptable.
Use connascence to identify specific coupling types. See references/connascence-types.md for detailed examples.
Ordered weakest to strongest:
Ordered weakest to strongest: 6. Execution (CoE) : Order of method calls matters 7. Timing (CoTm) : Timing of execution matters 8. Value (CoV) : Multiple values must change together 9. Identity (CoI) : Must reference same instance
When analyzing code, check for:
a.b().c().d() (Law of Demeter violation)Intrusive → Contract Coupling :
Functional → Model Coupling :
Model → Contract Coupling :
| From | To | Technique |
|---|---|---|
| CoM (Meaning) | CoN (Name) | Replace magic values with named constants/enums |
| CoP (Position) | CoN (Name) | Use named parameters, builder pattern, or parameter objects |
| CoA (Algorithm) | CoN (Name) | Extract algorithm to single location, reference by name |
| CoT (Type) | CoN (Name) | Use duck typing or interfaces |
| CoE (Execution) | Explicit | Use state machines, builder pattern, or constructor injection |
| CoI (Identity) | Explicit | Use dependency injection with explicit wiring |
High Strength + High Distance (Distributed Monolith):
Low Strength + Low Distance (Over-abstraction):
When asked to evaluate code modularization:
Map the component structure
Assess Integration Strength
Measure Distance
Evaluate Volatility
Apply the formula
Identify Connascence
Recommend actions
Structure your evaluation as:
## Modularization Assessment
### Summary
[Brief overview of coupling health]
### Component Map
[Describe module/service structure]
### Coupling Analysis
| Component Pair | Strength | Distance | Volatility | Balance |
|---------------|----------|----------|------------|---------|
| A → B | Model | High | High | ❌ |
### Connascence Issues
1. [Specific connascence type]: [Location] - [Impact]
### Recommendations
1. **Priority 1**: [Action] - [Rationale]
2. **Priority 2**: [Action] - [Rationale]
### Refactoring Plan
[Step-by-step approach for highest-priority item]
references/connascence-types.mdreferences/coupling-metrics.mdreferences/refactoring-patterns.mdWeekly Installs
59
Repository
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
claude-code46
codex41
opencode41
gemini-cli40
github-copilot33
cursor32
Flutter/Dart代码审查最佳实践:提升应用性能与质量的完整检查清单
1,100 周安装
Godot 游戏开发技能详解:场景树、节点类型、GDScript 与 MCP 工具
471 周安装
加密货币研究报告技能:代币经济学、协议机制、链上指标与投资分析
477 周安装
使用 PptxGenJS 创建专业幻灯片 - 支持 .pptx 和 .js 源文件生成,提升演示文稿开发效率
474 周安装
发票模板生成技能 - 使用Python ReportLab快速创建专业PDF发票,支持批量生成与定制
481 周安装
代码重构与整洁专家 - 提升代码质量、可维护性和性能的AI助手
478 周安装
Nx Import 使用指南:从源仓库导入代码并保留Git历史
474 周安装