name: single-file-test-first-fix description: 'Make safe changes in a single-file Python CLI by writing or updating tests first. Use for bug fixes, behavior changes, and regressions in mkbrr-wizard.py with pytest monkeypatch patterns.' argument-hint: 'What bug or behavior change should be covered first?'
Single-File Test-First Fix
Docs First
- When behavior depends on mkbrr flags or defaults, verify with:
docs/cli-reference-create.mddocs/cli-reference-check-inspect.mddocs/presets.mddocs/batch-mode.md
When To Use
- You need a safe fix in
mkbrr-wizard.pywithout regressions. - A behavior is unclear and should be locked with a test before editing logic.
- You are touching prompts, command builders, config loading, or runtime detection.
Procedure
- Reproduce the issue in a focused test file under
tests/. - Use the fixture-based import pattern from
tests/conftest.py: always reference functions and classes viamkbrr_wizard.<name>. - Prefer
monkeypatch.setattr(mkbrr_wizard, ...)when mocking module-level behavior. - Run the smallest test slice first (
pytest tests/<file>.py -k <name>), then implement minimal code changes inmkbrr-wizard.py. - Expand coverage for nearby edge cases only where risk is high.
- Run full
pytestand thenruff check ..
Completion Checks
- At least one test fails before the fix and passes after.
- No direct imports from
mkbrr-wizard.pyin tests. - Existing behavior outside the target area remains green.
References
tests/conftest.pytests/test_commands_builder.pytests/test_main_flow.pypyproject.toml