Token导航 LogoToken导航

Agent Skill · 研究检索

design-pattern(设计模式)

用于辅助界面设计、视觉规范、排版、配色、布局和交互体验优化。它适合让 Agent 根据产品场景整理页面结构、生成 UI 方案、检查视觉一致性或改进组件层级。使用时需要结合现有品牌、设计系统和用户任务,不应只堆装饰元素;涉及真实页面改动时,应通过截图或浏览器预览检查文本溢出、对齐和响应式表现。

design-pattern 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为只读;许可证信息还不明确,第三方扫描已通过,按安装量在研究检索类的 73,675 个 Skill 里排第 53,170。

总安装 539周安装 22GitHub Stars 公开资料未说明下载 174核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:design-pattern(设计模式)
来源仓库:https://github.com/cylixlee/skills
仓库路径:skills/design-pattern
安装命令:
npx skills add https://github.com/cylixlee/skills --skill design-pattern
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cylixlee/skills --skill design-pattern

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

应用软件设计原则生成高可维护代码,避免过度抽象与冗余。坚持 YAGNI 原则,仅在需要时引入接口与分层架构。使用时需优先考虑简单解决方案,延迟复杂模式的应用。

安装方式:GitHub,命令为 npx skills add https://github.com/cylixlee/skills --skill design-pattern。注意:核心目标是代码可读性与扩展性,而非追求模式覆盖率。

来源仓库内路径:skills/design-pattern

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/cylixlee/skills --skill design-pattern;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它标注为只读,先用只读任务试一次,确认行为符合预期再扩大使用范围。

常见问题

6 条

design-pattern 怎么安装?

在终端执行 npx skills add https://github.com/cylixlee/skills --skill design-pattern。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

design-pattern 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

design-pattern 需要什么权限?

权限级别是只读。该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

design-pattern 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

design-pattern 用的人多吗?

公开数据是累计安装 539 次,近一周安装 22 次,下载 174 次。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

design-pattern 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。
  • 标注为只读权限,试用阶段不容易误改本地文件。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。
  • 只想先试试效果、不希望它改动本地文件的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
design-pattern

设计模式 · 本页

539—只读未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Design Pattern

This skill guides the generation of high-quality, maintainable, and extensible code by applying established software design principles. When generating code for any non-trivial application, always follow these principles to ensure the resulting codebase is easy to understand, modify, test, and extend over time.

Core Principles

1. Simplicity First

Always prefer simple solutions over complex ones. Do not over-engineer or add abstraction layers that are not yet needed.

