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
28
AGENTS.md
28
AGENTS.md
|
|
@ -72,15 +72,23 @@ uv run pytest tests/test_parser.py::TestParseTable::test_empty_input
|
||||||
|
|
||||||
### Rules for adding or changing functionality
|
### Rules for adding or changing functionality
|
||||||
|
|
||||||
1. **Always update or add tests** when introducing new behaviour or modifying
|
1. **Use test-driven development (TDD) for new functionality.** The workflow is:
|
||||||
existing behaviour. Tests live in the `tests/` file that corresponds to the
|
1. Write the tests first, based on the expected behaviour.
|
||||||
module being changed (e.g. changes to `parser.py` → `tests/test_parser.py`).
|
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. **Run the full test suite before finishing** and confirm it passes with no
|
2. **Always update or add tests** when modifying existing behaviour. Tests live
|
||||||
failures:
|
in the `tests/` file that corresponds to the module being changed
|
||||||
```sh
|
(e.g. changes to `parser.py` → `tests/test_parser.py`).
|
||||||
uv run pytest --cov
|
|
||||||
```
|
|
||||||
|
|
||||||
3. **Do not reduce coverage.** Every new function or branch should have at
|
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
|
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
|
5. Joplin integration tests in `test_joplin.py` must mock `ClientApi` — do not
|
||||||
require a live Joplin instance.
|
require a live Joplin instance.
|
||||||
|
|
||||||
# Development Guidelines
|
# Behavioral Guidelines
|
||||||
|
|
||||||
# CLAUDE.md
|
|
||||||
|
|
||||||
Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.
|
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