Untangle codebase structure
Run xpd enhance untangle to find code that changes together in separate files, needless module links, and dead weight using source files and Git history without running project code.
Map module coupling and health
Section titled “Map module coupling and health”Print a Mermaid coupling map for Python packages, Go packages, Rust crates, and JavaScript or TypeScript modules, including mixed selections, or pass --format json to inspect nodes, directed edges, import cycles, orphans, and hidden co-change links.
xpd enhance untangle src/ --mapxpd enhance untangle src/ --map --format jsonIn an editor running xpd lsp, workspace-level structural findings such as untangle/import-cycle, untangle/orphaned-module, untangle/facade-module, untangle/single-use-module, untangle/mixed-responsibilities, and untangle/shared-state appear as HINT diagnostics.
Preview and apply mechanical Python refactors
Section titled “Preview and apply mechanical Python refactors”Use --move to relocate a Python module and rewrite every importing caller, or --inline-facade to collapse a re-export shim directly onto its defining modules. Both flags print a unified diff in dry-run mode first and validate every edited file with libcst before writing when --apply is passed.
xpd enhance untangle --move pkg/old_module.py pkg/new_module.pyxpd enhance untangle --move pkg/old_module.py pkg/new_module.py --apply
xpd enhance untangle --inline-facade pkg/compat_shim.pyxpd enhance untangle --inline-facade pkg/compat_shim.py --applyRun a recorded untangle ledger
Section titled “Run a recorded untangle ledger”Record structural cleanups in a Duroxide ledger so every commit must pass your checks and lower or settle findings.
| Stage | Command | Purpose |
|---|---|---|
| Start | xpd enhance untangle start src/ --check "<cmd>" |
Record the baseline commit, paths, and project checks |
| Survey | xpd enhance untangle src/ --format json |
Read stable finding IDs and six structural checklist items per module |
| Plan | xpd enhance untangle plan plan.json |
Register ordered fixes (shorter or design), accepted findings, and checklist verdicts |
| Gate | xpd enhance untangle gate <fix-id> |
Verify checks pass, findings do not regress, and goal constraints hold |
| Finish | xpd enhance untangle finish |
Confirm every open fix, new finding, and checklist item is settled |
See xpd enhance untangle for every finding kind and stage command.