Skip to main content

Documentation for this version: github.com/orenlab/codeclone/tree/v2.0.3/docs — the website describes the current release.

CodeClone

A structural review layer for Python — baseline-aware, deterministic, built for CI and AI agents

PyPI Tests Benchmark Python

CodeClone adds a control layer between analysis and CI: it isolates structural regressions from historical debt, so merges are blocked only by what actually got worse.

The same analysis pipeline powers CLI reports, CI checks, the MCP server, and native IDE/agent clients — so humans and AI agents operate on identical, deterministic facts.

Features

Control & governance

  • Baseline governance — separates accepted legacy debt from new regressions; CI fails only on what changed
  • CI-first — deterministic output, stable ordering, exit code contract, pre-commit support
  • Reports — interactive HTML, JSON, Markdown, SARIF, and text from one canonical report

Detection & analysis

  • Clone detection — function (CFG fingerprint), block (statement windows), and segment (report-only) clones
  • Structural findings — duplicated branch families, clone guard/exit divergence, and clone-cohort drift
  • Quality metrics — cyclomatic complexity, coupling (CBO), cohesion (LCOM4), dependency cycles, adaptive depth profile, dead code, health score, and overloaded-module profiling
  • Adoption & API — type/docstring annotation coverage, public API surface inventory and baseline diff
  • Coverage Join — fuse external Cobertura XML into the current run to surface coverage hotspots and scope gaps
  • Security Surfaces — report-only inventory of security-relevant capability boundaries without vulnerability claims

Surfaces & integrations

  • MCP control surface — triage-first agent and IDE interface over the same canonical pipeline; read-only by contract
  • IDE & agent clients — VS Code extension, Claude Desktop bundle, and Codex plugin over the same MCP contract

Performance

  • Fast — incremental caching, parallel processing, warm-run optimization

Quick Start

uv tool install codeclone

codeclone .                    # analyze
codeclone . --html             # HTML report
codeclone . --html --open-html-report
codeclone . --json --md --sarif --text
codeclone . --ci               # CI mode

Run without installing:

uvx codeclone@latest .

CI Workflow

# 1. Generate and commit the baseline
codeclone . --update-baseline

# 2. Enforce it in CI
codeclone . --ci

--ci equals --fail-on-new --no-color --quiet. When a trusted metrics baseline is loaded, CI mode also enables --fail-on-new-metrics.

Exit codes:

Code Meaning
0 Success
2 Contract error — untrusted baseline, invalid config, unreadable sources in CI
3 Gating failure — new clones or metric threshold exceeded
5 Internal error

Contract errors (2) take precedence over gating failures (3).

Reports

codeclone . --html
codeclone . --json
codeclone . --md
codeclone . --sarif
codeclone . --text

All formats are rendered from one canonical report payload.

Report contract: https://github.com/orenlab/codeclone/blob/v2.0.3/docs/book/08-report.md

MCP and Native Clients

uv tool install "codeclone[mcp]"

codeclone-mcp --transport stdio

codeclone --mcp runs the same server with the same arguments, for catalog and uvx launches: uvx --with "codeclone[mcp]" codeclone --mcp --transport stdio.

The MCP server is read-only by contract: it never mutates source files, baselines, cache, or repository state.

Surface Link
VS Code extension https://marketplace.visualstudio.com/items?itemName=orenlab.codeclone
Claude Desktop bundle https://github.com/orenlab/codeclone/tree/main/extensions/claude-desktop-codeclone
Codex plugin https://github.com/orenlab/codeclone/tree/main/plugins/codeclone

MCP docs: https://github.com/orenlab/codeclone/blob/v2.0.3/docs/book/20-mcp-interface.md

Configuration

[tool.codeclone]
baseline = "codeclone.baseline.json"
min_loc = 10
min_stmt = 6
block_min_loc = 20
block_min_stmt = 8
fail_on_new = true
fail_cycles = true
fail_dead_code = true
fail_health = 80

Precedence: CLI flags > pyproject.toml > built-in defaults.

Config reference: https://github.com/orenlab/codeclone/blob/v2.0.3/docs/book/04-config-and-defaults.md

License

  • Code: MPL-2.0 (LICENSE)
  • Documentation and docs-site content: MIT (LICENSE-MIT)

License scope map: https://github.com/orenlab/codeclone/blob/main/LICENSES.md

Metadata

Release files for codeclone 2.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for codeclone 2.0.3
File Size Uploaded Provenance Actions
codeclone-2.0.3.tar.gz 656.0 kB With provenance Details for codeclone-2.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for codeclone 2.0.3
File Interpreter ABI Platform Actions
codeclone-2.0.3-py3-none-any.whl Python 3 none any Details for codeclone-2.0.3-py3-none-any.whl

Total release size: 1.2 MB

Release files / codeclone-2.0.3.tar.gz

Download URL codeclone-2.0.3.tar.gz
Size 656.0 kB
Tags Source
SHA-256 checksum
How to use checksums
524340d6425444146259de034e2b8aa55fa4e3985372f25e55cd175ce03ee90b
BLAKE2b-256 checksum
How to use checksums
d7d458b329f7e299d55b00863337fc82cc326055c542863ca77af55557aa13d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Release files / codeclone-2.0.3-py3-none-any.whl

Download URL codeclone-2.0.3-py3-none-any.whl
Size 496.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39657b1a749537a14c7c27a2be57e69cf5e9ddb2832304233543dace9e77a7a6
BLAKE2b-256 checksum
How to use checksums
c860808d03e8e4ee321ab86e76f746ab4f5561cfca41809d48885f8cbaf2dd3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

Security for codeclone 2.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for codeclone-2.0.3.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 28, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page