Skip to content

Adonis0123/adonis-skills / skills/code-plugin-architecture

code-plugin-architecture

Verified

Design, review, refactor, or explain recurring extension mechanisms when adding or removing one variant requires scattered coordinated edits. Use for plugin architecture, registries, extension points, and cross-stack contract/host mappings. Assess whether a typed map, existing framework mechanism, or lifecycle-owning core is justified. Skip one plugin's internal styling or bugs, user signup, DI containers, and package registries.

references/anti-patterns.md

View on GitHub
# 插件机制评审

只读评审不修改源码、不创建分支,也不真的删除一个插件来验证可移除性。先读当前范围与契约,用下面的现象定位证据;不要逐条凑问题数量。

## 有当前伤害才提出修复

| 候选问题                 | 要核实的当前伤害                                         | 最小修法与边界                                             |
| ------------------------ | -------------------------------------------------------- | ---------------------------------------------------------- |
| 消费方重复 key 分支      | 每次新增同类能力必须同步修改多处,或已发生漏改           | 把这份变体知识放回定义或组合入口;单一稳定 switch 可保留   |
| Core 依赖具体变体        | 通用生命周期必须随新增变体修改,或删除该变体破坏无关能力 | 通过现有契约传入行为;不要顺带引入新框架                   |
| 插件读取另一插件私有状态 | 生命周期互相影响、移除一方破坏另一方                     | 由编排层拥有产品顺序,或显式传入所需数据;不默认加事件总线 |
| 配置存在冲突来源         | 同一配置两个来源互相覆盖,优先级不明确且影响行为         | 明确一个权威值或合法 override 的顺序,不盲删运行时覆盖     |
| 契约混合互斥能力         | 消费方靠多组 flag 猜能调用什么,错误路径不完整           | 窄契约或可辨识联合;不要为“同质”要求无关字段               |
| 重算与资源 owner 不清楚  | 换号串状态、旧请求写回、重复监听或卸载后仍更新           | 先在现有生命周期修正 ownership、取消/失效和 cleanup        |
| key / 路由 / 埋点漂移    | 同一项被错误解析、漏查或不兼容                           | 保持已发布标识,明确本地映射;命名不一样本身不是 bug       |

JavaScript 注册表按 key 调度前,先确认该 key 已被显式注册:普通对象检查自有键(例如 `Object.hasOwn`),`Map` 使用 `Map.has` 或等价成员检查,也可使用无原型字典。不要把未显式注册的 `toString`、`constructor` 等继承键当作处理函数;这些名称若已显式注册,按正常条目处理。未知 key 保留原有错误契约,不需要新增架构层。

`if (key === 'x')`、只有一个条目设置 optional 字段、静态 import、文件很长或缺占位符,都只是线索。需要读取消费方和运行时结果,不能凭 grep 判定“伪插件化”。

## 三个容易误判的例子

### 可选字段不是结构错误

```ts
interface Command {
  run: () => void;
  label?: string;
}
```

如果 label 确有统一默认,某条命令不提供它是正常契约。只有消费方无默认却按必填使用时才是正确性问题。互斥能力用不同类型表达,不用一串 nullable 属性假装统一。

### 延迟加载是性能选择

一个首次就必须展示的小组件静态加载可以合理。一个昂贵且很少使用的弹窗可能值得动态加载,但须检查首屏依赖、等待/失败 UI 和真实请求。不能从 import 语句判断 bundle 大小,也不能要求每个插件单独 chunk。

### 开发引导不是架构证明

已有清晰的类型表和添加示例时,缺 `// [Domain-Action]:(slot)` 不阻塞评审。只有团队确实反复漏接入时才建议沿仓库惯例补引导或生成器。不能要求一个只读评审额外交付 README 或全局调试接口。

## 证据与输出

对每个建议写出:哪条行为或修改路径有问题、当前证据、影响、最小改动、可验证结果。只读依赖图或隔离 fixture 可验证新增/移除传播。真实页面的分包、等待和账号切换需浏览器或渲染证据;已有测试能覆盖时复用。

没有有效问题就明确保留当前设计。无法看到消费方或运行时的候选标为待核实,不凑 Must-fix;版本敏感 API 先查项目版本与官方文档。
brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation).Stars: 322kUpdated Claude CodeCodexVerifiedInstall
brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.Stars: 197kUpdated Claude CodeCodexVerifiedInstall
mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).Stars: 197kUpdated Claude CodeCodexVerifiedInstall