Evaluate and improve code modularization using the Balanced Coupling Model. Analyzes coupling strength, connascence types, and distance to identify refactoring opportunities and architectural improvements. Use when reviewing code architecture, refactoring modules, or designing new systems.
Analyzes code modularization using the Balanced Coupling Model to identify refactoring opportunities and architectural improvements.
/plugin marketplace add dotneet/claude-code-marketplace/plugin install review-tool@dotneet-marketplaceThis skill inherits all available tools. When active, it can use any tool Claude has access to.
references/connascence-types.mdreferences/coupling-metrics.mdreferences/refactoring-patterns.mdEvaluate 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.mdThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
This skill should be used when the user asks to "create an agent", "add an agent", "write a subagent", "agent frontmatter", "when to use description", "agent examples", "agent tools", "agent colors", "autonomous agent", or needs guidance on agent structure, system prompts, triggering conditions, or agent development best practices for Claude Code plugins.
This skill should be used when the user asks to "create a hook", "add a PreToolUse/PostToolUse/Stop hook", "validate tool use", "implement prompt-based hooks", "use ${CLAUDE_PLUGIN_ROOT}", "set up event-driven automation", "block dangerous commands", or mentions hook events (PreToolUse, PostToolUse, Stop, SubagentStop, SessionStart, SessionEnd, UserPromptSubmit, PreCompact, Notification). Provides comprehensive guidance for creating and implementing Claude Code plugin hooks with focus on advanced prompt-based hooks API.