Skip to content

docs(test-driven-development): add guidance for modifying behavior with existing tests#2023

Open
wrcapitalcorp wants to merge 1 commit into
obra:mainfrom
wrcapitalcorp:tdd-modifying-existing-behavior
Open

docs(test-driven-development): add guidance for modifying behavior with existing tests#2023
wrcapitalcorp wants to merge 1 commit into
obra:mainfrom
wrcapitalcorp:tdd-modifying-existing-behavior

Conversation

@wrcapitalcorp

@wrcapitalcorp wrcapitalcorp commented Jul 23, 2026

Copy link
Copy Markdown

Summary

Adds a "Modifying Existing Behavior" section to the test-driven-development skill and clarifies the existing "Other tests fail?" note under Verify GREEN. Documentation only, one file.

Motivation

The red-green-refactor cycle in this skill is written for new behavior, beginning from an empty test file. It offers little guidance for changing behavior that is already covered by tests, which is a common and time-consuming case in practice. The only sentence that addresses it is:

Other tests fail? Fix now.

Taken literally, "fix now" can be read as license to make a failing test pass without first determining whether the code, rather than the test, is at fault. That inverts the purpose of the test: a test that fails on an unintended change is doing its job, and editing it to pass removes that signal.

Change

Adds a focused section covering the modification case:

  1. Inventory the existing tests before changing code, so a contract change is not discovered later as an unexplained CI failure.
  2. Update the existing test to the new contract first, in the same commit: watch it fail against the current code, then change the code to make it pass.
  3. For any other failing test, decide before editing whether it represents a genuine regression (fix the code) or an intended behavior change (update the test).

It also notes a brittleness signal: a refactor that changes no observable behavior yet breaks many tests indicates tests coupled to implementation rather than behavior.

The "Other tests fail?" line under Verify GREEN is updated to state this decision inline and link to the new section.

Notes

The change is intentionally scoped to a single section so it continues the existing red-green narrative rather than introducing a separate skill. If the maintainers would prefer a standalone companion skill to match the library's composition style, I would be glad to restructure it accordingly.

…th existing tests

The red-green-refactor cycle documents writing new behavior from an empty
test file and gives little guidance for changing behavior that is already
covered by tests. The only note on that case, "Other tests fail? Fix now,"
can be read as making a failing test pass without first determining whether
the code, rather than the test, is at fault.

This adds a "Modifying Existing Behavior" section covering three points:
inventory the existing tests before changing code; update the existing test
to the new contract first, in the same commit; and, for each additional
failing test, decide whether it is a genuine regression (fix the code) or an
intended behavior change (update the test). The "Other tests fail?" line
under Verify GREEN is updated to state this decision inline and link to the
new section.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@wrcapitalcorp
wrcapitalcorp force-pushed the tdd-modifying-existing-behavior branch from 2e16642 to 3896a3e Compare July 23, 2026 12:02
@wrcapitalcorp wrcapitalcorp changed the title tdd: add "Modifying Existing Behavior" section (test-vs-code fork) docs(test-driven-development): add guidance for modifying behavior with existing tests Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant