Coding & developmentLegacy testingcode
Protect a legacy function before refactoring
Builds tests around observed behaviour, including awkward quirks.

Ready to use
Prompt
Given [FUNCTION CODE], its callers and any known examples, create a characterisation-test pack before recommending changes. Identify inputs, outputs, side effects, hidden environment dependencies and known bugs that callers may rely on. Write test cases for ordinary, boundary, malformed and repeated calls; label expected results as observed, specified or unknown. Provide a minimal test harness in [LANGUAGE OR FRAMEWORK] and list the one behaviour that should remain deliberately unfixed until a product decision. Do not assert tests have run unless execution evidence is supplied. Keep production fixtures and credentials out of the test data.