Skip to main content
skill CX Codex

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

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add ZaxbyHub/opencode-swarm --skill use-internals-di-seam-pattern-for-test-injectable-functions -a claude-code
Open on GitHub

What 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 _internals DI 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 _internals DI 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-code

2Manually: put the files in place

~/.claude/skills/use-internals-di-seam-pattern-for-test-injectable-functions/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/use-internals-di-seam-pattern-for-test-injectable-functions/

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

Similar skills

All skills for Testing and QA →

From the same set121

The whole set →
confirm-failures-are-causally-linked-to-the-task-before-reportin confirm-failures-are-causally-linked-to-the-task-before-reportin is a Claude Code skill that separates pre-existing test failures from new regressions before rejecting work. CX Codex +1 ★ 539repo stars writing-tests writing-tests sets test-authoring rules for the opencode-swarm repository. Use it before changing tests that involve mocks, temporary paths, or regression checks. CX Codex +1 ★ 539repo stars run-affected-test-file-in-isolation-and-in-co-run-with-its-test- run-affected-test-file-in-isolation-and-in-co-run-with-its-test- is a Claude Code skill that makes the agent run tests in isolation and with sibling files after mock cleanup changes. CX Codex +1 ★ 539repo stars update-or-delete-tests-that-assert-intentionally-removed-behavio update-or-delete-tests-that-assert-intentionally-removed-behavio is a Claude Code skill for revising or removing tests of deliberately removed behavior. It applies to code changes that retire a code path. CX Codex +1 ★ 539repo stars worktree-retry-cleanup worktree-retry-cleanup is a Claude Code skill that cleans up a swarm worktree lane before a task is dispatched again. CX Codex +1 ★ 539repo stars swarm Enables a rigorous swarm-style posture with parallel searches, visible plan updates, and dual review gates for code changes. CX Codex +1 ★ 539repo stars research-first The research-first skill checks current documentation and discussions before tracing code when an issue depends on an external framework, tool, or platform. For repo-local questions, it searches the repository instead. CX Codex +1 ★ 539repo stars swarm-pr-subscribe swarm-pr-subscribe monitors open pull requests, triages incoming review comments or CI failures, and applies safe fixes until merge. CX Codex +1 ★ 539repo stars

Project sponsors

Companies that keep this analytics open