intense-visions/harness-engineering/js-mixin-pattern
Claude Code and agent skill by intense-visions/harness-engineering
Trust tier 3
- community
Source check pending
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install intense-visions/harness-engineering/js-mixin-patternSKILL.md
The same SKILL.md was published earlier as intense-visions/harness-engineering/js-mixin-pattern.
JS Mixin Pattern
Add reusable behaviors to classes without deep inheritance chains
When to Use
- Multiple unrelated classes need the same capability (e.g., serialization, event handling, logging)
- Single inheritance is not sufficient to compose all required behaviors
- You want to share behavior without creating a shared base class
Instructions
- Define a mixin as a function that takes a superclass and returns a new class extending it.
- Apply mixins by chaining:
class MyClass extends Mixin2(Mixin1(Base)) {}. - Keep mixins focused on a single capability — avoid fat mixins that do too much.
- Alternatively, use
Object.assign(Target.prototype, mixinMethods)for simpler method injection.
- Use TypeScript intersection types to type mixed-in methods correctly.
Details
JavaScript's single-prototype-chain inheritance means a class can only extend one parent. Mixins work around this by composing behaviors through function application rather than inheritance.
Trade-offs:
- Method name collisions between mixins are silent — the last applied mixin wins
- Stack traces can be confusing — intermediate mixin classes appear in the trace
instanceofchecks do not work for mixins applied viaObject.assign(only for the class mixin approach)
When NOT to use:
- When composition via plain function calls or hooks would work just as well
- When the behaviors are tightly coupled to specific base classes — inheritance is cleaner
- For simple utility methods — just import a utility function
Source
https://patterns.dev/javascript/mixin-pattern
Process
- Read the instructions and examples in this document.
- Apply the patterns to your implementation, adapting to your specific context.
- Verify your implementation against the details and edge cases listed above.
Harness Integration
- Type: knowledge — this skill is a reference document, not a procedural workflow.
- No tools or state — consumed as context by other skills and agents.
Success Criteria
- The patterns described in this document are applied correctly in the implementation.
- Edge cases and anti-patterns listed in this document are avoided.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingagents/skills/claude-code/js-mixin-pattern/SKILL.md
Popularity
- Repository stars
- 20
- Repository forks
- 10
- 7-day trend score
- 15
Stars and forks are for the whole GitHub repository, not this skill alone. Refreshed 4 Sep 2026, 2 months ago.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/intense-visions/harness-engineering/js-mixin-pattern)