code-humanizer
Code Humanizer
Remove signs of AI-generated code from a repository, or prevent the same patterns in the current change with Guard mode. The prose humanizer removes AI writing patterns; this handles AI coding patterns — the structural debt agents leave behind when they optimize for "tests pass" instead of "codebase stays healthy."
Core principle: AI code slop is not ugly code — it is code that works but degrades the repository: it reimplements what already exists, adds abstraction nobody asked for, swallows errors it should surface, and hedges against situations that cannot occur. Unlike prose, code has an oracle: the test suite decides what "meaning-preserving" means. Use it constantly.
Iron rules
Rules 1–4 govern cleanup of pre-existing code in Modes A/B. In Guard mode they apply to any cleanup performed after implementation, not to the requested feature work itself. Rule 5 applies in every mode.
- Behavior preservation is absolute. "Cleanup" that changes behavior is a bug with good intentions. This includes error types and error timing — swapping an accidental
AttributeErrorfor a "nicer"ValueErrorchanges behavior for every caller that catches it. If you find a latent bug or an ugly-but-load-bearing behavior: flag it in the report; never fix it silently as part of cleanup. - No tests → no cleanup edits. Run the test suite first. If it doesn't exist, doesn't pass, or doesn't cover the pre-existing code you'd clean, you may only report that debt (Mode A). Offer to write characterization tests first. This does not forbid implementing a requested change in a project whose tests are incomplete; report the verification gap.
- Report before rewriting pre-existing code. Default to Mode A (scan → report). Only enter Mode B (fix) when the maintainer approves, or was explicit that they want fixes. Guard mode may directly avoid or remove slop introduced by the current change.
- One pattern-class per cleanup commit. Each commit that removes pre-existing slop handles one kind and passes the full suite. A red test reverts the commit — do not "fix forward" into unrelated code. Ordinary feature commits under Guard mode need not be split by pattern when the prevention is inseparable from the implementation.
- Search before you judge duplication. Build a mental index of the repo's existing helpers before scanning or implementing (grep
utils,helpers,common, validators, existing base classes). You cannot recognize a reimplementation if you don't know what exists.
Pattern catalog
Severity per finding: 0 absent · 1 present but justified (→ exempt, do not touch) · 2 minor debt · 3 clear debt, raises future maintenance cost · 4 severe, breaks semantics or architecture boundaries.