用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Dev-Toolbelt/dev-team-agents --skill design-patterns命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | design-patterns |
| description | Design patterns — KISS, YAGNI, DRY, SOLID, GoF, DDD reference. |
These principles apply at every layer of the stack, independent of language or framework.
| Principle | Rule | Violated when... |
|---|---|---|
| KISS — Keep It Simple | Prefer the simplest solution that correctly solves the problem | A simpler approach exists but a more complex one was chosen without justification |
| YAGNI — You Aren't Gonna Need It | Don't build features, abstractions, or generalization until they are actually needed | Code is written for a hypothetical future requirement that doesn't exist yet |
| DRY — Don't Repeat Yourself | Every piece of knowledge has a single, authoritative representation | Logic, validation rules, or configuration are duplicated across two or more places |
| Principle | Rule |
|---|---|
| S — Single Responsibility | A class/module has one reason to change |
| O — Open/Closed | Open for extension, closed for modification |
| L — Liskov Substitution | Subtypes must be substitutable for their base types |
| I — Interface Segregation | Clients should not depend on interfaces they don't use |
| D — Dependency Inversion | Depend on abstractions, not concretions |
Creates objects without specifying the exact class. Use when the creation logic may vary or is complex.
Creator → factoryMethod() → Product
Creates families of related objects. Use when the system needs to be independent of how products are created.
Constructs complex objects step by step. Use when an object has many optional parameters or construction phases.
Ensures a class has only one instance. Use sparingly — prefer dependency injection. Avoid in testable code.
Converts an interface into another that clients expect. Use for integrating incompatible interfaces (e.g., third-party SDKs).
Adds responsibilities to objects dynamically. Prefer over subclassing for feature composition.
Provides a simplified interface to a complex subsystem. Use to hide complexity from callers.
Abstracts data access behind an interface. Decouples business logic from persistence technology.
Controls access to an object (lazy loading, caching, access control, logging).
Defines a family of algorithms and makes them interchangeable. Use when behavior varies and should be swappable at runtime.
Defines a one-to-many dependency so that when one object changes state, its dependents are notified. Use for event-driven systems.
Encapsulates a request as an object. Enables undo, queuing, and logging of operations.
Passes a request through a chain of handlers. Use for pipelines (middleware, validation chains).
Defines the skeleton of an algorithm, deferring steps to subclasses. Use when multiple implementations share a common process.
Immutable object defined by its attributes, not identity. Use for things like Money, Email, Address.
Object with a unique identity that persists over time. Has a lifecycle (create, update, delete).
Cluster of entities and value objects treated as a unit. Defines a consistency boundary.
Stateless operation that doesn't naturally belong to an entity or value object.
Provides collection-like access to aggregates. Hides storage details.
| Anti-Pattern | Problem |
|---|---|
| God Object | One class knows too much / does too much |
| Spaghetti Code | Unstructured, hard-to-follow control flow |
| Magic Numbers | Unnamed numeric literals — use named constants |
| Premature Optimization | Optimizing before profiling proves a bottleneck |
| Cargo Cult | Copying patterns without understanding why |
| Anemic Domain Model | Entities with no behavior — just getters/setters |
The single place in the application where all object graphs are assembled. Every dependency binding happens here and nowhere else — services never instantiate their own dependencies.
Load references/composition-root.md when setting up DI wiring, designing a service layer, or evaluating whether a DI container is appropriate for the project.