split-large-file

Split large source files into modules while preserving imports via barrel re-exports.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/bennybennison/agent-toolkit --skill split-large-file
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: split-large-file
Source: https://github.com/bennybennison/agent-toolkit/tree/main/skills/split-large-file
Command: npx skills add https://github.com/bennybennison/agent-toolkit --skill split-large-file

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Large source files that exceed 300 lines become hard to navigate, test, and maintain, especially when they bundle multiple classes or responsibilities.

Core Features & Use Cases

  • Boundary Identification: Detect natural split points such as separate classes, API groups, or distinct responsibilities.
  • Planning & Mapping: Generate a map of public symbols and import relationships before any file changes.
  • Automated Barrel Creation: Produce a re‑export module so existing imports continue to work after the split.
  • Validation Checklist: Verify line limits, circular imports, and test suite success after refactoring.

Quick Start

Ask the skill to split the file pricing.py into separate modules based on its classes and update imports accordingly.

Frequently Asked Questions about split-large-file

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

FAQPage Schema
How do I split a large Python source file into separate modules without breaking imports?

To split a large Python source file without breaking imports, identify natural boundaries like classes or APIs, extract them into separate modules, and create a barrel re-export file to preserve existing import paths.

When do I need to refactor a large source file into smaller modules?

You need to refactor a large source file into smaller modules when it exceeds 300 lines and becomes hard to navigate, test, and maintain due to bundling multiple classes or distinct responsibilities together.

What is the best way to reorganize codebase files that exceed the 300-line limit?

The best way to reorganize codebase files exceeding the 300-line limit is to map public symbols and import relationships, split the code into files between 50 and 300 lines, and generate an automated barrel re-export module.

How do I update imports after splitting a file into multiple Python modules?

To update imports after splitting a file into multiple Python modules, generate a barrel re-export file at the original location that re-exports the public symbols, ensuring existing import statements continue to work without modification.

What should I check after splitting a large source file into separate modules?

After splitting a large source file, you should run a validation checklist to verify that each resulting file stays between 50 and 300 lines, no circular imports were introduced, and the test suite still passes successfully.

Can I split a file based on distinct responsibilities and API groups instead of classes?

Yes, you can split a file based on distinct API groups or separate responsibilities by detecting natural split points in the code, allowing you to reorganize the source file according to logical boundaries rather than just class definitions.