DE

Provides guidance on choosing and implementing design patterns specifically for the BK-CI codebase.

Install

mkdir -p .claude/skills/design-patterns && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/2169" && unzip -o skill.zip -d .claude/skills/design-patterns && rm skill.zip

Installs to .claude/skills/design-patterns

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

在 BK-CI 中判断何时使用工厂、策略、责任链、观察者、模板方法、装饰器等设计模式时使用。当用户要重构可扩展结构、统一模式选型、理解项目里的模式落点时优先使用。
81 charsno explicit “when” trigger
Intermediate

Key capabilities

  • Select design patterns for extensible logic
  • Understand existing pattern implementations in BK-CI
  • Refactor if-else or dispatch logic
  • Choose between factory, strategy, or chain of responsibility patterns
  • Apply observer or template method patterns
  • Utilize decorator patterns for additional behaviors

How it works

The skill guides users to identify the problem type and then suggests appropriate design patterns, emphasizing alignment with BK-CI's module boundaries and stability requirements.

Inputs & outputs

You give it
Description of a problem requiring a design pattern solution
You get back
Recommended design pattern and its application in BK-CI

When to use design-patterns

  • Refactor nested if-else blocks
  • Select pattern for plugin extension points
  • Understand existing pattern implementation

About this skill

BK-CI 设计模式实践

适用场景

  • 需要为一段可扩展逻辑选择合适的设计模式
  • 需要理解 BK-CI 里某个模式为什么这样落地
  • 需要重构 if-else、分发逻辑、插件扩展点、后置处理链
  • 需要判断某个能力更适合用工厂、策略、责任链、观察者还是模板方法

不适用场景

  • 只是查某个类、某个接口或某段代码在哪里
  • 只是普通 CRUD、简单参数封装或一次性脚本逻辑
  • 问题本质是模块归属、接口设计或数据库结构,不是模式选型

快速指导

  1. 先判断你解决的是哪一类问题:
    • 对象按类型创建:看 reference/1-core-patterns.md 里的工厂模式
    • 多种规则按条件切换:看策略模式
    • 多个处理步骤串联:看责任链模式
    • 状态变化后广播处理:看观察者模式
    • 固定主流程、子类只改局部:看模板方法模式
    • 在原能力外叠加附加行为:看装饰器模式
  2. 在 BK-CI 里,模式选择要优先服从“模块边界 + 扩展点稳定性”,不要为了模式而模式。
  3. 如果只是 2 到 3 个稳定分支,且短期不会扩展,先别急着上复杂模式。
  4. 如果一段逻辑需要外部扩展、插件接入、规则分发或顺序处理,优先考虑模式,而不是继续堆 when / if-else
  5. 选型前先看项目里已有落地,不要凭空造新写法。常见实例在 reference/3-project-examples.md

高信号规则

  • 工厂模式适合“如何创建”,策略模式适合“如何选择一种行为”
  • 责任链适合“多个处理器按顺序试或继续”,不适合硬凑单一判断逻辑
  • 观察者适合事件解耦,不适合强事务链路里的必须同步步骤
  • 模板方法适合主流程稳定、局部差异明确的场景
  • 装饰器适合附加横切能力,不适合把核心流程绕得过深

关键陷阱

  • 只有两个稳定分支也强行上策略或工厂,增加理解成本
  • 把责任链当作“任何流程都能往里塞”的万能结构
  • 观察者乱用在需要强一致性的主业务流程里
  • 模式只在类图上优雅,落到 BK-CI 实际模块时却破坏分层和边界
  • 只看教科书定义,不看项目里已经存在的同类实践

延伸阅读

  • 核心模式:reference/1-core-patterns.md
  • 选型方法:reference/2-selection-guidelines.md
  • 项目案例:reference/3-project-examples.md
  • 如果模式已经沉淀为通用组件:再看 utility-components
  • 如果问题偏框架实践:再看 common-technical-practices

When not to use it

  • Only looking up a class, interface, or code snippet
  • Dealing with simple CRUD, parameter encapsulation, or one-time script logic
  • When the problem is module ownership, interface design, or database structure

Limitations

  • Not for simple CRUD operations
  • Not for problems related to module ownership or database structure
  • Not for only two or three stable branches that won't expand soon

How it compares

This skill provides specific guidance for applying design patterns within the BK-CI project context, unlike general design pattern literature.

Compared to similar skills

design-patterns side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
design-patterns (this skill)23moNo flagsIntermediate
software-architecture3336moNo flagsIntermediate
solid-principles579moNo flagsIntermediate
python-design-patterns192moNo flagsIntermediate

Try saying

Example prompts that trigger this skill in your AI assistant.

More by TencentBlueKing

View all by TencentBlueKing

project-module-architecture

TencentBlueKing

Project 项目管理模块架构指南,涵盖项目 CRUD、成员管理、项目配置、标签管理、项目迁移。当用户开发项目管理功能、处理项目成员、配置项目属性或实现项目相关逻辑时使用。

612

artifactory-module-architecture

TencentBlueKing

Artifactory 制品库模块架构指南,涵盖制品上传下载、存储后端适配、制品元数据、清理策略、权限控制。当用户开发制品库功能、处理制品存储、配置清理策略或实现制品管理时使用。

419

microservice-infrastructure

TencentBlueKing

微服务基础设施指南,涵盖条件配置、事件驱动架构、服务间通信、国际化与日志等微服务架构的核心基础设施。当用户实现服务间调用、配置多环境、实现异步通信、处理国际化或规范日志输出时使用。

411

frontend-vue-development

TencentBlueKing

前端 Vue 开发规范,涵盖 Vue 2/3 组件开发、Vuex 状态管理、路由配置、组件通信、样式规范、国际化。当用户进行前端开发、编写 Vue 组件、处理状态管理或实现页面交互时使用。

38

unit-testing

TencentBlueKing

单元测试编写指南,涵盖 JUnit5/MockK 使用、测试命名规范、Mock 技巧、测试覆盖率要求、TDD 实践。当用户编写单元测试、Mock 依赖、提高测试覆盖率或进行测试驱动开发时使用。

319

worker-module-architecture

TencentBlueKing

Worker 构建执行器模块架构指南,涵盖插件执行引擎、任务分发、日志上报、制品上传、Worker 生命周期。当用户开发 Worker 功能、实现插件执行、处理任务分发或优化执行器性能时使用。

37

Search skills

Search the agent skills registry