Skip to main content

Polyglot structural-analysis platform: extract dependency graphs, visualize coupling, track architectural drift.

Project description

code-split

CI codecov dependencies Crates.io npm PyPI License

Structural-analysis tool for Rust, Python, JavaScript and TypeScript codebases. Built AI-agent-friendly first — finds where a project has structural problems and hands an actionable shortlist to a human or an AI agent for the actual refactor.

👉 Map your codebase's worst structural problems in 30 seconds — jump to the Rust quick start and run it on your repo now.

Status: pre-alpha. APIs and output shapes may change without notice. Pin a specific version.

Rust quick start

cargo install code-split --version 1.0.0-alpha.4   # install the CLI
code-split report .                                # make html report in .code-split/ folder

report . needs no flags: it writes a self-contained HTML report (plus a JSON snapshot) into .code-split/. Open the latest …-<commit>.html to explore the dependency graph, per-file metrics, and the AI prompt generator. Everything below is detail.

Offline & private

code-split always runs entirely on your machine. It makes no network calls, sends no telemetry or analytics, and never uploads your code or analysis results anywhere. Generated HTML reports are self-contained — no CDN, no external requests, no tracking.

AI agents friendly

Hand your codebase to an AI agent and let it fix the worst spot. code-split is built to feed work straight to an AI coding agent (Claude Code, Cursor, …). Attach the short playbook docs/ai-skill.md to your agent's context — it teaches the agent which two metrics matter (dependency cycles ADP, coupling HK) and the exact fix loop (scorecard → snapshot → fix → re-check → before/after report).

Then just ask, e.g.:

  • "Read ai-skill.md. Find the worst dependency cycle in this project and propose a refactor that breaks it — show me the plan before changing code."
  • "Read ai-skill.md. Find the most complex / highest-HK file and analyze how to split it; explain what the split buys (lower coupling, smaller blast radius). Take a before report, apply the split, take an after report, and show me the HTML diff."

The agent drives the CLI itself — ai-skill.md already spells out the commands and the loop, so no glue is needed.

What it finds

  • Files that grew too complex and should be split. Per-file cyclomatic / cognitive / Halstead / MI metrics; flags files above your threshold.
  • Strong coupling between files. Computes fan-in / fan-out / HK on the file dependency graph; surfaces the files that everything depends on (or that depend on everything). Third-party libraries are tracked separately as depth-1 external nodes (fan_out_external), so they never inflate your internal-coupling numbers.
  • Cyclic dependencies. Detects SCCs in the file graph — including the silent ones the compiler does not catch.
  • Files that are just too big. Raw LOC, public surface size per file.

The tool does not refactor for you. It produces a structured, machine-readable list of problem spots and an offline HTML report a human or an LLM can act on.

CI integration

Runs as a linter. Configure thresholds in code-split.toml; the CLI exits non-zero when the codebase breaches them — so a PR that introduces a new cycle, a file above your cognitive budget, or a file above your LOC limit fails the build.

code-split check . \
  --threshold file.cognitive=25 --threshold file.loc=800

The linter is the check command — exits non-zero on any cycle or threshold violation, e.g. a PR that introduces a new file-level cycle or a file above your LOC limit (mutual and chain cycle checks are on by default). See docs/CLI.md for all flags.

Add it to your pipeline today — one code-split check step stops new cycles and bloat from ever landing.

Full CLI

Written in Rust — fast, memory-safe, single static-ish binary with no runtime dependencies (no Python, no Node, no JVM, no shared libs to install). One file on PATH, done.

Two commands: check (linter — exits non-zero on violations; with --baseline, a relative regression gate) and report (snapshot JSON + offline HTML; with --baseline, a baseline↔current diff). Both accept a directory or an existing .json/.html snapshot as input — analyze once, then run cheap passes over the snapshot. No daemon, no language server, no plugin host required at runtime. Full reference: docs/CLI.md.

HTML report with dynamic diagrams

code-split report writes a single self-contained HTML file with:

  • An interactive file dependency graph; third-party libraries appear as depth-1 external nodes in a distinct amber colour with dashed edges.
  • Dagre-laid-out graph with pan/zoom and live filtering.
  • Sortable table per metric; click a node to open its neighbourhood.
  • "Prompt generator" panel that copies a ready-to-paste prompt (one for each principle: ADP, SRP, OCP, LSP, ISP, DIP, DRY, KISS, LoD, MISU, CoI, YAGNI; plus Reduce Complexity, Split Components) — feed the prompt + the selected nodes to your AI agent.

No network, no analytics, no telemetry. Open in any browser, share as a file.

Live demo — code-split run on its own repo: interactive HTML report · JSON snapshot (regenerated on every push to main).

Install

Package pages: crates.io · npm · PyPI · Docker Hub · GHCR

Pick a channel:

# universal — shell installer that drops the prebuilt binary on PATH
curl -fsSL https://github.com/ffedoroff/code-split/releases/latest/download/code-split-installer.sh | sh

