modularize
Automatically refactor, split, and compress codebase files when they exceed size or complexity boundaries.
Skill by yamcodes
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/yamcodes-modularize
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions: not checked yet.
What's inside
- Skill 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.
- License
- MIT
- Metadata
- internal: true
- Instructions
- 52 lines in SKILL.md · view on GitHub
Files (2)
- SKILL.md
- evals.json · evals/
SKILL.md (first lines)
# 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`).
From yamcodes/the-hat, MIT.
More from yamcodes/the-hat
- 0.522score
codebase-design
yamcodes
Shared vocabulary for designing deep modules.
SkillBFreshness: B★ 1Claude Code +9 - 0.522score
domain-modeling
yamcodes
Build and sharpen a project's domain model.
SkillBFreshness: B★ 1Claude Code +9 - 0.522score
grilling
yamcodes
Grill the user relentlessly about a plan, decision, or idea.
SkillBFreshness: B★ 1Claude Code +9 - 0.511score
implement
yamcodes
Implement a piece of work based on a spec or set of tickets.
SkillBFreshness: B★ 1Claude Code +9
Signals
- Stars
- 1
- Forks
- 0
- Open issues
- 6
- Last commit (this folder)
- Aug 24, 2026 (2 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/yamcodes/the-hat
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
Same skill elsewhere
Copies of this SKILL.md published by others; search shows only one of them.
More from yamcodes
- 0.789score
create-skill
yamcodes
Create new skills, modify and improve existing skills, and measure skill performance.
SkillAFreshness: A★ 147Claude Code +9 - 0.786score
gh-cli
yamcodes
Use for GitHub-related tasks such as managing issues, pull requests, actions runs, and repository configuration using the GitHub CLI (gh).
SkillAFreshness: A★ 147Claude Code +9 - 0.783score
code-review
yamcodes
Fetch, analyze, and address code reviews and comments on GitHub, or perform a code review on changes in the workspace.
SkillAFreshness: A★ 147Claude Code +9 - 0.783score
forward-port
yamcodes
Manually forward-ports merged dev (v0) changes to the v1 branch, adapting code to v1's package layout and changeset names.
SkillAFreshness: A★ 147Claude Code +9 - 0.783score
arkenv
yamcodes
Answer questions about ArkEnv and help implement environment variable validation.
SkillAFreshness: A★ 147Claude Code +9 - 0.783score
groom-issue
yamcodes
Groom a poorly written issue by grilling the user to clarify requirements, updating the issue on GitHub via the gh cli, and utilizing the triage skill to…
SkillAFreshness: A★ 147Claude Code +9
Cite this page
modularize skill. Agent Mart. https://agentmart.dev/skills/yamcodes-modularize (last updated 2026-10-24)