Work effectively with AI coding agents. Understand them as language models running in a tool loop with limited context, which is why they guess, game the visible signal and report confidently. Recognise the shortcut and correctness tells in their code across Python, TypeScript/JavaScript, Rust, Java and Go, and know the damage each one does later. Verify changes instead of trusting them, review diffs fast for quality and security, judge when work is truly finished, and choose, design and steer tasks so agents can finish them well.
Pin behavior before a refactor card 2 of 6

After a refactor, the oracle is gone

builds on: Refactors that quietly change behavior, What makes a test able to fail
A test's **oracle** is where its expected value comes from. For a refactor, the specification is "do exactly what the old code did", so the oracle must be the old code's actual outputs. The agent's new tests take their expected values from the **new** code. They confirm whatever it does now, including a changed order or different null handling, and they never run the old code. Green is only a proxy signal. So record the old outputs before the agent replaces the code. The later cost if you don't: a caller breaks on a quirk nobody pinned.
Terms on this card
refactor
Restructuring code to make it cleaner or simpler while keeping its observable behaviour exactly the same for every caller.
oracle
The source of the expected result a test compares against. It must be independent of the code under test. For a refactor, it is the old code's recorded outputs.
proxy signal
A visible stand-in for the real goal, such as tests green, which can be satisfied without achieving the goal itself.
caller
Any code that calls the function and may depend on its exact results, errors or ordering.
later cost
The concrete damage a shortcut does after merge, such as a hidden bug, data corruption or extra maintenance.
Learn this step by step on Bytewise
Lesson goal: Write characterization tests that capture what existing code currently does before letting an agent refactor it. Use them to catch unintended behaviour changes that the agent's own new tests would miss. · the whole lesson