Split one giant app.js into clean, load-ordered modules.

Pure static analysis — no bundler, no LLM, no config. JS, TypeScript, HTML inline scripts and Python. Grouped by real dependencies, ordered so nothing runs too early, with a drop-in loader so your pages keep working.

$ npx splitcode app.js ./split-out 

● npm release pending — from-source instructions work today.

0statements in → out
0focused files
0ordering violations
0files in tarball

Why SplitCode?

Built for legacy scripts and plugin-style code that bundlers can't touch.

📦

Break up monoliths

Turn a 500KB script into focused files grouped by what actually depends on what.

🔗

Correct load order

Immediate references enforce ordering; deferred callbacks don't — no false cycles.

🚀

Drop-in loader

Generated app.js pulls in every file in order. Change nothing else.

🧠

Scope-aware analysis

IIFEs, block scoping, window.x globals, decorators and Promise executors handled correctly — in JS, TS and Python.

🔍

Honest manifest + preflight

Hubs, duplicates, cycles and parser mode reported — plus a pre-split risk scan per file type (--check runs it alone).

⚡

Zero config

Three tiny runtime deps (acorn + HTML parser; typescript optional, only for .ts). One command, honest manifest, 30-test suite.

Watch it work

Live terminal replay — exactly what you run.

Usage

Defaults do the right thing — flags only override.


BeforeAfter SplitCode
460KB single app.js18 focused files + loader
Load order implicit, fragileComputed topological order, 0 violations
Duplicate declarations silentReported in console + manifest
Refactoring means manual surgeryOne command, reproducible

Stop feeding 500KB files to your agent

Every read of a 460KB file costs ~115K tokens. SplitCode runs blind — one deterministic command, zero context spent — then your agent plans from a ~500-token manifest and edits one small file per task. Up to ~85% fewer tokens per edit.

1️⃣

Split without reading

Agent runs one command. Same input always gives same output — deterministic, no LLM variance, safe to run blind.

2️⃣

Plan from JSON

manifest.json lists files, declarations, hubs and load order — a machine-readable task plan, no code reading required.

3️⃣

Edit small, test always

Work file-by-file, never reorder order, rerun tests after each change. Syntax is proven; behavior is yours to verify.


You are refactoring a large file. Do NOT read it whole.
1. Run: npx splitcode app.js ./split-out
   (or from source: node split-js.js app.js ./split-out)
2. Read ./split-out/manifest.json — `order` is the load order,
   `declares` tells you what lives where, `hubNamesSuppressed`
   is shared state. Plan your edits from this file alone.
3. Open only the files you must change. Never reorder `order`,
   never rename the loader. Rerun the app's tests after every edit.
4. The manifest says "verified": "syntax-only" — that proves
   syntax, NOT behavior. You own the smoke test.

Prefer automatic invocation? Copy skills/splitcode/SKILL.md into your project's .claude/skills/ — or paste the prompt above into CLAUDE.md / AGENTS.md.