go-split-file

Split Go files into smaller files grouped by logical units.

2|Updated Feb 24, 2026
One-click install
npx skills add https://github.com/lestrrat/claude-code --skill go-split-file
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: go-split-file
Source: https://github.com/lestrrat/claude-code/tree/main/skills/go-split-file
Command: npx skills add https://github.com/lestrrat/claude-code --skill go-split-file

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Split large Go files into cohesive, smaller files grouped by logical units to improve readability and maintainability of Go codebases.

Core Features & Use Cases

  • Automatic grouping of related declarations: types, functions, interfaces, and their constructors and methods.
  • Preserves package structure and comments to maintain build correctness and readability.
  • Generates new files named after primary types in snake_case and places related declarations together to minimize cross-file dependencies, suitable for refactoring and module maintenance.

Quick Start

Provide the path to the Go source file to split and the tool will generate grouped .go files.

Frequently Asked Questions about go-split-file

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

FAQPage Schema
How do I split a large Go file into smaller files?

To split a large Go file, you can use tools that analyze package structure and top-level declarations to group related types, functions, and methods into cohesive, smaller files. This process generates new files named after primary types in snake_case to improve maintainability.

How are Go methods and constructors grouped when refactoring code?

When refactoring Go code, methods and constructors are grouped by analyzing their method receivers. This ensures that related declarations, interfaces, and their associated functions are placed together in the same new file to minimize cross-file dependencies.

Does splitting Go files preserve package structure and comments?

Yes, splitting Go files preserves package structure and comments. Maintaining the original package declarations and comments ensures that the newly generated files integrate correctly with the Go build process and retain their readability.

What is the best way to organize Go code by logical units?

The best way to organize Go code by logical units is to analyze top-level declarations and method receivers, grouping related types and functions together. This refactoring approach creates logically grouped outputs named after primary types to enhance codebase maintainability.

Can I automate Go file splitting for large codebases?

Yes, you can automate Go file splitting by providing the path to the source file. The tool automatically analyzes package structure and generates grouped .go files, making it suitable for module maintenance and large codebase refactoring.

When should I split Go files to improve code maintainability?

You should split Go files when a single file becomes too large to manage, affecting readability. By grouping top-level declarations and method receivers into smaller, cohesive files named after primary types, you minimize cross-file dependencies and improve maintainability.