law-of-demeter

Enforce the Law of Demeter during code reviews and architectural decisions.

6|2|Updated Feb 28, 2026
One-click install
npx skills add https://github.com/JordanCoin/codingskills --skill law-of-demeter-jordancoin
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: law-of-demeter
Source: https://github.com/JordanCoin/codingskills/tree/main/skills/law-of-demeter
Command: npx skills add https://github.com/JordanCoin/codingskills --skill law-of-demeter-jordancoin

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill helps teams reduce deep object coupling by enforcing the Law of Demeter during code reviews and design decisions.

Core Features & Use Cases

  • Enforces the principle that code should talk to its immediate collaborators only.
  • Detects deep call chains and suggests refactors to simpler interfaces.
  • Provides concrete examples, anti-patterns, and a practical code-review checklist.

Quick Start

Ask the agent to identify places where a call chain crosses object boundaries and propose LoD-compliant alternatives.

Frequently Asked Questions about law-of-demeter

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I fix deep object coupling and chained calls in my codebase?

To fix deep object coupling, you must limit objects to interacting only with their immediate collaborators. Enforcing this principle during code reviews detects deep call chains and suggests refactoring them into simpler, decoupled interfaces.

What is the Law of Demeter and when should I apply it?

The Law of Demeter is an object-oriented design principle dictating that a function should only talk to itself, its parameters, created objects, or global services. You should apply it during feature development and refactoring to prevent feature envy and reduce module breakage.

How do I enforce object-oriented design principles during PR reviews?

You can enforce object-oriented design principles during PR reviews by applying a code-review checklist that flags chained calls crossing object boundaries. This process identifies feature envy risks and proposes compliant alternatives to improve code clarity.

Does the Law of Demeter rule apply to architectural boundaries and external APIs?

Yes, the Law of Demeter applies to architectural boundaries by requiring you to wrap external APIs at system edges. This limits object coupling across different layers and modules, ensuring components communicate only through direct, compliant interfaces.

What's the best way to refactor code that violates object coupling limits?

The best way to refactor code violating object coupling limits is to identify where call chains cross object boundaries and wrap those external interactions. This shifts dependencies to immediate collaborators, yielding simpler interfaces and improved code clarity.