What problem does it solve?
This Skill prevents "abstraction leaks" where internal implementation details (like database schemas, file formats, or raw data structures) are exposed through public interfaces. It ensures that client code interacts at a high-level, domain-specific "what" rather than a low-level "how," making systems more flexible, maintainable, and resilient to change.
Core Features & Use Cases
- Information Hiding: Guides you to design interfaces that expose only what a component does, not how it achieves it.
- Domain-Level Interaction: Encourages working with domain objects (e.g.,
User, Order) instead of raw data structures (e.g., dict, SQL row).
- Implementation Agnosticism: Ensures that changing internal implementation (e.g., switching from JSON to YAML, or PostgreSQL to MongoDB) does not break client code.
- Encapsulation Test: Provides a set of questions to rigorously evaluate if an interface is truly encapsulating its complexity.
- Use Case: Instead of a
ConfigManager that exposes json_path and save_to_json(), this skill guides you to create a Config class with get_timeout() and save() methods, hiding the underlying storage format.
Quick Start
I'm designing a UserRepository class. Guide me through applying the "Encapsulating Complexity" skill. Help me design its interface to hide the underlying database implementation (e.g., SQL queries, ORM details) and expose only domain-level operations like get_user_by_id or save_user.