python-refactor-audit
Auditing and restructuring a Python module that grew
A procedure for the pass nothing else does: a module built incrementally, never reviewed as a whole, where the problem is not any single line but a shape repeated across the file. Every diff-scoped reviewer — a code-review command, a simplifier agent, a PR bot — is scoped to recent changes by design, and whole-module state threading is precisely what no diff contains.
This skill is about how the pass is run, which matters more than the target shape. What the
resulting code should look like is python-conventions; what a test should cover is
python-testing-conventions. The loop, the oracle rules and the stopping rule below are
language-neutral; the examples are Python.
The worked example every rule here comes from is in references/pilot.md — a
3,476-line single-file script restructured in nine commits on 2026-09-01, with its before/after
counts, the two counts that did not reproduce, and the things that went wrong.
references/prior-art.md is what was surveyed and what was deliberately
not taken.