From software-design
Use when reviewing or refactoring object coupling caused by train-wreck call chains and knowledge of nested internals. Applies the Law of Demeter / Principle of Least Knowledge to move behavior closer to the owning object. Trigger for chained calls, dot chains, train wrecks, high coupling, Feature Envy, or reducing object navigation.
How this skill is triggered — by the user, by Claude, or both
Slash command
/software-design:j5ik2o-law-of-demeterThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Talk to direct collaborators, not strangers reached through them.
Talk to direct collaborators, not strangers reached through them.
Find call chains such as a.getB().getC().doX() and code that navigates object structure.
Identify the decision or behavior being performed by the caller.
Move that behavior to the object that owns the needed knowledge.
Replace navigation with intention-revealing methods.
Keep DTO, builder, and fluent API exceptions explicit; not every chain is a domain coupling problem.
Train wrecks expose structure and make callers fragile.
Repeated navigation paths usually indicate a missing method.
Getters used only to make a decision are Tell Don't Ask candidates.
Read references/patterns.md for refactoring patterns and exceptions.
For non-trivial implementation, review, or refactoring work, read references/details.md before giving final guidance. It contains the detailed rules, examples, smells, and migration notes that do not belong in the short invocation body.
Return the chain, the hidden behavior, the target owner, and replacement code.
npx claudepluginhub j5ik2o/ai-tools --plugin software-designIdentifies and fixes Law of Demeter violations (train wrecks) where code chains method calls through intermediate objects, reducing coupling and improving maintainability.
Use when reviewing or refactoring code that queries object state and makes decisions outside the object that owns the data. Moves behavior to the responsible object to improve encapsulation. Trigger for getter misuse, Feature Envy, Tell Don't Ask, encapsulation improvements, or moving responsibility into domain objects.
Proven refactoring patterns (Extract Method, Replace Temp, Introduce Parameter Object) to improve code structure safely. Use when improving existing code while keeping behavior unchanged.