Token导航 LogoToken导航TokenDH.com
运维和基础设施需要联网github未标认证来源可访问clear审计通过

design-patterns设计模式

Agent Skill

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

总安装

1,257

周安装

54

GitHub Stars

35

下载量

441
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/ratacat/claude-skills --skill design-patterns

简介

用于辅助界面设计、视觉规范和交互体验优化。

  • 适合让 Agent 整理页面结构、生成 UI 方案或检查视觉一致性。
  • 使用时需结合品牌和设计系统,避免堆砌装饰元素;改动应通过预览验证。
  • 安装命令:npx skills add https://github.com/ratacat/claude-skills --skill design-patterns
  • 适用于 Codex、Claude、Cursor、Gemini CLI,建议先确认设计系统边界。

SKILL.md

Design Patterns

Overview

Design patterns are proven solutions to recurring software design problems. They provide a shared vocabulary for discussing design and capture collective wisdom refined through decades of real-world use.

Core Philosophy: Patterns are templates you adapt to your context, not blueprints to copy. Use the right pattern when it genuinely simplifies your design—not to impress or over-engineer.

Foundational Principles

These principles underpin all good design:

PrincipleMeaningViolation Symptom
Encapsulate What VariesIsolate changing parts from stable partsChanges ripple through codebase
Program to InterfacesDepend on abstractions, not concretionsCan't swap implementations
Composition Over InheritanceBuild behavior by composing objectsDeep rigid class hierarchies
Loose CouplingMinimize interdependency between objectsCan't change one thing without breaking another
Open-ClosedOpen for extension, closed for modificationMust edit existing code for new features
Single ResponsibilityOne reason to change per classClasses doing too many things
Dependency InversionHigh-level modules don't depend on low-levelBusiness logic coupled to infrastructure

Pattern Selection Guide

By Problem Type

CREATING OBJECTS
├── Complex/conditional creation ──────────→ Factory Method
├── Families of related objects ───────────→ Abstract Factory
├── Step-by-step construction ─────────────→ Builder
├── Clone existing objects ────────────────→ Prototype
└── Single instance needed ────────────────→ Singleton (use sparingly!)

STRUCTURING/COMPOSING OBJECTS
├── Incompatible interface ────────────────→ Adapter
├── Simplify complex subsystem ────────────→ Facade
├── Tree/hierarchy structure ──────────────→ Composite
├── Add behavior dynamically ──────────────→ Decorator
└── Control access to object ──────────────→ Proxy

MANAGING COMMUNICATION/BEHAVIOR
├── One-to-many notification ──────────────→ Observer
├── Encapsulate requests as objects ───────→ Command
├── Behavior varies by internal state ─────→ State
├── Swap algorithms at runtime ────────────→ Strategy
├── Algorithm skeleton with hooks ─────────→ Template Method
├── Reduce N-to-N communication ───────────→ Mediator
└── Sequential handlers ───────────────────→ Chain of Responsibility

MANAGING DATA ACCESS
├── Abstract data source ──────────────────→ Repository
├── Track changes for atomic commit ───────→ Unit of Work
├── Ensure object identity ────────────────→ Identity Map
├── Defer expensive loading ───────────────→ Lazy Load
├── Map objects to database ───────────────→ Data Mapper
└── Shape data for transfer ───────────────→ DTO

By Symptom

SymptomConsider
Giant switch/if-else on typeStrategy, State, or polymorphism
Duplicate code across classesTemplate Method, Strategy
Need to notify many objects of changesObserver
Complex object creation logicFactory, Builder
Adding features bloats classDecorator
Third-party API doesn't fit your codeAdapter
Too many dependencies between componentsMediator, Facade
Can't test without database/networkRepository, Dependency Injection
Need undo/redoCommand
Object behavior depends on stateState
Request needs processing by multiple handlersChain of Responsibility

Domain Logic: Transaction Script vs Domain Model

