CodeClone

by orenlab

Not rated
GitHub

About

Structural code quality analysis for Python with baseline-aware CI governance, canonical reports, and a triage-first MCP control surface for agents and IDEs.

Details

Author
orenlab
Categories
Developer Tools

Setup

Install CodeClone in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/orenlab/codeclone

Follow the installation instructions in the repository README, then restart your MCP client.

Deterministic Structural Change Controller for AI-assisted Python development

Let agents move fast.
Keep structural change explicit, bounded, and verifiable.

[!IMPORTANT] Sections marked2.1 alpharequire theCodeClone 2.1 prerelease. Everything else works with the current stable release,CodeClone 2.0.2.

CodeClone helps developers use AI coding agents without losing control of structural change.

Before an agent edits code, CodeClone records the intended change, maps the structural blast radius, and establishes explicit edit boundaries. After the edit, it compares the real patch with the declared scope, verifies structural regressions, and leaves an auditable review receipt.

CodeClone does not generate or rewrite source files, and it does not ask an LLM to decide whether a structural change is safe. Every finding and every gate comes from deterministic repository facts shared across agents, human reviewers, IDEs, reports, and CI.

CodeClone requires no hosted service or cloud account. Analysis state, controller state, Engineering Memory, and trajectories are stored locally.

Most review tools begin after the patch already exists. CodeClone begins earlier:

task request → declared intent → structural blast radius → explicit boundary → actual patch → deterministic verification

Agent scope expansion can look reasonable in the final diff. A narrow task may quietly spread into shared helpers, tests, configuration, public APIs, or unrelated modules.

By the time that expansion reaches the final diff, it already looks intentional. CodeClone catches it at the declared boundary instead — by comparing what the agent said it would change with what it actually changed.

Run the stable release without installing anything:

Prefer a browsable report? Generate the HTML view and open it:

uvx codeclone@latest . --html --open-html-report

Once you use it regularly, install it as a local tool:

2. Record the current structural baseline

Before asking an agent to change the repository, capture the accepted state once:

codeclone . --update-baseline git add codeclone.baseline.json git commit -m "chore: add CodeClone structural baseline"

The baseline records the structural debt that already exists. Future analysis can then separatenew regressionsfrom findings that were already present, so agents and reviewers can focus on what the current change introduced.

Updating the baseline is an explicit governance action. Do not regenerate it merely to make a failing check pass.

Continue toAgent change controlbelow to install the MCP control surface and wire CodeClone into Claude Code, Cursor, VS Code, Codex, or Claude Desktop.

CodeClone runs one deterministic analysis and renders the same canonical report through every supported surface.

- function, block, and segment clones;
- clone drift and duplicated branch families;
- complexity, coupling, cohesion, dependency cycles, and dead code;
- Module Map— a package/module dependency graph with cycle, hub, overloaded-module, and unwind-candidate views;
- Guided Finding Review— a prioritized review queue with shared finding cards, filters, and progress tracking;
- public API inventory and baseline-aware API break detection;
- external coverage joined with structural hotspots;
- deterministic structural health and review priorities.

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

How CodeClone works·Canonical report contract

The baseline is a versioned, integrity-checked contract that records the accepted structural state of the repository.

It lets CodeClone and connected agents distinguish:

- findings that already existed;
- regressions introduced by the current change;
- deliberate baseline updates approved by the user.

Check future changes against the committed baseline:

- uses: orenlab/codeclone/.github/actions/codeclone@v2 with: fail-on-new: "true" sarif: "true" pr-comment: "true"

CI can reject newly introduced clones, metric regressions, API breaks, and coverage regressions without requiring the existing repository to be clean first.

Baseline contract·CI integration and quality gates

Linters check style and correctness file by file. Clone detectors report duplication and stop there. Hosted review bots ask a model for an opinion about a finished diff.

CodeClone combines CFG-based clone detection, multi-metric baseline governance, and a read-only MCP control surface in one local-first, open-source package — and applies thembeforethe edit happens, not only after. Structural facts are computed deterministically, so the same input always produces the same verdict, in the terminal, in CI, and inside your agent's loop.

uv tool install --prerelease allow "codeclone[mcp]" codeclone-mcp --transport stdio

The server exposes38 MCP toolscovering analysis, change control, blast radius, memory, and diagnostics. Responses are built for agent loops: deterministicnext_toolguidance, token-budget-aware payloads, and replies that keep mandatory control facts inline while linking full evidence for drill-down.

Before gating agents or CI, confirm[tool.codeclone]and local gitignore hygiene:

codeclone setup status codeclone setup plan codeclone setup apply # or: codeclone setup wizard

Every client uses the same MCP interface and the same canonical structural facts.

Analyze.CodeClone builds one canonical structural report for the repository and compares it with the accepted baseline.

- records the agent's intent;
- maps structural blast radius;
- separates editable paths from review context and do-not-touch boundaries;
- exposes the regression budget relative to the accepted baseline;
- returns the authoritativeedit_allowedresult.

Edit.The agent writes the code. CodeClone does not generate or rewrite source files. Where the host supports hooks, integrations can stop edits unlessedit_allowed=true. While editing, the agent stays oriented throughLive Implementation Contextinstead of rediscovering the repository with broad searches.

- resolves the actual changed files;
- checks declared scope against the real patch;
- verifies structural changes;
- validates optional review claims;
- records Patch Trail evidence;
- produces an auditable review receipt.

If the patch crosses the declared boundary or introduces regressions beyond the budget, verification fails — and the receipt records exactly where and why. The result is not an AI opinion about the patch. It is a deterministic comparison between declared intent, repository structure, the accepted baseline, and the actual change.

Read the Structural Change Controller guide

get_implementation_contextserves the agent bounded, task-scoped context directly from the current analysis run:

- structural context and call relationships for the declared edit scope;
- contract-oriented truth maps and test anchors;
- freshness signals and active intent boundaries.

There is no separate vector database drifting behind the code, and no watcher daemon re-indexing the tree. Context comes from the same analysis that produces findings and gates — so what the agent reads is what the verifier will check. Context is read-only: it informs edits but never authorizes them.

- Platform Observability— development-time tracing of CLI, MCP, analysis phases, database activity, and payload pressure, so you can see what CodeClone itself is doing and what it costs.
- Corpus Analytics— offline intent clustering and interpretability over recorded controlled changes, with versioned profiles and inspectable JSON/HTML outputs.

Engineering Memory gives agents durable, repository-specific context without treating model output as project truth.

- architecture and contract notes;
- risks, test anchors, and public surfaces;
- git and change-control provenance;
- prior trajectories and Patch Trail evidence;
- recurring advisory patterns calledExperiences.

Agent-created records remain drafts until a human approves them.

codeclone memory init --root . codeclone memory search "baseline schema" --match all

Retrieval is hybrid — FTS5/BM25 lexical search, optional LanceDB vector search, and Reciprocal Rank Fusion combining the two — with fully reproducible ranking.

Memory can guide an agent. It cannot authorize edits, override blast radius, change a gate, or replace canonical report facts.

Engineering Memory documentation·Trajectories and Experiences

- Structural findings and gates come from deterministic analysis, not LLM judgment.
- edit_allowedis an explicit controller result; status or advisory ownership does not grant permission.
- Read-only analysis commands do not modify source code or project governance state.
- Baseline updates are explicit user-approved governance actions.
- Controller and memory operations write only to their explicit local state stores.
- Memory, trajectory, and implementation-context evidence remain advisory.
- stdiois the recommended transport for local clients.
- Remote HTTP exposure requires explicit--allow-remote.

Bug reports, feature discussions, and pull requests are welcome — start withIssuesorDiscussions, or join theDiscord.

git clone https://github.com/orenlab/codeclone.git cd codeclone uv sync --all-extras uv run codeclone .

- Getting started
-
Structural Change Controller
-
Engineering Memory
-
MCP usage
-
Configuration reference

SeeLICENSES.mdfor the license scope map.

- PyPI:https://pypi.org/project/codeclone/
- Discord:
https://discord.com/invite/U72KmRvpUx
- Issues:
https://github.com/orenlab/codeclone/issues
- Discussions:
https://github.com/orenlab/codeclone/discussions

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

MCP server that bridges LCOV coverage reports to AI agents.

Uses TypeScript AST to determine which tests are affected by code changes

AI-Safe Code Analysis with 113+ MCP tools for guard validation, memory, workflow, and testing.

Prevents regression by providing Blast Radius data to AI based on your git history

A powerful Model Context Protocol (MCP) server that supercharges your Python development workflow with AI-powered code review, intelligent test generation, and comprehensive test execution.

Local MCP that allows your agent to keep track of code analysis coverage

Bring agent evaluations, observability, and synthetic test set generation directly into your IDE for free with Galileo's new MCP server

Browser automation via MCP for Chrome and Firefox

Bring the full power of BrowserStack’s Test Platform to your AI tools, making testing faster and easier for every developer and tester on your team.

Official Chrome DevTools MCP server for controlling and inspecting a live Chrome browser from coding agents such as Gemini, Claude, Cursor, and Copilot.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.