solid-liskov-substitution

solid-liskov-substitution is a skill for Claude Code from helmedeiros/clean-code-skills. It costs 54 tokens per session (748 once invoked), scanned A, original, MIT.

A guide to the Liskov Substitution Principle, a rule that says a subtype should be usable wherever its parent type is expected without breaking the program.

In plain words
What is it for?
Use it when designing or reviewing class hierarchies, overridden methods, subtype behavior, or code that checks concrete types with instanceof.
Why use it?
It helps reveal inheritance designs where a subclass changes promised behavior and makes code unreliable.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the clean-code-skills plugin — 21 skills, 2 commands shipped together

Good fit Use it when designing or reviewing class hierarchies, overridden methods, subtype behavior, or code that checks concrete types with instanceof.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/helmedeiros/clean-code-skills/solid-liskov-substitution
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add helmedeiros/clean-code-skills --skill solid-liskov-substitution
Clone the repo
git clone --depth 1 https://github.com/helmedeiros/clean-code-skills

Made for: Claude Code.

Or install clean-code-skills, the plugin that ships this one along with the rest of its 21 skills, 2 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for solid-liskov-substitution

README.md
[![agentmods](https://agentmods.dev/badge/skills/helmedeiros/clean-code-skills/solid-liskov-substitution/github.svg)](https://agentmods.dev/skills/helmedeiros/clean-code-skills/solid-liskov-substitution)
Your own site
<a href="https://agentmods.dev/skills/helmedeiros/clean-code-skills/solid-liskov-substitution"><img src="https://agentmods.dev/badge/skills/helmedeiros/clean-code-skills/solid-liskov-substitution/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for solid-liskov-substitution

Your own site · 80×15
<a href="https://agentmods.dev/skills/helmedeiros/clean-code-skills/solid-liskov-substitution"><img src="https://agentmods.dev/badge/skills/helmedeiros/clean-code-skills/solid-liskov-substitution.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 54 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 748 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00054 $0.00748
Opus 5 $0.00027 $0.00374
Sonnet 5 $0.00011 $0.00150
Haiku 4.5 $0.00005 $0.00075

Measured 8d ago against content hash f57eaa70d730, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

solid-liskov-substitution scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/solid-liskov-substitution/SKILL.md · 73 lines

How it starts

The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.

SOLID: Liskov Substitution Principle

Verify that subtypes can replace their base types without altering the correctness of the program — every subclass must honor the contract of its parent.

When This Skill Applies

  • Designing or reviewing inheritance hierarchies
  • A subclass overrides a method in a way that changes expected behavior
  • Runtime errors or bugs appear when substituting a derived type
  • The user mentions LSP, Liskov substitution, or behavioral subtyping
  • Code uses instanceof checks to handle different subtypes differently

Core Principle

If S is a subtype of T, then objects of type T can be replaced with objects of type S without altering any of the desirable properties of the program. Subtypes must honor the base type's contract: same preconditions (or weaker), same postconditions (or stronger), and preserved invariants. Violations create fragile hierarchies where polymorphism becomes unreliable.

Workflow

Step 1: Define the Base Contract

Document the base type's contract: what preconditions callers must satisfy, what postconditions the method guarantees, and what invariants the class maintains.

Step 2: Check Each Subtype

For every overriding method in each subtype, verify:

  • Preconditions are not strengthened (subtype must accept everything the base accepts)
  • Postconditions are not weakened (subtype must guarantee at least what the base guarantees)
  • Invariants are preserved (subtype does not break class-level rules)

Step 3: Test Substitutability

Write tests using the base type reference. Run them with every subtype. All must pass without modification.

Step 4: Fix Violations

If a subtype cannot honor the base contract, it should not extend that base. Use composition instead, or redesign the hierarchy.

Detection / Indicators

  • A subclass throws an exception where the base class does not
  • A subclass ignores or no-ops a base class method
  • Code checks instanceof before calling a method
  • A subclass has stricter input validation than its parent
  • Overridden methods return different types or null where the parent returns a value
  • The "is-a" relationship feels forced: "is a Square a Rectangle?"

Read the full file on GitHub · 73 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 73 lines · 54 tokens per session scan A f57eaa70d730

Subscribe to this mod's changes

solid-liskov-substitution is a skill published in the GitHub repository helmedeiros/clean-code-skills (2 stars, last pushed 6mo ago), licensed MIT. It adds 54 tokens to every session and 748 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

fp-brief

First-principles briefing from technical documents. Use when: understanding why decisions were made, onboarding to feature reasoning, reviewing decision chains, explaining doc from first principles. Not for: PM/CTO summary (use project-brief), pre-doc analysis (use feasibility-study), code explanation (use…

sd0xdev/sd0x-harness · 77 tokens

codex-explain

Explain complex code via Codex exec. Use when: understanding complex logic, tracing data flow, onboarding to unfamiliar code. Not for: code review (use codex-code-review), exploration (use code-explore). Output: structured explanation at chosen depth.

sd0xdev/sd0x-harness · 56 tokens

sharingan

Replicate knowledge from any source as sd0x-dev-flow skill definition. Use when: copying skills from repos, adapting patterns from articles/papers/code, converting knowledge to skill format. Not for: research without skill output (use deep-research), creating skills from scratch (use skill-creator), project onboarding…

sd0xdev/sd0x-harness · 87 tokens

creating-explainers

Use when creating an interactive explainer - a single self-contained HTML page with hand-built Canvas figures. Handles source-file explainers, topic-driven research explainers, and mixed intake where files provide the spine and research adds support. Trigger phrases include "make an explainer", "turn this paper into…

analyticalmonk/explain-this · 98 tokens

explaining-codebases

Use when creating an interactive explainer about a codebase, repository, or source files. Handles onboarding overviews, architecture maps, and deep-dives on real implementation paths. Trigger phrases include "explain this codebase", "interactive guide to this repo", "walk through how X works in the code", or…

analyticalmonk/explain-this · 84 tokens

openehr-assistant

This skill should be used when a conversation touches openEHR outside a task owned by a dedicated skill — e.g. "what is an archetype?", "how do openEHR templates work?", "which composition category fits this data?", "find me a guide on X", "where do I start with openEHR modeling?" — or names openEHR concepts (ADL…

Cadasto/openehr-assistant-plugin · 182 tokens