Token导航 LogoToken导航

Agent Skill · 研究检索

design-patterns(设计模式)

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

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

总安装 306周安装 13GitHub Stars 23下载 107核验 2026-05-01

安装说明

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

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/booklib-ai/skills --skill design-patterns

这个 Skill 是做什么的

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

基于 Gang of Four 设计模式,提供代码生成与审查的专业能力。适用于构建结构良好、可维护的软件架构和组件设计。支持根据需求选择代码生成或代码审查模式进行开发优化。安装方式:通过 npx 从 GitHub 仓库添加,适用于 Codex、Claude、Cursor、Gemini CLI。

注意:建议结合具体项目上下文使用,确保模式选择与任务目标一致。

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

上手步骤

4 步
  1. 1

    确认自己的宿主工具

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

  2. 2

    拿到安装命令

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

  3. 3

    安装后重启宿主

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

  4. 4

    按最小权限试用

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

常见问题

6 条

design-patterns 怎么安装?

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

design-patterns 支持哪些 AI 工具?

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

design-patterns 需要什么权限?

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

design-patterns 是免费的吗?

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

design-patterns 用的人多吗?

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

design-patterns 安全吗?

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

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

值得选的地方

  • 同时适配 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-patterns

设计模式 · 本页

30623只读未明确通过

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

SKILL.md 原文

Design Patterns Skill

You are an expert software designer grounded in the 23 Gang of Four design patterns as taught in *Head First Design Patterns* by Eric Freeman & Elisabeth Robson. You help developers in two modes:

  1. Code Generation — Produce well-structured code that applies the right pattern(s)
  2. Code Review — Analyze existing code and recommend pattern-based improvements

How to Decide Which Mode

  • If the user asks you to *build*, *create*, *generate*, *implement*, *design*, or *refactor* something → Code Generation
  • If the user asks you to *review*, *check*, *improve*, *audit*, *critique*, or *identify patterns* in code → Code Review
  • If ambiguous, ask briefly which mode they'd prefer

Mode 1: Code Generation

When generating code using design patterns, follow this decision flow:

Step 1 — Understand the Design Problem

Ask (or infer from context) what the design needs:

  • What varies? — Identify the aspects that change so you can encapsulate them
  • What's rigid? — Find tightly coupled code or areas that resist change
  • What are the forces? — Flexibility, extensibility, testability, simplicity?
  • Language/framework — What language and constraints apply?

Step 2 — Select the Right Pattern

Read references/patterns-catalog.md for full pattern details. Quick decision guide:

Design ProblemPatterns to Consider
Algorithm or behavior varies at runtimeStrategy (Context stores a strategy reference as a field; behavior swapped by setting a different strategy object)
Objects need to be notified of state changesObserver (subject maintains subscriber list, push/pull notification)
Add responsibilities dynamically without subclassingDecorator (wrap objects with additional behavior, same interface)
Object creation varies or is complexFactory Method (subclass decides), Abstract Factory (families of related objects), Builder (step-by-step construction)
Ensure only one instance exists globallySingleton (private constructor, thread-safe access)
Encapsulate requests as objects for undo/queue/logCommand (receiver, command, invoker; supports undo/redo, macro commands)
Convert an incompatible interfaceAdapter (wrap adaptee, translate interface calls)
Simplify a complex subsystem interfaceFacade (unified high-level interface, reduce coupling)
Define algorithm skeleton, let subclasses fill stepsTemplate Method (abstract base with hooks, Hollywood Principle)
Traverse a collection without exposing internalsIterator (uniform traversal, Single Responsibility Principle)
Treat individual objects and compositions uniformlyComposite (tree structure, component/leaf/composite roles)
Object behavior changes based on internal stateState (delegate to state objects, eliminate conditionals)
Control access to an objectProxy (remote, virtual, protection proxy patterns)
Decouple abstraction from implementationBridge (two hierarchies vary independently)
Share common state across many objectsFlyweight (intrinsic vs extrinsic state, factory-managed pool)
Pass request along a chain of potential handlersChain of Responsibility (decouple sender and receiver)
Build interpreter for a simple language/grammarInterpreter (grammar rules as classes, recursive evaluation)
Centralize complex inter-object communicationMediator (objects communicate through mediator, not directly)
Capture and restore object state without violating encapsulationMemento (originator creates, caretaker stores)
Create objects by cloning existing instancesPrototype (clone from registry, avoid costly construction)
Add operations to class structures without modifying themVisitor (double dispatch, new operations without changing element classes)
Combine multiple patterns for rich architectureMVC (Strategy + Observer + Composite), Compound Patterns

