| name | arf |
| description | Three-phase test-driven bug fix workflow. First write a passing test proving the bug exists, then flip assertions to define correct behavior (fails), then fix the production code. Use when fixing bugs, correcting wrong behavior, or closing gaps in existing logic. |
Assert-Refute-Fix
A three-phase workflow for test-driven bug fixes. Each phase requires user confirmation before proceeding to the next.
Phase 1: ASSERT — Prove the bug exists
- Read the relevant source code and existing tests to understand the current behavior and why it's wrong.
- Write a test that asserts the current (buggy) behavior. This test passes today, demonstrating the bug is real and reproducible.
- Name the test to describe the buggy behavior (e.g., "does not restore record when...").
- Run the test to confirm it passes:
/opt/dev/bin/dev test <test_file> --name="/<test_name_pattern>/"
- Present the passing test to the user. Wait for confirmation before proceeding.
Phase 2: REFUTE — Assert the correct behavior
- Update the test name to describe what the behavior should be (e.g., "restores record when...").
- Flip the assertions to assert the correct/desired behavior.
- Run the test to confirm it now fails:
/opt/dev/bin/dev test <test_file> --name="/<test_name_pattern>/"
- Verify the failure is in the assertions about correct behavior, not a setup error or exception.
- Present the updated test and failure output to the user. Wait for confirmation before proceeding.
Phase 3: FIX — Make the test pass
- Make the smallest change to production code that causes the failing test to pass.
- Run the full test file to verify the fix doesn't break existing tests:
/opt/dev/bin/dev test <test_file>
- If existing tests break, adjust the fix (not the tests) until everything is green.
- Present the production code change and green test output to the user.
Rules
- Do not touch production code during ASSERT or REFUTE phases.
- Do not change tests during the FIX phase.
- Follow project testing conventions (Minitest, Mocha, assertion style, naming, parallel safety).
- Use
ensure blocks to restore fixture state when modifying records in-place.