Maintaining Consistent Abstractions

Enforce one cohesive abstraction per class during design and code reviews.

41|27|Updated Oct 6, 2025
One-click install
npx skills add https://github.com/obra/clank --skill maintaining-consistent-abstractions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Maintaining Consistent Abstractions
Source: https://github.com/obra/clank/tree/main/skills/architecture/maintaining-consistent-abstractions
Command: npx skills add https://github.com/obra/clank --skill maintaining-consistent-abstractions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill eliminates poorly designed classes that mix multiple responsibilities, making code difficult to understand, maintain, and extend.

Core Features & Use Cases

  • Abstraction Analysis: Identify when classes mix domain logic with serialization, persistence, or unrelated concerns.
  • Refactoring Guidance: Provides specific patterns to separate mixed concerns into focused classes.
  • Use Case: When reviewing an Employee class that contains both business logic methods like calculate_annual_salary() and serialization methods like to_json().

Quick Start

Analyze this class for abstraction consistency: class Employee { calculateAnnualSalary() { return this.salary * 12; } toJSON() { return JSON.stringify({...}); } }

Frequently Asked Questions about Maintaining Consistent Abstractions

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

FAQPage Schema
How do I identify when a class is mixing too many responsibilities?

A class mixes responsibilities when it combines domain logic with unrelated concerns like serialization, persistence, or formatting. For example, an Employee class with both calculateAnnualSalary() and toJSON() methods violates single responsibility. Each concern should live in its own focused class to maintain cohesion and separation of concerns.

What's the best way to separate serialization from business logic in a class?

Extract serialization into dedicated serializer classes rather than adding toJSON() or toString() methods to your domain class. This keeps domain logic pure and lets you serialize the same object in multiple formats without bloating the original class. Repositories handle persistence the same way.

When should I refactor a class to enforce single abstractions?

Refactor during class design, code reviews, or when extending existing classes. Watch for classes where domain methods like calculate() sit alongside persistence methods like save() or serialization methods like toJSON(). These mixed concerns are prime refactoring targets to improve maintainability.

Why does mixing domain logic with persistence hurt code quality?

Mixed concerns make classes harder to understand, test, and modify. Changes to how you store data shouldn't require touching business logic. Separation of concerns ensures each class has one reason to change, reducing bugs and making the codebase easier to extend.

Can I apply abstraction consistency to existing codebases?

Yes. Analyze existing classes for mixed concerns during refactoring or code review cycles. Identify where domain logic, serialization, and persistence overlap, then extract each concern into its own class or dedicated component. This improves temporal cohesion gradually.

What's the relationship between single abstractions and API design?

Clean API design depends on single-purpose abstractions. When each class represents one cohesive idea, your API contracts become clear and stable. Mixed abstractions create confusing interfaces that force consumers to understand multiple unrelated concerns.