agentleFS
reliable-coding-agentsreliable-coding-agents/reliable-python/skills/applying-solid-principles/SKILL.md

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.

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
  1. Distinctive:

    Use SOLID for concrete design costs, not as five labels for every class.

    line 8
  2. Very specific:

    Use # quality: ignore[SOLID03] - rationale only beside a proven false positive.

    line 39
  3. Very specific:

    Check which operations each client needs for SOLID04.

    line 70
  4. Very specific:

    Run review-code-quality for the mechanical audit and structured finding format.

    line 74

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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

IDPrinciplePython review question
SOLID01Single responsibilityDoes this unit have more than one demonstrated reason to change?
SOLID02Open/closedCan a required variant be added at a stable boundary, or must central policy be repeatedly edited?
SOLID03Liskov substitutionDoes every subtype preserve calls and behavior promised by its base or protocol?
SOLID04Interface segregationAre clients forced to depend on operations they cannot or do not use?
SOLID05Dependency inversionDoes 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 **kwargs calls 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

  1. Identify the clients and promises at the changed boundary.
  2. Trace replacement calls and failure behavior for SOLID03 first.
  3. Name demonstrated change reasons for SOLID01 and extension edits for SOLID02.
  4. Check which operations each client needs for SOLID04.
  5. Confirm policy-to-detail dependency direction for SOLID05.
  6. 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.