representation-envy-refactor

Detect representation envy and suggest refactoring for better encapsulation.

14|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/KentBeck/SmalltalkGenie --skill representation-envy-refactor
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: representation-envy-refactor
Source: https://github.com/KentBeck/SmalltalkGenie/tree/main/.agents/skills/representation-envy-refactor
Command: npx skills add https://github.com/KentBeck/SmalltalkGenie --skill representation-envy-refactor

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill helps identify and refactor code that accesses another object's internal representation, promoting better object ownership and design.

Core Features & Use Cases

  • Identify Representation Envy: Detects code that reads or manipulates another object's internal state.
  • Refactoring Suggestions: Offers guidance on moving behavior to the object that owns the representation.
  • Use Case: When reviewing or refactoring a codebase, this Skill can help identify and correct cases where a class is improperly depending on the internal state of another object.

Quick Start

Analyze the codebase using the representation-envy-refactor skill and follow the suggested refactorings.

Frequently Asked Questions about representation-envy-refactor

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

FAQPage Schema
What is representation envy in code refactoring?

Representation envy occurs when code improperly accesses or manipulates another object's internal state. This Skill detects such method and variable interactions during code reviews and suggests moving behavior to the object that owns the representation.

How do I refactor code to improve object ownership and encapsulation?

To improve object ownership, analyze your codebase to identify where methods improperly depend on another object's internal state. This Skill suggests refactoring guidance to move that behavior directly to the object that owns the representation.

How do I identify code that accesses another object's internal state?

You identify code accessing another object's internal state by analyzing method and variable interactions across your codebase. This Skill automates this detection process to highlight cases where a class improperly depends on external internal state.

Does this code analysis approach work for general code reviews?

Yes, this code analysis approach applies directly to code reviews and refactoring processes. It analyzes method and variable interactions to identify representation envy and suggest improvements for better object design and encapsulation.

When should I not use representation envy refactoring?

You should avoid representation envy refactoring when method and variable interactions do not involve improperly accessing another object's internal state. If object ownership and encapsulation are already correct, this refactoring approach offers no value.