CODEX RESET RADAR Codex Reset Radar
中文
PRO TIPS · Field Playbooks

Testing Code That Never Had Tests: A Four-Phase Codex SOP

Updated: 2026-10-18~3 min readsources × 2

TL;DREvery trap in backfilling tests is an ordering trap: make Codex read and describe current behavior first, make it test what the code does rather than what it should do, add tests one batch at a time, and gate each batch on green. Plus the key rule for failures: fix the code or fix the test?

Sources SOURCES

Distilled from public community discussions. This page only breaks them down and verifies — it never reposts the original; opinions belong to their authors.

Facts FACTS

Check these claims against the listed sources. For allowance mechanics, first-party account displays outrank community summaries.

Concepts CONCEPTS

Not everything said in a community thread is a fact — each concept carries its nature label. Read the label first.

Test what isCommunity opinion

The classic wipeout in legacy testing: you ask Codex to write tests for 'the behavior the code should have' and end up testing its own imagination. The correct framing is the reverse — have it describe how the code actually behaves today, then freeze that current behavior into tests.

Fix the code or fix the testCommunity opinion

The rule for failures: behavior matches business expectations, so fix the test (the assertion was wrong); behavior is a clear bug, so fix the code and log it. The rule itself is simple. The discipline is not.

Step-by-step SOP STEP BY STEP

GOALScenario: a test-less but stably running old module is about to get surgery. Goal: give it its first batch of safety-net tests within half a day.
YOU NEEDThe project runs; you know the module's entry functions.
  1. 01
    Make it read first

    Ask: 'Read this module and list every exported function's inputs, outputs, and side effects — write no code.' Check that understanding by hand for obvious errors.

  2. 02
    Confirm test infrastructure

    Ask: 'What test framework does this project use? If none exists, propose the minimal setup.' Get one empty test passing before anything else.

  3. 03
    Batch one: core paths

    Have it write 'test what is' cases — known input, current actual output — for only the 2–3 most-used functions.

  4. 04
    Green one batch, then the next

    Once everything passes, request one batch of edge cases. One batch at a time; handle failures immediately; never stockpile.

  5. 05
    Dispose of failures by rule

    Apply the fix-code-or-fix-test rule to every failure, and record the bugs you squashed in the commit message.

  6. 06
    Persist into AGENTS.md

    Write the test command and the 'test what is' policy into the repo's AGENTS.md, so every future agent follows them automatically.

RESULTThe legacy module gets its first layer of safety net, and your confidence for the next refactor comes from tests instead of memory.

Want today's verdict? Back to the live radar.

More Field Playbooks playbooks SAME CATEGORY

🎯 Any confirmed public reset today?
Open the signal radar for sourced announcements; personal allowance and exact reset time remain in Usage.
Open the signal radar →