一键导入
typescript-solid
SOLID principles for reducing coupling and improving testability—SRP, OCP, LSP, ISP, and DIP with TypeScript examples.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
SOLID principles for reducing coupling and improving testability—SRP, OCP, LSP, ISP, and DIP with TypeScript examples.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Enforce and guide the Mikado Method when a developer is refactoring, restructuring, or dealing with legacy code. Use this skill whenever the user mentions refactoring, technical debt, legacy code, code restructuring, dependency untangling, or "breaking everything" when making changes. Also trigger when the user wants to make a large change safely, asks how to split a big refactoring task, wants to work on main branch without a long-lived feature branch, or asks how to incrementally improve a codebase. The skill enforces the full Mikado loop: goal → naive attempt → map prerequisites → revert → implement leaves → commit → repeat.
Evaluate TypeScript/JavaScript code against Dave Thomas's OO principles and the Tell Don't Ask rule. Trigger when: class has only static methods; class has a single public method + constructor; code uses GoF pattern names (Decorator/Factory/Strategy/Builder/Command/Observer); class is invalid until setters are called; data class with only constructor + properties; external code reads getters to make decisions (Tell Don't Ask); user asks "is this a code smell?", "should this be a class or a function?", or "why does my code feel procedural?".
Detect code smells and apply refactoring techniques to improve clarity, testability, and maintainability.
Guide users through TDD and TCRDD (Test && Commit || Revert + Test Driven Development). Use this skill whenever a user mentions TDD, test-driven development, writing tests before code, red-green-refactor cycles, or unit testing workflows. Also trigger when a user asks about TCRDD, TCR, "test commit revert", "git gamble", or wants a strict TDD workflow with automatic commits and reverts. Trigger when the user asks to implement a feature, fix a bug, or write a class/function and mentions tests, TDD, or "test first". If the user shares code and asks for a review with any testing angle, consult this skill.
Master testing strategy — philosophy, approach, architecture decisions, test quality audit, and BDD review practices.
Design patterns for TypeScript—Factory, Strategy, Builder, Decorator, Singleton, Mixin, and more with problem-oriented and GoF triggers.
| name | typescript-solid |
| description | SOLID principles for reducing coupling and improving testability—SRP, OCP, LSP, ISP, and DIP with TypeScript examples. |
| triggers | ["SOLID","SRP","OCP","LSP","ISP","DIP","single responsibility principle","open-closed principle","Liskov substitution","interface segregation","dependency inversion","god class","fat interface","one reason to change","extend without modifying","depend on abstractions","interface too large","reduce coupling","improve testability"] |
| Principle | Rule | Signal it's violated |
|---|---|---|
| SRP — Single Responsibility | One reason to change | Class handles auth, hashing, and persistence |
| OCP — Open–Closed | Extend via subclass; don't modify proven code | Adding CSV export requires editing JsonFormatter |
| LSP — Liskov Substitution | Subtypes substitutable without surprising callers | instanceof checks in calling code; subclass throws "not supported" |
| ISP — Interface Segregation | Many focused interfaces over one fat one | Read-only client forced to implement write methods |
| DIP — Dependency Inversion | Depend on abstractions, not concretions | EmailService directly instantiates SendgridClient |
SRP — One reason to change. Split UserController into UserValidator, PasswordHasher, UserRepository.
OCP — Extend via subclass, don't edit proven code. Add CsvResponseFormatter extends JsonResponseFormatter without touching the base.
LSP — Subtypes must be fully substitutable. ReadOnlyCache extends Cache violating set() is LSP violation—use ReadableCache / WritableCache interfaces instead.
ISP — Split fat interfaces into focused slices. Don't force read-only clients to depend on write methods.
DIP — Depend on abstractions, not concretions. EmailService(transport: MailTransport) not new SendgridClient(). Enables swapping implementations.
→ Full annotated examples for all five principles: references/solid.md