FactorTransaction ScriptDomain Model
Logic complexitySimple (< 500 lines)Complex, many rules
Business rulesFew, straightforwardMany, interacting
OperationsCRUD-heavyRich behavior
Team/timelineSmall team, quick deliveryLong-term maintenance
TestingIntegration testsUnit tests on domain

Rule of thumb: Start with Transaction Script. Refactor to Domain Model when procedural code becomes hard to maintain.

Quick Reference

Tier 1: Essential Patterns (Master First)

PatternOne-LineWhen to UseReference
StrategyEncapsulate interchangeable algorithmsMultiple ways to do something, swap at runtimestrategy.md
ObserverNotify dependents of state changesEvent systems, reactive updatesobserver.md
FactoryEncapsulate object creationComplex/conditional instantiationfactory.md
DecoratorAdd behavior dynamicallyExtend without inheritancedecorator.md
CommandEncapsulate requests as objectsUndo/redo, queuing, loggingcommand.md

Tier 2: Structural Patterns

PatternOne-LineWhen to UseReference
AdapterConvert interfacesIntegrate incompatible codeadapter.md
FacadeSimplify complex subsystemsHide complexity behind simple APIfacade.md
CompositeUniform tree structuresPart-whole hierarchiescomposite.md
ProxyControl access to objectsLazy load, access control, cachingproxy.md

Tier 3: Enterprise/Architectural Patterns

PatternOne-LineWhen to UseReference
RepositoryCollection-like data accessDecouple domain from data layerrepository.md
Unit of WorkCoordinate atomic changesTransaction managementunit-of-work.md
Service LayerOrchestrate business operationsDefine application boundaryservice-layer.md
DTOShape data for transferAPI contracts, prevent over-exposuredto.md

Additional Important Patterns

PatternOne-LineWhen to UseReference
BuilderStep-by-step object constructionComplex objects, fluent APIsbuilder.md
StateBehavior changes with stateState machines, workflowstate.md
Template MethodAlgorithm skeleton with hooksFramework extension pointstemplate-method.md
Chain of ResponsibilityPass request along handlersMiddleware, pipelineschain-of-responsibility.md
MediatorCentralize complex communicationReduce component couplingmediator.md
Lazy LoadDefer expensive loadingPerformance, large object graphslazy-load.md
Identity MapEnsure object identityORM, prevent duplicatesidentity-map.md

Common Mistakes

MistakeSymptomFix
Pattern OveruseSimple operations require navigating many classesOnly use when solving real problem
Wrong PatternCode feels forced, awkwardRe-examine actual problem
Inheritance AbuseDeep hierarchies, fragile base classFavor composition (Strategy, Decorator)
Singleton AbuseGlobal state, hidden dependencies, hard to testUse dependency injection instead
Premature AbstractionInterfaces with single implementationWait for real need to vary

Anti-Patterns to Recognize

  • God Object: One class does everything → Split using SRP
  • Anemic Domain Model: Objects are just data bags → Move behavior to objects
  • Golden Hammer: Same pattern everywhere → Match pattern to problem
  • Lava Flow: Dead code nobody removes → Delete it, VCS has your back

Modern Variations

Modern PatternBased OnDescription
Dependency InjectionStrategy + FactoryContainer creates and injects dependencies
MiddlewareDecorator + Chain of ResponsibilityRequest/response pipeline
Event SourcingCommandStore state changes as events
CQRSCommand/Query separationSeparate read/write models
Hooks (React/Vue)Observer + StrategyFunctional lifecycle subscriptions

Implementation Checklist

Before implementing a pattern:

  • Pattern solves a real problem in this codebase
  • Considered simpler alternatives
  • Trade-offs acceptable for this context
  • Team understands the pattern
  • Won't over-engineer the solution

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

04

需要参考平台分布和安装热度时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

补充不同宿主或平台的使用分布数据

能力 5

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

29.87%
按下载量换算132

Antigravity

23.7%
按下载量换算105

Codex

20.11%
按下载量换算89

OpenCode

12.71%
按下载量换算56

Gemini CLI

8.12%
按下载量换算36

windsurf

3.36%
按下载量换算15

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills