When designing module boundaries, interfaces, or class hierarchies for maintainable architecture. Use when the user says "how should I structure this," "too coupled," "hard to test," "dependency injection," "single responsibility," or "interface design." For simpler structural concerns, see separation-of-concerns.
If .agents/stack-context.md exists, read it first. Apply this principle using idiomatic patterns for the detected stack. For framework-specific details, use context7 MCP or web search — don't guess.
Five design principles that produce modular, testable, and resilient systems. While originally framed for object-oriented design, the underlying ideas apply to any paradigm — functions, modules, services, or components.
SOLID code is change-friendly code. Production systems change constantly — new features, bug fixes, integrations, scaling. Systems designed with SOLID principles absorb change locally rather than requiring cascading modifications. This means fewer regressions, faster feature delivery, and smaller blast radius when things go wrong.
A module should have one, and only one, reason to change.
Every module, function, or component should own exactly one piece of functionality. When a change request comes in, you should be able to predict which file needs editing without searching.
Violations look like:
Apply it:
Software should be open for extension but closed for modification.
You should be able to add new behavior without modifying existing, working code. This doesn't mean you never touch existing code — it means you design so that the common extension points don't require it.
Violations look like:
if type == "x" for an ever-expanding list of typesApply it:
Subtypes must be usable wherever their parent type is expected, without surprises.
If your code accepts a base type, any implementation of that type should work correctly. No special-casing, no "except when it's type X" guards.
Violations look like:
instanceof, typeof) to determine behavior after accepting a general typeApply it:
No consumer should be forced to depend on methods it doesn't use.
Keep interfaces small and focused. A consumer that only reads data shouldn't depend on an interface that also includes write, delete, and admin operations.
Violations look like:
Apply it:
Reader, Writer, Admin instead of RepositoryHigh-level policy should not depend on low-level detail. Both should depend on abstractions.
Your business logic should not directly import database drivers, HTTP clients, or filesystem operations. It should depend on abstractions that those details implement.
Violations look like:
Apply it:
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer