use-internals-di-seam-pattern-for-test-injectable-functions — skill
use-internals-di-seam-pattern-for-test-injectable-functions is a Claude Code skill that uses _internals as a DI seam and checks mock isolation in combined Bun test runs.
MIT ★ 539 updated 2026-10-29
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a claude-codeWhat use-internals-di-seam-pattern-for-test-injectable-functions does
The skill directs the agent to expose testable functions through _internals, creating a clear DI seam for dependency replacement. When mocking Node.js built-ins, it keeps the module’s real exports and overrides only the target function, using a pattern built around import * as real from 'node:module' and mock.module().
Tests must run in combined mode rather than one file at a time. Bun can carry mock.module() state across files in a shared runner process, so an isolated green file run is not enough to validate isolation. Delegated work includes file:.opencode/skills/generated/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.md, and the reviewer checks that every required action appears in the diff.
What it helps with
- expose a function through an
_internalsDI seam - mock a Node.js built-in while keeping its real exports
- check mock isolation across Bun test files
- run related tests in combined mode
- cover the forbidden single-file test path
Example prompts for the agent
- Move the function under test behind an
_internalsDI seam. - Mock the target Node.js built-in function while preserving the real exports with
import * as real. - Run the test files together and verify that
mock.module()state does not cross file boundaries.
How to install use-internals-di-seam-pattern-for-test-injectable-functions
1Skills CLI (Vercel)
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a claude-code2Manually: put the files in place
~/.claude/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.mdCopy the whole skill folder; for one project use .claude/skills/use-internals-di-seam-pattern-for-test-injectable-functions/
1Skills CLI (Vercel)
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a codex2Manually: put the files in place
.agents/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.mdFor all projects use ~/.agents/skills/
1Skills CLI (Vercel)
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a cursor2Manually: put the files in place
.cursor/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.mdCursor also reads .agents/skills/ and .claude/skills/
1GitHub CLI
gh skill install ZaxbyHub/opencode-swarm .opencode/skills/generated/use-internals-di-seam-pattern-for-test-injectable-functions2Manually: put the files in place
.github/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.md1Skills CLI (Vercel)
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a gemini-cli2Platform CLI
gemini skills install https://github.com/ZaxbyHub/opencode-swarm --path .opencode/skills/generated/use-internals-di-seam-pattern-for-test-injectable-functionsManually: put the files in place
.devin/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.mdThe legacy .windsurf/skills/ path still works
Skills CLI (Vercel)
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a opencodeClaude.ai
Zip the folder and upload it in Settings → Capabilities → Skills
Step by step, with commands for each platform: How to install skills in Claude Code: five ways
Questions about use-internals-di-seam-pattern-for-test-injectable-functions
How do I install use-internals-di-seam-pattern-for-test-injectable-functions in Claude Code?
Run npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a claude-code, then check ~/.claude/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.md.
What does use-internals-di-seam-pattern-for-test-injectable-functions do?
It guides the use of _internals as a dependency-injection seam for testable functions. It also sets rules for preserving real exports in built-in module mocks and validating tests in combined mode.
Why should Bun test files run together?
A shared Bun test-runner process can let mock.module() state leak from one file into another. The skill therefore rejects relying on separate file runs to prove mock isolation.
Source text
SKILL.md · MIT
---
name: use-internals-di-seam-pattern-for-test-injectable-functions
description: use _internals DI seam pattern for test-injectable functions
metadata:
generated_from_knowledge: '["8a374ec6-734e-4b34-9119-1b6148db3a1e"]'
source_knowledge_ids: '["8a374ec6-734e-4b34-9119-1b6148db3a1e"]'
generated_at: "2026-07-06T14:02:41.553Z"
confidence: "0.60"
status: active
version: "1"
skill_origin: generated
---
<!-- generated by opencode-swarm skill-generator. Do not edit by hand; edits will be preserved on regeneration only with controlled update mode. -->
# use _internals DI seam pattern for test-injectable functions
## Trigger
- (no explicit trigger metadata; cluster derived from category/tags)
## Required Procedure
- use _internals DI seam pattern for test-injectable functions
- spread real module exports when mocking node built-ins (import * as real from 'node:module'; mock.module('node:module', () => ({ ...real, targetFn: mockFn })))
- verify mock isolation by running test files in combined mode, not individually
## Forbidden Shortcuts
- rely on mock.module() isolation between test files in bun:test
- declare a test passing based solely on individual file execution
## Delegation Template
When delegating a task affected by this skill, include:
```
SKILLS: file:.opencode/skills/generated/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.md
```
## Reviewer Checks
- Verify each required action above appears in the diff.
## Test Engineer Checks
- Add or update tests covering the trigger condition and the forbidden shortcut.
## Source Knowledge IDs
- 8a374ec6-734e-4b34-9119-1b6148db3a1e — In Bun's shared test-runner process, mock.module() leaks across test files. Always use _internals DI seams or spread-real-exports for node:fs/child_process mocks instead of bare mock.module().
© ZaxbyHub · MIT · ZaxbyHub/opencode-swarm