modularize
/modularize
Automatically refactor, split, and compress codebase files when they exceed size or complexity boundaries. Trigger when the user requests to split a file, modularize code, or refactor a large module, and when files exceed size (~200 lines) or complexity guidelines.
- Author
- yamcodes ↗
- Repository
- arkenv ↗
- Licence
- MIT
- Last repository change
- 23.10.2026
Assessment and security
- Files in this package
- 2
- Scripts
- 0
- HTML comments
- 0
- URLs in SKILL.md
- 0
No signals detected. Repository changed on 23.10.2026, without references to retired models or APIs.
MIT, open: use and modify while retaining author attribution.
What it does and when to use it
Automatically refactor, split, and compress codebase files when they exceed size or complexity boundaries. Trigger when the user requests to split a file, modularize code, or refactor a large module, and when files exceed size (~200 lines) or complexity guidelines.
Original author description
Automatically refactor, split, and compress codebase files when they exceed size or complexity boundaries. Trigger when the user requests to split a file, modularize code, or refactor a large module, and when files exceed size (~200 lines) or complexity guidelines.
How it works
- 1. Core heuristics & guardrails
- 2. Refactoring patterns
- 3. Step-by-step workflow
SKILL.md preview
--- name: modularize description: Automatically refactor, split, and compress codebase files when they exceed size or complexity boundaries. Trigger when the user requests to split a file, modularize code, or refactor a large module, and when files exceed size (~200 lines) or complexity guidelines. metadata: internal: true --- # Modularize A skill for automatically refactoring, splitting, and compressing codebase files when they exceed size or complexity boundaries. ## 1. Core heuristics & guardrails Rather than enforcing a strict, rigid line count, utilize \~200 lines as a **warning light/signal** to evaluate logical cohesion and maintainability. ### Heuristics to evaluate before refactoring: - **Logical Cohesion**: Does the file focus on one primary concern? Or does it contain independent blocks? - **Function/Block Size**: Prioritize keeping functions small (under 20-30 lines) first. - **Nesting/Complexity**: High cyclomatic complexity/nesting vs. simple flat lists. - **Fragmentation Risk**: Avoid "jump-to-definition" fatigue by not over-splitting cohesive units. ### Guardrails: - **The "Abort" Condition**: Skip refactoring if the file is predominantly a configuration dictionary, list of constants, or single massive switch statement that logically belongs together. - **API Contract Preservation**: Maintain public APIs using barrel files (e.g., `index.ts`) to re-export split modules, preventing breaking changes for consumers. - **Dependency Injection**: Favor passing context via arguments rather than creating tangled relative imports (e.g., `../../../`). --- ## 2. Refactoring patterns ### A. test files For large test suites (e.g., splitting a 600+ line test file): - **Split by Behavior/Topic**: Group tests into separate files named after the feature or option under test (e.g. `coercion.test.ts`, `arrays.test.ts`, `options.test.ts`, etc.). - **Shared Setup**: Extract common setup, beforeEach/afterEach hooks, mocks, or helper functions into a small local test utility or shared helper file, but only when duplication is real and significant. - **Run Focused Tests**: After splitting, run the affected test suite files individually before running the wider project check. ### B. source modules For CLI commands, components, or services: - **Isolate Concerns**: Isolate interactive UI prompts, file system adapters, API clients, and terminal reporters into discrete sub-modules. - **High-Level Orchestrator**: Keep the original file purely as a high-level orchestrator that coordinates the sub-modules. - **Avoid Speculative Abstractions**: Avoid creating generic reusable classes/functions before there are multiple active callers. Keep them as local module splits first. --- ## 3. Step-by-step workflow 1. **Inspect & Classify**: Read the file, identify dependencies/imports, and evaluate heuristics to decide whether to refactor or abort. 2. **Design Boundaries**: Formulate a plan for the split. Define clear boundaries, minimal interfaces, and ensure no public contracts are broken. 3. **Incremental Execution**: Extract sub-modules or smaller test files in small, logical batches. Check compilation/type-checking at each step. 4. **Update Imports & Exports**: Re-wire caller modules, update barrel/index files, and resolve imports cleanly. 5. **Verify**: Run the targeted tests, execute typechecking (e.g., `pnpm typecheck` or `pnpm typecheck:packages`), run the package build step (e.g., `pnpm build` or `pnpm build:packages`) to guarantee ESM/CJS module resolution/exports remain intact, and execute linting and formatting checks (e.g., `pnpm fix`).
Files in this package (2)
- SKILL.md 4 KB
- evals/evals.json 2 KB
Versions
| Repository | Score | Licence |
|---|---|---|
| This page · yamcodes/arkenv | 90 | MIT |
| anthony-chaudhary/fak | 100 | Apache-2.0 |
| fusengine/agents | 90 | MIT |
Database snapshot: 13.11.2026 · package version aaa7cd16676d (SHA-256 digest of the entire package)
Downloads in the last 30 days: 0 · ranking
Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.
Similar skills
- 100refactor-plan
Code-level refactoring analysis and roadmap. Detects duplication and complexity. Triggers on: refactor, tech debt, simplify, clean up, modularize, DRY, restructure. - 100software-design-complexity
Manage software complexity through deep modules, information hiding, and strategic programming. Use when the user mentions "module design", "API too complex", "shallow class", "complexity budget", or "strategic vs tactical". Covers deep vs shallow modules, red flags for… - 100modularize-brave-browser
Modularize Brave browser code: move a //brave/browser directory out of the brave_chrome_browser_sources monolith into its own headers/impl/test targets, or remove an allow_circular_includes_from entry from Brave GN files. Triggers on: modularize, componentize, Project Bedrock,… - 98tl-complexity-assessment
Find large files, god modules, and refactoring candidates in TypeScript/JavaScript/React codebases. Use when files feel "too big", planning a refactor sprint, onboarding to legacy code, or asking "what should I split up? - 100modularize-chrome-browser
Modularize a chrome/browser/ subfolder by splitting its sources out of the monolithic //chrome/browser:browser target into dedicated source_set targets in the subfolder's own BUILD.gn. Use when the user asks to modularize, extract, or create BUILD targets for a chrome/browser/… - 100codebase-organizer
Monitor and refactor large files into smaller, AI-friendly modules. Use when user asks to check file sizes, split large files, or organize the codebase. Ensures tests pass before and after refactoring.