applying-solid-principles
Skill1 starsChanged 2 months agoMITView on GitHub
Use when designing or reviewing Python class hierarchies, protocols, interfaces, service boundaries, or dependency direction for SOLID-related maintainability risks.
In this repository7 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- bounded-loopsSkill
- limiting-nestingSkill
- review-code-qualitySkill
- using-power-of-tenSkill
- writing-docstringsSkill
- writing-maintainable-pythonSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 8
Use SOLID for concrete design costs, not as five labels for every class.
- Very specific: line 39
Use # quality: ignore[SOLID03] - rationale only beside a proven false positive.
- Very specific: line 70
Check which operations each client needs for SOLID04.
- Very specific: line 74
Run review-code-quality for the mechanical audit and structured finding format.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Applying SOLID Principles in Python
Use SOLID for concrete design costs, not as five labels for every class. A finding needs evidence that substitution, extension, ownership, client coupling, or dependency direction makes change harder or behavior less reliable.
Principles
| ID | Principle | Python review question |
SOLID01 | Single responsibility | Does this unit have more than one demonstrated reason to change? |
SOLID02 | Open/closed | Can a required variant be added at a stable boundary, or must central policy be repeatedly edited? |
SOLID03 | Liskov substitution | Does every subtype preserve calls and behavior promised by its base or protocol? |
SOLID04 | Interface segregation | Are clients forced to depend on operations they cannot or do not use? |
SOLID05 | Dependency inversion | Does policy depend on a narrow abstraction instead of a volatile concrete detail? |
Class size, method count, constructor count, isinstance, or use of a concrete
class is not proof by itself. Trace an actual caller, extension, change axis,
or disabled operation before reporting a principle violation.
Mechanical SOLID03 evidence
The bundled auditor compares public overrides only when a base is a directly named class in the same module. It warns when an override:
- replaces concrete behavior with
NotImplementedError; - changes method/property or synchronous/asynchronous behavior;
- removes positional, keyword,
*args, or**kwargscalls accepted by the base; - makes an optional argument required or adds a required argument.
External bases, inferred types, custom descriptors, unsupported decorators,
postconditions, exception guarantees, and semantic invariants remain manual.
SOLID03 warnings appear in direct audits but are advisory to the Stop hook.
Use # quality: ignore[SOLID03] - rationale only beside a proven false positive.
Example
class Store:
def fetch(self, key: str, timeout: float | None = None) -> bytes:
raise LookupError(key)
class RemoteStore(Store):
# Compatible: preserves existing calls and only widens acceptance.
def fetch(
self,
key: str,
timeout: float | None = None,
**options: object,
) -> bytes:
return request(key, timeout=timeout, **options)Making timeout required, adding a required region, returning an awaitable,
or rejecting the operation would make RemoteStore unsafe at a Store
boundary. Preserve the contract; if the subtype cannot, prefer composition or
a narrower Protocol that states what clients can actually rely on.
Review sequence
- Identify the clients and promises at the changed boundary.
- Trace replacement calls and failure behavior for
SOLID03first. - Name demonstrated change reasons for
SOLID01and extension edits forSOLID02. - Check which operations each client needs for
SOLID04. - Confirm policy-to-detail dependency direction for
SOLID05. - Report one principle that best explains the smallest safe remedy; do not duplicate a code-smell finding.
Run review-code-quality for the mechanical audit and structured finding
format. Passing checks does not prove SOLID compliance or architectural quality.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

