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 4 of 6

Pinning parse_tags before the refactor

builds on: Refactors that quietly change behavior, What makes a test able to fail
The current code splits on commas, strips and lowercases each tag, and skips blanks and repeats, keeping first-seen order. Each expected value below was copied from running it, not taken from a spec. - Pin 1 covers stripping, lowercasing, a blank and a repeat in one input. - Pin 2 uses `"b,A,a"`, where first-seen order differs from sorted order. With `"a,b"` the two orders match, so a switch to sorting could not turn it red. - Pin 3 records an accident: `None.split` raises `AttributeError`. Nobody designed that, but a caller may catch it.
// Python
import pytest
from tags import parse_tags

def test_cleans_and_dedupes():
    assert parse_tags(" a, ,A ") == ["a"]

def test_keeps_first_seen_order():
    assert parse_tags("b,A,a") == ["b", "a"]

def test_none_raises_attribute_error():
    with pytest.raises(AttributeError):
        parse_tags(None)
Terms on this card
refactor
Restructuring code to make it cleaner or simpler while keeping its observable behaviour exactly the same for every caller.
pin
To record a piece of current behaviour as a test's expected value, so that any change to it turns the test red.
caller
Any code that calls the function and may depend on its exact results, errors or ordering.
None
Python's null value, meaning 'no object'.
AttributeError
Python exception raised when an attribute or method doesn't exist on an object, e.g. calling .split on None.
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