split

File splitting for large files

Go File System GitHub

Split large files into manageable chunks for AI processing. Respects code boundaries and produces structured output.

Features

  • Split files by line count or byte size
  • Respects code boundaries (functions, blocks)
  • Structured JSON output with chunk metadata
  • MCP server and CLI modes

Install

go install github.com/hegner123/split@latest

The Problem: Files too large for AI context windows

# A 3000-line file exceeds what an AI can process at once.
# Manually splitting risks breaking mid-function.
# You need smart boundaries, not arbitrary line cuts.

Solution

$ split --cli --file large_module.go --lines 500

Output

{"file":"large_module.go","total_lines":2847,"chunks":6,"parts":[{"start":1,"end":498,"lines":498},{"start":499,"end":997,"lines":499},{"start":998,"end":1495,"lines":498},{"start":1496,"end":1993,"lines":498},{"start":1994,"end":2491,"lines":498},{"start":2492,"end":2847,"lines":356}]}

Comparison

MetricValue
Boundary awarenessRespects code blocks
Split modesBy lines or bytes