cg-file-size-and-function-reduction

Refactors files over 100 lines and functions over 15 lines into decomposed modules.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Large monolithic source files and long functions are hard to read, test, and maintain. This Skill autonomously audits a codebase and decomposes any file exceeding 100 lines and any function exceeding 8–15 lines into small, single-responsibility units across Go, TypeScript, Python, PHP, Rust, and C# projects. ## Core Features & Use Cases - Two-Part Decomposition: First splits oversized functions into helpers of 8 lines or fewer, then extracts cohesive helper clusters into sibling files such as validators, converters, and helpers. - Strict Style Invariants: Enforces wrapper structs for multi-value returns, parameter structs for functions with more than two arguments, positive-only boolean naming, guard clauses with nesting depth of at most one, and mandatory blank lines around returns and block closings. - Exemption Awareness: Leaves data, schema, type definition, lookup table, and constants files untouched while refactoring all logic, services, handlers, and CLI commands. - Use Case: Point it at a Go service with a 400-line handler file; it decomposes the handlers, extracts validation and conversion helpers into sibling files, and finishes with a single atomic conventional commit pushed to the remote branch. ## Quick Start Ask the agent to audit the repository for files over 100 lines and functions over 15 lines and refactor them according to the decomposition rules.

Frequently Asked Questions about cg-file-size-and-function-reduction

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

FAQPage Schema
How do I refactor files that are too long in Go or TypeScript?

Decompose functions longer than 15 lines into helpers of 8 lines or fewer first, then group cohesive helpers into sibling files like validators or converters. This Skill automates that two-part decomposition while preserving whitespace and formatting.

What is the maximum function length this refactoring enforces?

Functions are decomposed to a target of 8 lines or fewer, with a hard cap of 15 lines. Files must stay under 100 lines, with 80 lines recommended, except for exempt data, type, lookup, and constants files.

Which file types are exempt from the 100-line limit?

JSON and YAML data files, dedicated type definition files like types.go or *.d.ts, static lookup and registry files, and centralized constants files may exceed 100 lines. All logic, services, handlers, and scripts must stay under the limit.

Does the refactoring run tests or builds during the process?

No. Intermediate test runs and build checks are explicitly banned during refactoring turns. Compilation is verified only once at the final step, after all extractions and import adjustments are complete.

How are functions with many parameters or return values handled?

Functions returning two or more related values get a dedicated wrapper struct, and functions needing more than two parameters receive an options or params struct. This keeps signatures small and self-documenting.

When should I not use this line-count refactoring approach?

Avoid it for generated code, dense data tables, or schema definitions where line count does not reflect complexity. The Skill already exempts these categories, so forcing decomposition there would fragment cohesive declarations.