working-with-legacy-code
A guide for safely changing and adding tests to untested legacy code using seams, characterization tests, and dependency-breaking techniques from Michael Feathers' Working Effectively with Legacy Code
What it does
'Safely change and test untested codebases using Feathers'' "Working Effectively with Legacy Code". Use when the user mentions "legacy code", "no tests", "untested codebase", "how do I test this", "seams", "characterization tests", "golden master", "sprout method", "afraid to change this code", "monster method", "dependency breaking", or "inherited a messy codebase". Also trigger when changing code without tests safely, getting a class under test when constructors, statics, or singletons block it, adding features to tangled modules, or planning incremental test coverage for an old codebase. Covers the legacy-code change algorithm, seams, characterization tests, sprout/wrap, and dependency-breaking techniques. For refactoring code that already has tests, see refactoring-patterns. For day-to-day code quality, see clean-code.'
Quality judgment
An exceptionally thorough, well-organized distillation of Feathers' book covering the change algorithm, seams, characterization tests, sprout/wrap, dependency-breaking, and comprehension techniques, with concrete code examples, a scoring rubric, common mistakes, and a diagnostic table. Triggers are specific and well-scoped with sensible cross-references; only minor deductions for occasionally dense prose and reliance on external reference files not shown here.