Token导航 LogoToken导航TokenDH.com
前端设计操作浏览器github未标认证来源可访问许可证需确认审计通过

mixin-pattern混合模式

Agent Skill

mixin-pattern 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

6,120

周安装

250

GitHub Stars

173

下载量

1,960
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/patternsdev/skills --skill mixin-pattern

简介

mixin-pattern 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中围绕项目状态和变更进行整理。

  • 适用于前端设计中的混合模式应用,可辅助生成可执行下一步。
  • 通过 npx skills add 命令从 GitHub 安装,需确认权限范围和是否触发联网或文件操作。
  • 建议在使用前检查维护状态和实际功能是否符合预期,避免误判技能能力边界。
  • 涉及写入操作时需谨慎授权,确保 token 权限仅限于目标仓库和必要操作。

SKILL.md

Mixin Pattern

A mixin is an object that we can use in order to add reusable functionality to another object or class, without using inheritance. We can't use mixins on their own: their sole purpose is to *add functionality* to objects or classes without inheritance.

Let's say that for our application, we need to create multiple dogs. However, the basic dog that we create doesn't have any properties but a name property.

When to Use

  • Use this when you need to add reusable functionality to multiple classes without creating an inheritance chain
  • This is helpful when you want to compose behavior from multiple sources

When NOT to Use

  • When composition via hooks (React) or composables (Vue) achieves the same result with better traceability
  • When prototype pollution is a risk — mixins modify shared prototypes and can cause naming collisions
  • When the added functionality is simple enough that a utility function or module import suffices

Instructions

  • Use Object.assign() to add mixin properties to a class prototype
  • Be cautious with prototype pollution — modifying prototypes can lead to unexpected behavior
  • In React, prefer Hooks over mixins (mixins are discouraged by the React team)
  • Consider composition over inheritance when designing reusable behavior

Details

class Dog {
  constructor(name) {
    this.name = name;
  }
}

A dog should be able to do more than just have a name. It should be able to bark, wag its tail, and play! Instead of adding this directly to the Dog, we can create a mixin that provides the bark, wagTail and play property for us.

const dogFunctionality = {
  bark: () => console.log("Woof!"),
  wagTail: () => console.log("Wagging my tail!"),
  play: () => console.log("Playing!"),
};

We can add the dogFunctionality mixin to the Dog prototype with the Object.assign method. This method lets us add properties to the *target object*: Dog.prototype in this case. Each new instance of Dog will have access to the properties of dogFunctionality, as they're added to the Dog's prototype!

class Dog {
  constructor(name) {
    this.name = name;
  }
}

const dogFunctionality = {
  bark: () => console.log("Woof!"),
  wagTail: () => console.log("Wagging my tail!"),
  play: () => console.log("Playing!"),
};

Object.assign(Dog.prototype, dogFunctionality);

Let's create our first pet, pet1, called Daisy. As we just added the dogFunctionality mixin to the Dog's prototype, Daisy should be able to walk, wag her tail, and play!

const pet1 = new Dog("Daisy");

pet1.name; // Daisy
pet1.bark(); // Woof!
pet1.play(); // Playing!

Perfect! Mixins make it easy for us to add custom functionality to classes or objects without using inheritance.

Although we can add functionality with mixins without inheritance, mixins themselves can use inheritance!

Most mammals can walk and sleep as well. A dog is a mammal, and should be able to walk and sleep!

Let's create a animalFunctionality mixin that adds the walk and sleep properties.

const animalFunctionality = {
  walk: () => console.log("Walking!"),
  sleep: () => console.log("Sleeping!"),
};

We can add these properties to the dogFunctionality prototype, using Object.assign. In this case, the target object is dogFunctionality.

const animalFunctionality = {
  walk: () => console.log("Walking!"),
  sleep: () => console.log("Sleeping!"),
};

const dogFunctionality = {
  bark: () => console.log("Woof!"),
  wagTail: () => console.log("Wagging my tail!"),
  play: () => console.log("Playing!"),
  walk() {
    super.walk();
  },
  sleep() {
    super.sleep();
  },
};

Object.assign(dogFunctionality, animalFunctionality);
Object.assign(Dog.prototype, dogFunctionality);

Perfect! Any new instance of Dog can now access the walk and sleep methods as well.

An example of a mixin in the real world is visible on the Window interface in a browser environment. The Window object implements many of its properties from the WindowOrWorkerGlobalScope and WindowEventHandlers mixins, which allow us to have access to properties such as setTimeout and setInterval, indexedDB, and isSecureContext.

Since it's a mixin, thus is only used to *add functionality* to objects, you won't be able to create objects of type WindowOrWorkerGlobalScope.

React (pre ES6)

Mixins were often used to add functionality to React components before the introduction of ES6 classes. The React team discourages the use of mixins as it easily adds unnecessary complexity to a component, making it hard to maintain and reuse. The React team encouraged the use of higher order components instead, which can now often be replaced by Hooks.

Mixins allow us to easily add functionality to objects without inheritance by injecting functionality into an object's prototype. Modifying an object's prototype is seen as bad practice, as it can lead to prototype pollution and a level of uncertainty regarding the origin of our functions.

Source

References

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

32.95%
按下载量换算646

Claude

30.17%
按下载量换算591

Cursor

18.05%
按下载量换算354

Gemini CLI

10.27%
按下载量换算201

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

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

来源信息

继续浏览同类 Skills