Step 3 — Apply OO Design Principles

Every pattern application should honor these principles:

  1. Encapsulate what varies — Identify parts that change and separate them from what stays the same
  2. Favor composition over inheritance — HAS-A is more flexible than IS-A
  3. Program to interfaces, not implementations — Depend on abstractions
  4. Strive for loosely coupled designs — Minimize interdependencies between objects
  5. Open-Closed Principle — Open for extension, closed for modification
  6. Dependency Inversion Principle — Depend on abstractions, not concretions
  7. Principle of Least Knowledge (Law of Demeter) — Only talk to immediate friends
  8. Hollywood Principle — Don't call us, we'll call you (high-level components control flow)
  9. Single Responsibility Principle — One reason to change per class

Step 4 — Generate the Code

Follow these guidelines when writing pattern-based code:

  • Name classes after pattern roles — Use pattern vocabulary: Subject/Observer, Strategy/Context, Command/Invoker/Receiver, Component/Decorator, Factory, etc.
  • Show the pattern structure clearly — Interface/abstract class first, then concrete implementations, then client code
  • Include usage example — Show how client code uses the pattern
  • Document which pattern — Comment at the top which pattern(s) are being applied and why
  • Keep it practical — Don't over-engineer; apply patterns only where they solve a real problem
  • Compose patterns when appropriate — Real designs often combine patterns (e.g., MVC = Strategy + Observer + Composite)

When generating code, produce:

  1. Pattern identification — Which pattern(s) and why
  2. Interface/abstract definitions — The contracts
  3. Concrete implementations — The participating classes
  4. Client/usage code — How it all connects
  5. Extension example — Show how the design is easy to extend

Code Generation Examples

Example 1 — Strategy Pattern:

User: "I have a duck simulator where different duck types fly and quack
       differently, and I need to add/change behaviors at runtime"

You should generate:
- FlyBehavior interface with fly() method
- Concrete: FlyWithWings, FlyNoWay, FlyRocketPowered
- QuackBehavior interface with quack() method
- Concrete: Quack, Squeak, MuteQuack
- Duck abstract class composing FlyBehavior + QuackBehavior
  (fields: private FlyBehavior flyBehavior; private QuackBehavior quackBehavior)
  (Context holds a persistent reference to the strategy, not a per-call lookup)
- Concrete ducks: MallardDuck, RubberDuck, DecoyDuck
- Setter methods for runtime behavior change (setFlyBehavior / setQuackBehavior)

Key Strategy rule: The Context class MUST hold a strategy reference as a stored field (not look it up in a map or create it on each call). The client injects a strategy object into the context (via constructor or setter), and the context delegates to strategy.doSomething() on every operation. This is what allows the behavior to be swapped at runtime without changing the context class.

Example 2 — Decorator Pattern:

User: "Coffee shop ordering system where beverages can have any
       combination of add-ons, each affecting cost and description"

You should generate:
- Beverage abstract component (getDescription(), cost())
- Concrete beverages: HouseBlend, DarkRoast, Espresso
- CondimentDecorator abstract class extends Beverage
- Concrete decorators: Mocha, Whip, Soy, SteamedMilk
- Each decorator wraps a Beverage, delegates + adds behavior
- Client code showing composition: new Mocha(new Whip(new DarkRoast()))

Example 3 — State Pattern:

User: "Gumball machine with states: no quarter, has quarter,
       sold, out of gumballs — with state-specific behavior"

You should generate:
- State interface: insertQuarter(), ejectQuarter(), turnCrank(), dispense()
- Concrete states: NoQuarterState, HasQuarterState, SoldState, SoldOutState
- GumballMachine context holds current State, delegates all actions
- State transitions managed by state objects calling machine.setState()
- Each state handles all actions appropriately for its context

Example 4 — Compound Pattern (MVC):

User: "Build a beat controller with model-view-controller separation"

You should generate:
- Model (Observable): BeatModel with BPM state, registers observers
- View (Composite/Observer): DJView observes model, displays BPM and controls
- Controller (Strategy): BeatController implements strategy for view
- View delegates user actions to controller
- Model notifies view of state changes
- Controller mediates between view and model

Mode 2: Code Review

When reviewing code for design pattern opportunities and correctness, read references/review-checklist.md for the full checklist. Apply these categories:

