🎁 Get the FREE AI Skills Starter GuideSubscribe →
BytesAgainBytesAgain
🦀 ClawHub

Modularity Health Evaluator

by @quochungto

Assess code modularity health using quantitative metrics — cohesion (LCOM), coupling (afferent/efferent), abstractness, instability, distance from main seque...

When to Use
TriggerAction
- The user has a class with too many methods or responsibilities and wants to evaluate it
- The user has a utility package that everything depends on and wants to understand the risk
- The user is planning to extract microservices and needs to evaluate which modules are cleanly bounded
- The user mentions coupling, cohesion, or dependency problems
- The user sees cascading breakage when changing one module and wants to diagnose why
- The user wants to evaluate whether a codebase is ready for architectural migration
Before starting, verify:
- Is there a specific module, class, or package to evaluate? (At minimum, a description of the component and its dependencies)
- Does the user have access to dependency analysis tooling, or will this be a manual/descriptive assessment?
💡 Examples

Scenario: God class evaluation Trigger: "I have a CustomerService class with 35 methods, 12 instance variables, and methods spanning registration, billing, notifications, and reporting. Is this well-designed?" Process: Cataloged the class. Identified 4 distinct responsibility groups from the method descriptions. Assessed cohesion as logical (methods related by entity, not by function). Estimated LCOM as high — registration methods use fields A,B,C; billing methods use fields D,E,F; notification methods use fields G,H; reporting methods use fields I,J,K,L. Few fields shared across groups. Measured Ca=15 (many dependents), Ce=8. Calculated I=0.35, A=0.0, D=0.65 — deep in zone of pain. Recommended extracting into 4 focused services: CustomerRegistrationService, BillingService, NotificationService, CustomerReportingService. Expected improvement: each new class achieves functional cohesion, LCOM drops to low, and D approaches 0. Output: Modularity health report showing the class is Unhealthy with a specific 4-way decomposition plan.

Scenario: Utility package dependency analysis Trigger: "Our utils package has 200 classes and every other package depends on it. We're afraid to change anything." Process: Identified the utils package as having Ca=high (every package depends on it), Ce=low (it depends on nothing), I=0.0, A~0.05 (almost no interfaces). Plotted directly in zone of pain. Cohesion type: coincidental — date formatters, database helpers, and email templates have no functional relationship. Analyzed connascence: mostly CoN (name-based) from the rest of the codebase, but some CoM (magic numbers shared via utility constants). Recommended: (1) Extract date/time utilities into a DateTimeUtils package with an interface, (2) Move database helpers into a persistence package close to where they're used, (3) Extract email templates into a notification package. Each extraction reduces Ca on the remaining utils and moves code to functionally cohesive homes. Output: Modularity health report with 3-phase decomposition plan and expected zone migration from pain to main sequence.

Scenario: Microservice extraction readiness assessment Trigger: "We have 15 top-level packages in our monolith. Which are ready to extract as microservices?" Process: For each package, measured Ca, Ce, calculated I and A. Assessed cohesion type. Analyzed cross-package connascence. Found 4 packages with functional cohesion, low Ce, and weak cross-boundary connascence (good candidates). Found 3 packages in zone of pain with high Ca (extract last — need abstraction first). Found 2 packages with high CoV (shared transactions — cannot extract without addressing data consistency). Ranked all 15 by extraction readiness score. Recommended extraction order: start with the 4 clean candidates, then refactor the zone-of-pain packages by introducing interfaces, then address shared-transaction packages using saga pattern or shared database strategy. Output: Ranked extraction readiness report with specific blockers and prerequisites for each package.

View on ClawHub
TERMINAL
clawhub install bookforge-modularity-health-evaluator

🧪 Use this skill with your agent

Most visitors already have an agent. Pick your environment, install or copy the workflow, then run the smoke-test prompt above.

🔍 Can't find the right skill?

Search 60,000+ AI agent skills — free, no login needed.

Search Skills →