Get the FREE Ultimate OpenClaw Setup Guide →

abstraction-quality

Scanned
npx machina-cli add skill codybrom/clairvoyance/abstraction-quality --openclaw
Files (1)
SKILL.md
4.0 KB

Abstraction Quality Review Lens

When invoked with $ARGUMENTS, focus the analysis on the specified file or module. Read the target code first, then apply the checks below.

Evaluate whether abstractions are genuine (hiding complexity) or false (adding layers without reducing what callers must know).

When to Apply

  • Reviewing class hierarchies or layered architectures
  • When an abstraction feels like it adds complexity rather than reducing it
  • When decorator or wrapper patterns are used
  • When two layers seem to operate at the same level of abstraction

Core Principles

Genuine vs. False Abstraction Test

Can callers forget what's underneath? If yes, it's genuine. If callers must peek through to use it correctly, it's false.

Two Ways Abstractions Fail

  • Including unimportant details: The interface leaks implementation concerns. Shows up as wide interfaces, excessive parameters. More common, at least visible.
  • Omitting important details: The interface hides something callers need. More dangerous because it signals nothing. The abstraction appears clean, inviting trust it doesn't deserve.

A file system can safely hide which disk blocks store data. It cannot hide flush rules for durable storage. Databases depend on that guarantee.

Different Layer, Different Abstraction

Each layer should provide a fundamentally different way of thinking about the problem. If two adjacent layers have similar methods, similar parameters, similar concepts, the layering adds cost without value.

Check: compare the interface of each layer. Are they at different conceptual levels? Or is one just a thin rephrasing of the other?

Decorator Pattern Trap

Decorators are structurally committed to shallowness. A decorator that adds one behavior to a class with twenty methods has nineteen pass-throughs and one meaningful method.

Four alternatives before creating a decorator:

  1. Add the functionality directly to the underlying class
  2. Merge with the use case
  3. Merge with an existing decorator
  4. Implement as a standalone class

Ask whether the new functionality really needs to wrap the existing functionality. If not, implement it independently.

Resolving False Abstractions

When a false abstraction is detected:

  1. Redistribute: Move functionality between layers so each has a distinct, coherent responsibility
  2. Merge: Combine adjacent layers into one deeper layer
  3. Expose: Remove the abstraction. Let callers use the underlying layer directly

Review Process

  1. Map layers: Identify the abstraction layers under review
  2. Compare adjacent layers: Do they provide different mental models?
  3. Test each abstraction: Can callers forget what's underneath?
  4. Audit decorators/wrappers: Adding depth or just adding a layer?
  5. Check pass-throughs: Any methods or variables that just forward without contributing? (See deep-modules for pass-through audits, interface-vs-implementation checks, and when signature duplication is legitimate.)
  6. Resolve: Redistribute, merge, or expose

Relationship to Other Lenses

This skill asks "is the abstraction genuine?": does each layer provide a different way of thinking? deep-modules asks the follow-up: "is the module deep enough?": does the interface justify what's behind it? A layer can provide a genuinely different abstraction and still be shallow. Use this skill first to evaluate layer structure, then deep-modules to evaluate depth within each layer.

Source

git clone https://github.com/codybrom/clairvoyance/blob/main/skills/abstraction-quality/SKILL.mdView on GitHub

Overview

This lens assesses whether abstractions truly change how you think about a problem or merely add boilerplate. Use it when adjacent layers feel redundant, when decorators wrap with little depth, or when an abstraction leaks details. It is not intended to measure a single module's interface-to-implementation ratio (use deep-modules) or to check for cross-boundary information leakage (use information-hiding).

How This Skill Works

Read the target module, map each abstraction layer, and assess whether callers can forget what's underneath. Check that adjacent layers provide different mental models and audit decorators for depth vs pass-throughs. If a false abstraction is found, apply Redistribution, Merge, or Expose and re-check.

When to Use It

  • Reviewing class hierarchies or layered architectures
  • When an abstraction feels like it adds complexity rather than reducing it
  • When decorator or wrapper patterns are used
  • When two layers seem to operate at the same level of abstraction
  • When an abstraction leaks or hides critical details from callers

Quick Start

  1. Step 1: Open the target file or module specified by ARGUMENTS
  2. Step 2: Map abstraction layers, test forgetfulness, and audit decorators for depth
  3. Step 3: If false abstractions are detected, apply Redistribution, Merge, or Expose and re-evaluate

Best Practices

  • Map abstraction layers and identify the mental models each provides
  • Test whether callers can forget what's underneath; if not, the abstraction is likely false
  • Audit decorators and wrappers for meaningful behavior vs pass-throughs
  • Compare adjacent layers for genuine differences in concepts and avoid duplication
  • If false abstractions are found, redistribute, merge, or expose to restore clarity

Example Use Cases

  • A decorator wraps a class with 20 methods but only adds one new behavior (19 pass-throughs), illustrating a potential false abstraction
  • Two adjacent layers expose similar interfaces with little conceptual difference, signaling unnecessary layering
  • A filesystem facade hides disk-block layout but cannot hide durable storage flush rules, revealing a leakage across boundaries
  • A data access layer masks SQL complexity but preserves the same surface area, offering little abstraction payoff
  • Merging multiple shallow layers into a single deeper layer to reduce surface area and cognitive load

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers