docs: require TDD workflow in AGENTS.md
New functionality must follow the red-green-refactor cycle: 1. Write failing tests first 2. Confirm they fail before implementing 3. Implement until tests pass 4. Run full suite to check for regressions
This commit is contained in:
parent
17e6a35b37
commit
f99e114770
1 changed files with 17 additions and 11 deletions
24
AGENTS.md
24
AGENTS.md
|
|
@ -72,15 +72,23 @@ uv run pytest tests/test_parser.py::TestParseTable::test_empty_input
|
|||
|
||||
### Rules for adding or changing functionality
|
||||
|
||||
1. **Always update or add tests** when introducing new behaviour or modifying
|
||||
existing behaviour. Tests live in the `tests/` file that corresponds to the
|
||||
module being changed (e.g. changes to `parser.py` → `tests/test_parser.py`).
|
||||
|
||||
2. **Run the full test suite before finishing** and confirm it passes with no
|
||||
failures:
|
||||
1. **Use test-driven development (TDD) for new functionality.** The workflow is:
|
||||
1. Write the tests first, based on the expected behaviour.
|
||||
2. Confirm the new tests *fail* before writing any implementation:
|
||||
```sh
|
||||
uv run pytest tests/test_<module>.py
|
||||
```
|
||||
3. Implement the functionality until all tests pass.
|
||||
4. Run the full suite to confirm nothing regressed:
|
||||
```sh
|
||||
uv run pytest --cov
|
||||
```
|
||||
Skipping the "confirm it fails" step defeats the purpose of TDD — a test
|
||||
that never fails gives no confidence.
|
||||
|
||||
2. **Always update or add tests** when modifying existing behaviour. Tests live
|
||||
in the `tests/` file that corresponds to the module being changed
|
||||
(e.g. changes to `parser.py` → `tests/test_parser.py`).
|
||||
|
||||
3. **Do not reduce coverage.** Every new function or branch should have at
|
||||
least one test covering the happy path. Edge cases and error paths should be
|
||||
|
|
@ -92,9 +100,7 @@ uv run pytest tests/test_parser.py::TestParseTable::test_empty_input
|
|||
5. Joplin integration tests in `test_joplin.py` must mock `ClientApi` — do not
|
||||
require a live Joplin instance.
|
||||
|
||||
# Development Guidelines
|
||||
|
||||
# CLAUDE.md
|
||||
# Behavioral Guidelines
|
||||
|
||||
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue