xpd enhance untangle
Run xpd enhance untangle to find pieces that change together in separate modules, needless links between modules, and dead weight across a codebase.
| Group | Finding kinds |
|---|---|
| Hidden links | copy, near-copy, look-alike, changes-together |
| Needless links | volatile-import, import-cycle |
| Surplus | parameter-alias, default-argument, unreferenced, constant-parameter, orphaned-module, single-use-module |
| Special cases | one-caller-parameter |
unreferenced reports a Python function or class only when nothing reaches it: no surveyed code, no entry point, no documentation, notebook or Python file elsewhere in the repository that names it, and no string that calls it, such as a doctest.
unreferenced blocks a recorded run and xpd audit --strict-clean, because an oracle that can prove a finding wrong labelled its findings and at least 90% were right. Every other finding of this track is advice: a fix may name one, and no run or audit has to clear one.
Run xpd enhance untangle --questions to read the six structural questions and the facts that inform them, pass --all-modules to start to review every module against them, or run xpd enhance untangle <paths> --map to print a Mermaid module coupling and health map for Python, Go, Rust, JavaScript, and TypeScript trees, including mixed selections (add --format json for structured nodes, edges, and hidden links). The supported fix goals are shorter and design.
For mechanical Python cleanups, preview diffs with xpd enhance untangle --move <from> <to> or xpd enhance untangle --inline-facade <file> and pass --apply to write the validated changes.
A shorter fix requires a lower line count. For a data script refactor, run xpd equiv on the old and new versions and record the result in the fix commit.
xpd enhance untangle [OPTIONS] [PATHS]... xpd enhance untangle <COMMAND>Subcommands
Section titled “Subcommands”| Subcommand | What it does |
|---|---|
xpd enhance untangle start |
Start a run: record the commit it starts from, the paths, line count, checks and optional benchmark of the project |
xpd enhance untangle plan |
Record the plan of a round: the fixes in order, and the findings that are right as they are |
xpd enhance untangle approve |
Record that the user said yes to a fix that changes what callers or users see, or that changes files outside the paths of the run |
xpd enhance untangle gate |
Gate a fix: run the checks, time --bench when set, count lines and compare the findings with the commit before it. Exit 1 when the fix is not kept |
xpd enhance untangle drop |
Record that a fix was given up, after its files were restored |
xpd enhance untangle status |
Print the run and the stage that comes next |
xpd enhance untangle finish |
End the run: compare findings, line count and benchmark timing with the start commit. Exit 1 while a fix is open or a new finding has no reason |
Arguments
Section titled “Arguments”| Argument | What it does |
|---|---|
<PATHS>... |
Files or directories (directories respect .gitignore) |
Options
Section titled “Options”| Option | Default | What it does |
|---|---|---|
--kind <KIND> |
List only the findings of these kinds, separated by commas. Repeatable. Values: copy (The same code is written out in more than one place), changes-together (Two files change in the same commits, and no import joins them), volatile-import (A module imports a module that changes at least twice as often as it does), import-cycle (Modules import one another in a circle), parameter-alias (A function keeps a legacy parameter alias alive through fallback assignment or kwargs.pop), unreferenced (No file mentions a function or class apart from its definition), test-only-helper (A production definition referenced only by test files), constant-parameter (Every call gives a parameter the same value), one-caller-parameter (One call alone passes a parameter that has a default), near-copy, look-alike (Functions, classes or modules that are no copy and still do much the same work), default-argument, orphaned-module (A production module that no other surveyed file imports), single-use-module (A helper module imported by only one non-test file). |
|
--limit <LIMIT> |
20 |
The most findings to list of each kind, strongest first. 0 lists every finding. |
--since <COMMIT> |
Count the findings at this commit too, and print each count beside the count of today. | |
--group-by <GROUP_BY> |
none |
Group findings and checklist items by owning module or shared cause. Values: none (Keep the default flat per-kind listing), module (Group findings and checklist items by owning module path), cause (Group related findings by shared kind and anchor files). |
--packet <N> |
Emit one 1-indexed deterministic context-budgeted review packet for the Nth cluster. | |
--budget-lines <LINES> |
300 |
Maximum source lines included across excerpts inside a --packet view. |
--all-modules |
Include checklist review items for every surveyed module, not only modules with findings. | |
--format <FORMAT> |
Output format. Default: text on a terminal, json otherwise. Values: text, json. |
|
--questions |
||
--map |
Print a Mermaid (or JSON with --format json) module coupling and health map for Python, Go, Rust, JavaScript, or TypeScript. | |
--move <FROM> <TO> |
Mechanically move a Python module (FROM TO) and rewrite project imports (dry-run unless --apply) Repeatable. Conflicts with --map, --inline-facade, --questions. |
|
--inline-facade <FILE> |
Inline a pure re-export Python facade module into its callers and remove it (dry-run unless --apply) Conflicts with --map, --move, --questions. |
|
--apply |
Write mechanical refactor changes to disk instead of printing a preview diff. |
Recorded run
Section titled “Recorded run”- Start: record the current commit, paths, and project checks from a clean tracked tree with
xpd enhance untangle start . --check "your-project-check". - List: read the stable ID of each finding with
xpd enhance untangle . --format json. - Plan: record the ordered fixes, each naming the findings it removes, using
xpd enhance untangle plan plan.json. - Approve: record approval for an interface change with
xpd enhance untangle approve fix-id. - Gate: commit one fix and run
xpd enhance untangle gate fix-id. - Drop: return to the run's current commit and record a reason with
xpd enhance untangle drop fix-id --reason "reason". - Status: show the current run, its recorded answers, and the next stage with
xpd enhance untangle status. - Finish: compare against the starting commit with
xpd enhance untangle finish. An open fix causes exit 1. Advice that is left needs no reason.
Example
Section titled “Example”$ xpd enhance untangle --questions --format json | jq -c '{facts: (.facts | length), questions: (.questions | length)}'{"facts":2,"questions":6}Exit status
Section titled “Exit status”A successful list or recorded stage exits 0. A rejected gate or a finish with an open fix exits 1. Invalid input exits 2.