YAGNI (You Aren't Gonna Need It)

Do not design abstractions "just in case" they might be needed later. Implement what is needed now, and refactor when actual extension requirements arise. Premature abstraction often leads to incorrect interfaces that must be changed anyway.

KISS (Keep It Simple, Stupid)

Simple code is easier to understand, test, and maintain. If a simple solution works, use it. Complexity should be added only when there is a clear, immediate need.

2. Interface Design

Prefer Standard Library Interfaces

When the standard library or language provides an interface that meets your needs, use it. Do not create custom interfaces that duplicate standard ones. For example, in Go use io.Reader and io.Writer instead of defining your own Reader or Writer interfaces.

Define Interfaces at the Point of Need

Define interfaces where they are consumed, not at a central location. This reduces unnecessary coupling and allows interfaces to be specific to actual use cases.

3. Package and Module Organization

Name Packages by Purpose, Not Project Name

Name packages based on what they do, not the project name. For example, a parser package should be called "parser" or "parsing", not "brainvm".

Follow Language Conventions

Use the project structure and conventions appropriate for the language:

  • Go: Single program → root main.go, multiple programs → cmd/ folder, library → functional packages
  • Java: Standard Maven/Gradle structure with src/main/java
  • Python: src/ or flat structure with __init__.py
  • Do not assume all languages have the same conventions (not all languages have cmd/)

4. Layered Architecture

Layered Architecture is essential for maintainable software because it separates concerns, making code easier to understand, test, and modify. When all code is mixed together in a single layer, changes in one area can unexpectedly break unrelated functionality. By separating responsibilities into distinct layers, each layer can be developed, tested, and modified independently.

The key principle is that dependencies should only flow in one direction, typically from outer layers toward inner layers. This ensures that core business logic does not depend on external concerns like databases, UI frameworks, or external services.

Why Layered Architecture Matters
  • Separation of Concerns: Each layer has a single, well-defined responsibility
  • Testability: Inner layers can be tested without involving outer layers
  • Maintainability: Changes to one layer (e.g., switching databases) don't affect other layers
  • Reusability: Core business logic can be reused across different interfaces
  • Parallel Development: Different teams can work on different layers simultaneously
Common Layering Approaches

Model-View-Controller (MVC): A pattern that separates an application into three main components: the Model (data and business logic), the View (presentation layer), and the Controller (handles user input and orchestrates Model and View). MVC is particularly common in web applications and UI frameworks.

Domain-Driven Design (DDD): DDD emphasizes modeling software around business domains. It uses concepts like entities, value objects, aggregates, bounded contexts, and domain services. DDD is particularly valuable for complex business applications where the domain logic is sophisticated and frequently changing. For more details, see Domain-Driven Design.

General Rule

Regardless of the specific layering approach chosen, always ensure:

  • Each layer has clear, single responsibility
  • Dependencies flow inward only
  • Layer boundaries are enforced through interfaces or abstractions
  • Code is distributed across multiple files and packages, not lumped together
Avoid Unnecessary Middle Layers

Do not create abstraction layers that merely wrap other layers without adding value. Only create a new layer when there is a clear separation of concerns that genuinely needs it. If two components naturally belong together, keep them together.

2. OOP Over Imperative

Write code using Object-Oriented Programming principles rather than procedural or functional style. OOP provides better abstraction, encapsulation, and polymorphism for building complex systems.

Use Interfaces or Abstract Classes to Define Contracts

Always define the "what" separately from the "how". Define what operations are available through an interface or abstract class, then provide concrete implementations. This allows clients to depend on abstractions rather than specific implementations, enabling flexibility and testability.

Prefer Composition Over Inheritance

Favor "has-a" relationships over "is-a" relationships. Inheritance creates tight coupling between classes, making changes difficult and testing problematic. Composition (组装) allows you to combine behaviors by injecting dependencies, which is more flexible and easier to test.

Encapsulate Behavior Within Classes

Keep related behavior and data together. Avoid scattered utility functions or global state. Each class should bundle its data with the operations that manipulate that data.

Extract Hardcoded Logic to Strategy Classes

When you find conditional logic that varies by type or category, consider extracting each variant into its own class. This follows the Strategy pattern and makes the code easier to extend without modification.

3. SOLID Principles

Apply these five principles as code quality checks. Whenever you write code, verify that it does not violate any SOLID principle.

Single Responsibility Principle

Every class should have only one reason to change. A class should do one thing well. If a class is responsible for multiple concerns, changes to one concern may affect others unexpectedly.

Open/Closed Principle

Software entities should be open for extension but closed for modification. Add new features by adding new code rather than modifying existing code. This is typically achieved through abstraction, polymorphism, and composition.

Liskov Substitution Principle

Subtypes must be substitutable for their base types. A subclass should honor the contract of its parent class. If a subclass cannot fully implement parent behavior, the inheritance relationship is incorrect.

Interface Segregation Principle

Clients should not be forced to depend on interfaces they do not use. Many small, specific interfaces are better than one large interface. This prevents classes from being burdened with methods they don't need.

Dependency Inversion Principle

High-level modules should not depend on low-level modules. Both should depend on abstractions. This enables swapping implementations without affecting clients.

4. Design Pattern Selection

Design patterns are reusable solutions to commonly occurring problems. Choose appropriate patterns based on the specific problem context.

How to Use Design Pattern References
  1. Analyze the problem: First, understand what problem you need to solve
  2. Select the pattern: Choose the appropriate design pattern from the tables below based on the problem type
  3. Choose implementation: Navigate to references/{pattern-name}/{language}.md for your target language
  4. Apply with care: Remember that patterns are tools, not rules - use them when they fit
Creation Patterns
PatternPurposeGoJavaPython
Factory MethodDelegate instantiation to subclassesGoJavaPython
Abstract FactoryCreate families of related objectsGoJavaPython
BuilderConstruct complex objects step by stepGoJavaPython
SingletonEnsure single instance with global accessGoJavaPython
PrototypeCreate objects by cloning existing onesGoJavaPython
Structural Patterns
PatternPurposeGoJavaPython
AdapterConvert interface compatibilityGoJavaPython
BridgeSeparate abstraction from implementationGoJavaPython
CompositeTree structures for part-whole hierarchiesGoJavaPython
DecoratorAdd responsibilities dynamicallyGoJavaPython
FacadeSimplified interface to complex subsystemGoJavaPython
FlyweightShare common state efficientlyGoJavaPython
ProxyControl access to another objectGoJavaPython
Behavioral Patterns
PatternPurposeGoJavaPython
Chain of ResponsibilityPass request along a chain of handlersGoJavaPython
CommandEncapsulate request as an objectGoJavaPython
IteratorAccess elements sequentiallyGoJavaPython
MediatorCentralized communicationGoJavaPython
MementoCapture and restore internal stateGoJavaPython
ObserverNotify dependents of state changesGoJavaPython
StateAlter behavior based on internal stateGoJavaPython
StrategyInterchangeable algorithmsGoJavaPython
Template MethodDefine algorithm skeleton, let subclasses override stepsGoJavaPython
VisitorOperations on elements of an object structureGoJavaPython

5. Dependency Management

Proper dependency management is critical for maintainability and testability.

Use Dependency Injection

Inject dependencies rather than creating them inside classes. Pass dependencies through constructors or setters rather than having classes create their own dependencies. This enables loose coupling and makes testing straightforward.

Inject Abstractions, Not Concretions

Always depend on interfaces or abstract types, not concrete implementations. This allows implementations to be swapped without affecting client code.

Avoid Circular Dependencies

Circular dependencies make code hard to test and reason about. The dependency graph should be acyclic. If two modules depend on each other, extract shared abstractions to break the cycle.

6. Testability

Design code to be easily testable. Testable code is usually well-designed code.

  • Avoid static state that persists between tests
  • Avoid singletons with mutable state
  • Use dependency injection to enable mocking
  • Favor pure functions where possible
  • Keep methods focused and single-purpose

7. Code Quality Rules

  • Meaningful Naming: Use descriptive names for classes, methods, and variables that convey intent
  • Short Methods: Each method should do one thing; keep methods concise
  • No Duplication: Extract repeated logic into reusable abstractions (DRY principle)
  • Error Handling: Use exceptions rather than error codes; provide meaningful error messages

8. Anti-Patterns to Avoid

  • God Class: A class with too many responsibilities; split into focused classes
  • Spaghetti Code: Tangled, unstructured control flow; apply proper design
  • Magic Values: Hardcoded numbers or strings without constants; use named constants
  • Premature Optimization: Optimize only when measurement proves it necessary
  • Excessive Inheritance: Deep hierarchies create tight coupling; prefer composition
  • Over-Engineering: Creating unnecessary abstraction layers, interfaces, or packages that don't yet have clear use cases
  • Interface Duplication: Defining custom interfaces that duplicate standard library interfaces (e.g., defining your own Reader when io.Reader exists)
  • Premature Abstraction: Creating generic interfaces or base types before actual variation points are understood
  • Unused Code: "var _ Interface = (*Implementation)(nil)" style compile-time checks that serve no practical purpose

平台分布

Codex

35.92%
按下载量换算63

Claude

30.34%
按下载量换算53

Cursor

18.67%
按下载量换算32

Gemini CLI

8.31%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

该 Skill 主要提供规则、说明或参考内容,本身偏只读;真正读写文件、联网或执行命令仍取决于宿主 Agent 的任务。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills