nuclear-package-modularization

Modularize monolithic Go packages into acyclic subpackages and isolate heavy subprocess tests.

Updated May 16, 2026
One-click install
npx skills add https://github.com/alimtvnetwork/img-pdf-v2 --skill nuclear-package-modularization-alimtvnetwork
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nuclear-package-modularization
Source: https://github.com/alimtvnetwork/img-pdf-v2/tree/main/.agents/skills/nuclear-package-modularization
Command: npx skills add https://github.com/alimtvnetwork/img-pdf-v2 --skill nuclear-package-modularization-alimtvnetwork

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Large monolithic Go packages cause compiler bloat, slow test suites, and circular dependency risk. This Skill autonomously decomposes them into small acyclic subpackages while separating slow subprocess-based tests from fast in-memory unit tests. ## Core Features & Use Cases - Strict DAG Architecture: Enforces a layered package graph where root packages dispatch to domain subpackages and leaf packages carry zero domain dependencies, eliminating Go import cycles. - Heavy Test Isolation: Moves tests using exec.Command, external git processes, sockets, or time.Sleep into blackbox heavy_test packages, keeping routine unit tests under 0.05 seconds. - Test Inventory & Cache Freshness: Maintains .ai-memory/test-inventory.json with profiled durations and applies a 5-day cache freshness decision engine to avoid redundant test runs. - Use Case: Given a bloated Go CLI package with mixed fast and slow tests, the Skill records your request verbatim, profiles the test inventory, splits the package into a DAG of subpackages, relocates heavy tests, and verifies the result with go vet and go build. ## Quick Start Ask the AI to modularize a specified monolithic Go package into acyclic subpackages and isolate its heavy subprocess tests into a heavy_test package.

Frequently Asked Questions about nuclear-package-modularization

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

FAQPage Schema
How do I split a monolithic Go package into subpackages?

Split a monolithic Go package by organizing code into a directed acyclic graph: root packages dispatch to domain subpackages, which only import leaf packages like constants, models, and utilities. Leaf packages must never import their callers, which prevents import cycles.

How to isolate slow subprocess tests in Go?

Move tests that invoke exec.Command, external git processes, sockets, or time.Sleep into a dedicated tests/heavy_test directory under package heavy_test as blackbox tests. This keeps routine package unit tests fully in-memory and under 0.05 seconds each.

What causes import cycle not allowed errors in Go?

Import cycles occur when packages mutually depend on each other directly or transitively. The fix is a strict DAG architecture where dependencies flow one direction from root to domain to leaf packages, with leaf packages having zero domain dependencies.

Does this refactoring approach verify the build still works?

Yes, verification runs go vet ./... and go build ./... strictly at the final step and requires exit code 0. This confirms the modularized packages compile cleanly and pass static analysis after restructuring.

When should test duration profiling be re-run?

Re-run profiling when the test inventory cache is stale, missing, or unprofiled. The decision engine checks cache age with a 5-day threshold; fresh caches with profiled durations are ingested directly without re-running the full test suite.