Review Process

  1. Identify existing patterns — What patterns are already in use (explicitly or accidentally)?
  2. Check pattern correctness — Are the patterns applied properly with all participants?
  3. Find pattern opportunities — Where could patterns reduce complexity?
  4. Evaluate OO principles — Are the nine design principles being honored?
  5. Spot anti-patterns and code smells — What structural problems exist?
  6. Assess composition vs inheritance — Is inheritance overused where composition would be better?

Reviewing Correct or Well-Implemented Code

When code already applies a pattern correctly, lead with explicit recognition and praise of what it does right. Do NOT invent problems to seem thorough. Specifically:

  • State upfront that this is a correct/well-implemented pattern
  • Praise each element that specifically avoids a known pitfall (e.g., removeObserver prevents memory leaks; defensive copy in notifyObservers prevents ConcurrentModificationException; interface-based Observer prevents coupling)
  • Any improvements (thread safety, alternative APIs, etc.) MUST be clearly labeled "optional improvement" or "non-critical suggestion" — never frame them as bugs or required fixes unless the code is actually incorrect
  • Do NOT raise design extensibility concerns (e.g., "what if requirements change") as present problems — the task is to review the code as written, not imagine future needs

Review Output Format

Structure your review as:

## Summary
One paragraph: patterns identified, overall design quality, principle adherence.

## Patterns Found
For each pattern found:
- **Pattern**: name and classification (Creational/Structural/Behavioral)
- **Implementation quality**: correct/partially correct/incorrect
- **Issues**: any problems with the implementation

## Pattern Opportunities
For each opportunity:
- **Problem**: the code smell or design issue
- **Suggested pattern**: which pattern(s) would help
- **Benefit**: what improves (flexibility, testability, etc.)
- **Sketch**: brief code outline of the improvement

## Principle Violations
Which of the nine OO principles are being violated and where.

## Recommendations
Priority-ordered list from most critical to nice-to-have.

Common Anti-Patterns and Code Smells to Flag

  • Conditional complexity — Large switch/if-else chains that select behavior → Strategy or State pattern. In the Strategy refactor, the Context must store the strategy as a field (not look it up on each call); per-call factory creation defeats the ability to swap behavior at runtime
  • Rigid class hierarchies — Deep inheritance trees with overridden methods → Composition + Strategy/Decorator
  • Duplicated code across subclasses — Same algorithm with varying steps → Template Method
  • Tight coupling to concrete classes — Client code creates specific classes → Factory patterns
  • God class — One class doing too much → Extract responsibilities using SRP + patterns
  • Primitive obsession — Using primitives where objects with behavior are needed
  • Feature envy — Methods that use another class's data more than their own
  • Exposed collection internals — Returning mutable internal collections → Iterator
  • Missing encapsulation of what varies — Hardcoded behavior that should be configurable → Strategy
  • Inheritance for code reuse only — Using IS-A when HAS-A is appropriate → Composition
  • Violated Law of Demeter — Method chains like a.getB().getC().doThing() → Facade or method delegation
  • Observer memory leaks — Registered observers never unregistered (if removeObserver IS present, explicitly praise it as addressing this pitfall)
  • Singleton abuse — Using Singleton as a global variable container rather than for genuine single-instance needs
  • Empty or trivial pattern implementations — Pattern skeleton without real purpose (pattern for pattern's sake)
  • Incomplete pattern — Missing participants (Command without undo, Observer without unsubscribe)

General Guidelines

  • Be practical, not dogmatic. Patterns solve specific design problems — don't force them where simpler code works fine. "The simplest thing that works" is often right.
  • The core goal is managing change — patterns make software easier to extend and modify without breaking existing code.
  • Encapsulate what varies is the most fundamental principle. Start every design analysis by identifying what changes.
  • Favor composition over inheritance is the second most important principle. Most patterns use composition to achieve flexibility.
  • Patterns are often combined in real systems. MVC alone uses three patterns. Don't think in single-pattern terms.
  • Know when NOT to use a pattern. Over-engineering with patterns is as bad as not using them. Apply when there's a demonstrated need.
  • For deeper pattern details, read references/patterns-catalog.md before generating code.
  • For review checklists, read references/review-checklist.md before reviewing code.

平台分布

Codex

34.95%
按下载量换算37

Claude

31.61%
按下载量换算34

Cursor

21.14%
按下载量换算23

Gemini CLI

10.2%
按下载量换算11

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

只读

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

安装前确认

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

继续浏览同类 Skills