This skill should be used when the user asks about "file size", "large file", "split file", "file too long", "LOC limit", "organize Go files", or needs guidance on when and how to split large Go source files.
Detects when Go files are too large and suggests strategic splits based on responsibility, entities, or complexity patterns.
/plugin marketplace add dkoosis/cc-plugins/plugin install go-filesize@cc-pluginsThis skill inherits all available tools. When active, it can use any tool Claude has access to.
Strategies for managing large Go source files and planning strategic splits.
Large files are harder to navigate, understand, and maintain. However, not all large files should be split - cohesive code should stay together.
| Lines | Tier | Recommendation |
|---|---|---|
| <500 | 🟢 Green | No action needed |
| 500-999 | 🟡 Yellow | Monitor, consider if growing |
| ≥1000 | 🔴 Red | Evaluate for split |
Multiple Responsibilities
Multiple Entity Types
Mixed Abstraction Levels
Navigation Difficulty
Just to meet line limit
Arbitrary groupings
Small splits
Breaking cohesion
Split file along clear responsibility boundaries.
Before: handler.go (1500 lines)
- 400 lines: HTTP handlers
- 350 lines: Validation logic
- 300 lines: Response formatting
- 250 lines: Middleware
- 200 lines: Helpers
After:
handler.go (400 lines) - HTTP handlers
validation.go (350 lines) - Validation
response.go (300 lines) - Response formatting
middleware.go (250 lines) - Middleware
helpers.go (200 lines) - Shared helpers
Split when one file handles multiple domain entities.
Before: store.go (2000 lines)
- User CRUD operations
- Order CRUD operations
- Product CRUD operations
- Shared database helpers
After:
store.go (200 lines) - Shared helpers, interface
store_user.go (600 lines) - User operations
store_order.go (700 lines) - Order operations
store_product.go (500 lines) - Product operations
Split public API from implementation details.
Before: parser.go (1200 lines)
- Parse() - main entry point
- Internal parsing functions
- Helper functions
After:
parser.go (200 lines) - Public API (Parse, Config)
parser_impl.go (800 lines) - Core parsing implementation
parser_util.go (200 lines) - Utility functions
Extract complex algorithms into dedicated files.
Before: process.go (1500 lines)
- Simple orchestration
- Complex algorithm A (500 lines)
- Complex algorithm B (600 lines)
After:
process.go (400 lines) - Orchestration
process_algo_a.go (500 lines) - Algorithm A
process_algo_b.go (600 lines) - Algorithm B
| Pattern | Example | Use Case |
|---|---|---|
{name}.go | handler.go | Core/primary file |
{name}_{aspect}.go | store_user.go | Entity/aspect variant |
{aspect}.go | validation.go | Standalone aspect |
Some files are appropriately large:
Single complex algorithm
Generated code
Type definitions with methods
Document these decisions:
// Package expr implements expression parsing.
//
// This file is intentionally large (~1200 LOC) because the
// recursive descent parser is highly interconnected and
// splitting would obscure the algorithm flow.
// See ADR-015 for the decision rationale.
package expr
Before splitting, verify:
After splitting, verify:
go build ./... passesgo test ./... passesgolangci-lint run ./... passesGenerally keep test files together unless:
When splitting tests:
store_test.go → Common test helpers
store_user_test.go → User tests
store_order_test.go → Order tests