mutation-test-barrel-import-trap

Diagnoses slow Stryker mutation runs caused by aggregate barrel imports and rewrites them to per-component entries.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/VilnaCRM-Org/claude-plugins --skill mutation-test-barrel-import-trap-vilnacrm-org
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: mutation-test-barrel-import-trap
Source: https://github.com/VilnaCRM-Org/claude-plugins/tree/main/plugins/react-frontend-sdlc/skills/mutation-test-barrel-import-trap
Command: npx skills add https://github.com/VilnaCRM-Org/claude-plugins --skill mutation-test-barrel-import-trap-vilnacrm-org

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? When Stryker's jest runner uses enableFindRelatedTests, a source module that imports from an aggregate barrel like @/components becomes related to every component export, so one test suite re-runs for mutants across the whole repository and the mutation gate times out or drags for hours. ## Core Features & Use Cases - Root-cause diagnosis: Traces the slow suite one level down into the rendered module to find the aggregate import edge that inflates the related-test set. - Import rewrite guidance: Replaces import { UiTypography } from '@/components' with the per-component public entry @/components/ui-typography, respecting each entry's export shape and boundary rules. - Fail-closed prevention audit: Provides a grep-based lint gate that blocks new aggregate imports (including dynamic and side-effect forms) while exempting entry barrels. - Use Case: A Next.js project's mutation shard times out with the same suite reloading for unrelated mutants; this Skill locates the @/components import in the rendered module, rewrites it to the component's own barrel, and adds the audit so the trap cannot return. ## Quick Start Ask the AI to find why the mutation test suite re-runs for unrelated mutants and fix any aggregate @/components imports to use per-component entries.

Frequently Asked Questions about mutation-test-barrel-import-trap

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
Why does one test suite re-run for every mutant in Stryker?▼

Stryker's jest runner with enableFindRelatedTests uses the import graph to pick related tests. A module importing from an aggregate barrel like @/components is recorded as depending on every export, so its suites become related to mutants in every component.

How do I fix slow mutation testing caused by barrel imports?▼

Replace the aggregate import with the target component's own public entry, for example changing import { UiTypography } from '@/components' to import UiTypography from '@/components/ui-typography'. Check the entry's export shape and keep the style consistent across all consumers.

Does this barrel import trap apply to Next.js and React SPA projects?▼

Yes for Next.js apps, where the components index is an aggregate barrel and enableFindRelatedTests is on. For React SPA shapes with dependency-cruiser boundary gates the remedy is leaf extraction instead, and for component libraries the cost is latent when related-tests lookup is disabled.

How do I prevent aggregate barrel imports from coming back?▼

Add a fail-closed grep audit beside the lint gates that scans the source root for import, from, and dynamic import() specifiers matching the aggregate alias, including side-effect imports, while exempting the entry barrels whose job is re-exporting the aggregate surface.

When should I not replace a barrel import with a deeper import?▼

Do not replace it when the repository's public-API contract requires the barrel import; in that case move the shared leaf out of the aggregate instead. Also never reach past a component's public entry into its internals, since that violates the boundary rules.