mock-to-internals-migration
Skill517 starsChanged 3 days agoMITView on GitHub
Codex canon for migrating opencode-swarm tests away from Bun mock.module leakage toward _internals dependency-injection seams. Use when touching tests with mock.module, adding test seams, fixing Bun mock isolation failures, or updating source modules for injectable internals.
We split this skill into the rules it gives an agent
10 rules. About 0 are common, 5 are distinctive, and 5 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 21
Run barrel-import-dependent tests after modifying barrel exports.
- Very specific: line 28
Prefer a small _internals seam exposing only the dependency under test over a new mock.module target — mock.module leaks across test files …
- Distinctive: line 34
Check for existing wrapper patterns before applying sandbox wrapping.
- Distinctive: line 35
Run tests on the unmodified codebase before starting, to establish a failure baseline.
- Very specific: line 37
Run the lint check (e.g. bun run lint) as part of pre-submit verification, not just the build.
- Very specific: line 54
Run git diff <base>..<head> --name-only and confirm file presence before marking introduced_by_pr verdicts.
- Distinctive: line 59
Add or update tests covering the trigger condition and the forbidden shortcut.
- Very specific: line 69
Use apply_patch for source and test edits.
- Very specific: line 70
Use focused per-file bun --smol test <file> --timeout 30000 validation first.
- Distinctive: line 72
Prefer small seams that expose only the dependency under test.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Mock To Internals Migration
This is the canonical Codex migration protocol (self-contained since the #2966
retired-generated-skill reconciliation; it previously delegated to a retired
generated fork). The host-agnostic rules live in AGENTS.md invariant 7 and
.opencode/skills/writing-tests/SKILL.md; this canon carries the migration's own
procedure and checks.
Required Procedure
- Mirror the existing opt-in pattern when gating tools behind feature flags: a
separate tool-map constant, a conditional merge in
src/agents/index.ts, and gating tests verifying BOTH the disabled and enabled states. - Run barrel-import-dependent tests after modifying barrel exports.
- Audit code structure integrity before editing a file that was recently refactored or extracted (the symbol may have moved).
- Grep for all
vi.fn(),vi.spyOn(),vi.mock()in converted files before declaring the conversion complete. - Spread the real module's exports (
...realModule) as the base of everymock.modulereturn object that must remain (Node built-ins especially). - Prefer a small
_internalsseam exposing only the dependency under test over a newmock.moduletarget —mock.moduleleaks across test files in Bun's shared test-runner process (AGENTS.md invariant 7; the allowlist is closed bybun run check:invariantsCheck 4). - Design command-transformation pipelines as idempotent passes, not stacking layers.
- Check for existing wrapper patterns before applying sandbox wrapping.
- Run tests on the unmodified codebase before starting, to establish a failure baseline.
- Run the lint check (e.g.
bun run lint) as part of pre-submit verification, not just the build.
Forbidden Shortcuts
- Invent new tool-gating mechanisms for opt-in feature flags.
- Label post-change test failures as "pre-existing" without having run the tests before the change.
Reviewer Checks
- Grep for import-from-barrel patterns in test files and run the affected tests after barrel changes.
- Grep for
mock.modulepatterns that lack the...realModulespread. - Confirm
bun:testisolation patterns match the skill guidelines. - For wrapper transforms, verify idempotency by applying the transform twice and confirming the output equals the single-call output.
- Run
git diff <base>..<head> --name-onlyand confirm file presence before markingintroduced_by_prverdicts.
Test Engineer Checks
- Add or update tests covering the trigger condition and the forbidden shortcut.
Also load:
.agents/skills/writing-tests/SKILL.md.agents/skills/engineering-conventions/SKILL.mdif the seam touches runtime-sensitive code
Codex-specific execution notes:
- Use
apply_patchfor source and test edits. - Use focused per-file
bun --smol test <file> --timeout 30000validation first. - Restore any
_internalsoverrides inafterEach. - Prefer small seams that expose only the dependency under test.
Other versions1 project uses a version of this.
Word for word · 1
- zaxbysauce/opencode-swarm★ 517100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository66 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- .github/copilot-instructions.mdCopilot instructions
- ci-fix-monitorSkill
- codebase-review-swarmSkill
- commit-prSkill
- contributingSkill
- engineering-conventionsSkill
- fork-pr-operationsSkill
- guardrail-patternsSkill
- issue-tracerSkill
- pr-review-fixSkill
- qa-sweepSkill
- research-firstSkill
- running-testsSkill
- subprocess-safetySkill
- swarm-ci-monitorSkill
- swarm-implementSkill
- swarm-pr-feedbackSkill
- swarm-pr-reviewSkill
- swarm-pr-subscribeSkill
- swarmSkill
- tech-debt-ci-reviewSkill
- test-file-splitSkill
- unswarmSkill
- writing-testsSkill
- brainstormSkill
- clarifySkill
- clarify-specSkill
- codebase-review-swarmSkill
- commit-prSkill
- consultSkill
- councilSkill
- critic-gateSkill
- deep-diveSkill
- deep-researchSkill
- design-docsSkill
- discoverSkill
- durable-session-stateSkill
- editing-skillsSkill
- engineering-conventionsSkill
- executeSkill
- fork-pr-operationsSkill
- graphifySkill
- issue-ingestSkill
- issue-tracerSkill
- orchestrating-subagentsSkill
- phase-wrapSkill
- pre-phase-briefingSkill
- qa-sweepSkill
- research-firstSkill
- rust-crate-ciSkill
- specifySkill
- swarm-ci-monitorSkill
- swarm-implementSkill
- swarm-planSkill
- swarm-pr-feedbackSkill
- swarm-pr-reviewSkill
- swarm-pr-subscribeSkill
- swarm-resumeSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