# Windows
powershell -ExecutionPolicy ByPass -c "irm https://github.com/ffedoroff/code-split/releases/latest/download/code-split-installer.ps1 | iex"

# Rust (Cargo)
cargo install code-split --version 1.0.0-alpha.4

# Node (npm)
npm install -g code-split

# Python (pip / uv / pipx)
pip install code-split

# Docker (Docker Hub)
docker pull fedoroff/code-split:1.0.0-alpha.4

# Docker (GHCR — no anonymous rate limits)
docker pull ghcr.io/ffedoroff/code-split:1.0.0-alpha.4

All channels ship the same code-split binary built from the same Rust source. Linux (x86_64, aarch64), macOS (x86_64, aarch64), Windows (x86_64).

Quick start

# lint a project — non-zero exit on violations (CI linter)
code-split check ./path/to/project

# analyze and write a snapshot JSON + offline HTML report
code-split report
# → .code-split/{ts}-{git-hash-3}.json + .code-split/{ts}-{git-hash-3}.html
#   (override paths via --output.<fmt>.path or [output.<fmt>] in code-split.toml)

# before / after refactor comparison: an HTML diff against a baseline snapshot
code-split report . --baseline .code-split/before.json

Built-in plugins: rust (cargo + syn), python, javascript (also handles TypeScript) — all compiled into the single binary, nothing to install.

Documentation

  • CLI — commands, flags, and examples
  • Rule reference — rule ids grouped by concern (CYC/CPX/CPL/SIZ), per-file thresholds (file), what each flags, and how to fix it
  • Configcode-split.toml schema
  • AI agent skill — a short playbook to attach to an AI agent's context (the ADP/HK fix loop)
  • PRD — product requirements
  • DESIGN — technical design
  • Principles corpus — Rust / Python / TypeScript principle catalogues used by the prompt generator

Try it now

cargo install code-split --version 1.0.0-alpha.4 && code-split report . && open .code-split/

One command on any Rust project — you'll have an interactive structural map and an AI-ready shortlist in seconds. ⭐ the repo if it helps.

License

Apache-2.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

code_split-1.0.0a4.tar.gz (823.2 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

code_split-1.0.0a4-py3-none-win_amd64.whl (5.1 MB view details)

Uploaded Python 3Windows x86-64

code_split-1.0.0a4-py3-none-manylinux_2_28_x86_64.whl (5.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

code_split-1.0.0a4-py3-none-manylinux_2_28_aarch64.whl (4.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

code_split-1.0.0a4-py3-none-macosx_11_0_arm64.whl (4.8 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

File details

Details for the file code_split-1.0.0a4.tar.gz.

File metadata

  • Download URL: code_split-1.0.0a4.tar.gz
  • Upload date:
  • Size: 823.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_split-1.0.0a4.tar.gz
Algorithm Hash digest
SHA256 39d8a056e29aadc79f158cdbf4f4dea37d3efced0329c4eaed67332fcf0986d4
MD5 3525728d93986ce58093271c6d092d6f
BLAKE2b-256 fd32052e4d9d754b97fc574397de9cc9ab33713e7038661d746caf5f872ac3ad

See more details on using hashes here.

File details

Details for the file code_split-1.0.0a4-py3-none-win_amd64.whl.

File metadata

  • Download URL: code_split-1.0.0a4-py3-none-win_amd64.whl
  • Upload date:
  • Size: 5.1 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for code_split-1.0.0a4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 bcd43a435c0735079112b8eb1caefbdb719589c084933ed2074c9171caacaf92
MD5 c73d482eb7d57daec4e535bdfbd46363
BLAKE2b-256 f86c65fcc5bc429b62982badbc89c58bfd94521406bf0e0816b4dcde634d0bef

See more details on using hashes here.

File details

Details for the file code_split-1.0.0a4-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for code_split-1.0.0a4-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 18ded81debab5e747901af7f7fe103bf887932e4b7b7a24e91f639730620692b
MD5 51348d2573fc49c3b88066efd52b87fd
BLAKE2b-256 b782a6f7b5020c206c4b015385bf764ad56fddbc46cb21af8baefdfd038cf8de

See more details on using hashes here.

File details

Details for the file code_split-1.0.0a4-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for code_split-1.0.0a4-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 7219e12e936a040222863e67718aea6f2536991c7b69381ecb01d0315fb8e71d
MD5 f4a90ecf92bf8f88f96a0124621592d4
BLAKE2b-256 5db8d37136714d375a70d3d72cd868d15add8c05b51ae824d54975df214480c1

See more details on using hashes here.

File details

Details for the file code_split-1.0.0a4-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for code_split-1.0.0a4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3113d1c6814e2f3c306b9b741d06ab9662a4ab5c467c78cef582a900d345e5a1
MD5 921b1f87b30e7b67fbd09c1c8d5010b4
BLAKE2b-256 00274d725f7f0dd0983c0130f3599b24979c00305734891a87273010ee8b42a1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page