ワンクリックで
scientific-tdd
Pragmatic test-driven development for scientific code with numerical validation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Pragmatic test-driven development for scientific code with numerical validation
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
| name | scientific-tdd |
| description | Pragmatic test-driven development for scientific code with numerical validation |
| tags | ["testing","tdd","scientific","numerical"] |
| version | 1 |
Pragmatic test-driven development for scientific code: write tests first for new features and complex changes, verify with tests for simple bug fixes.
Core principle: Tests before implementation for new behavior, tests verify implementation for known bugs.
Announce at start: "I'm using the scientific-tdd skill to implement this feature."
MUST use for:
Can skip test-first for:
Copy to TodoWrite:
Scientific TDD Progress:
- [ ] Understand existing behavior (read code and tests)
- [ ] Write test capturing desired new behavior
- [ ] Run test to confirm RED (fails as expected)
- [ ] Implement minimal code to pass test
- [ ] Run test to confirm GREEN (passes)
- [ ] Run full test suite (check for regressions)
- [ ] Run numerical validation if mathematical code changed
- [ ] Run code-reviewer agent (and/or ux-reviewer when appropriate)
- [ ] Refactor if needed (keep tests green)
- [ ] Commit with descriptive message
Before writing new tests, understand current state:
Commands:
# Find relevant tests
pytest --collect-only -q | grep <relevant_term>
# Run specific test file
/Users/edeno/miniconda3/envs/non_local_detector/bin/pytest src/non_local_detector/tests/<test_file>.py -v
Write test that captures desired behavior:
Test Structure:
def test_descriptive_name_of_behavior():
"""Test that [specific behavior] works correctly.
This test verifies that [explain what you're testing] when [condition].
"""
# Arrange: Set up test data
input_data = create_test_input()
# Act: Call the function/method
result = function_under_test(input_data)
# Assert: Verify behavior
assert result.shape == expected_shape
assert np.allclose(result.sum(), 1.0, atol=1e-10) # Probabilities sum to 1
For mathematical code, verify:
CRITICAL: Test MUST fail before implementing:
/Users/edeno/miniconda3/envs/non_local_detector/bin/pytest src/non_local_detector/tests/<test_file>.py::test_name -v
Expected output: Test fails with clear error (function not defined, wrong output, etc.)
If test passes: The test isn't testing new behavior - reconsider what you're testing.
Write simplest code that makes test pass:
For scientific code:
/Users/edeno/miniconda3/envs/non_local_detector/bin/pytest src/non_local_detector/tests/<test_file>.py::test_name -v
Expected output: Test passes
If test fails: Debug until it passes, then verify you're testing the right thing.
Check for regressions:
/Users/edeno/miniconda3/envs/non_local_detector/bin/pytest -v
Expected: All tests pass (same count as before)
If new failures: Your change broke something - fix before proceeding.
If you modified mathematical/algorithmic code:
Use numerical-validation skill:
@numerical-validation
This verifies:
If code can be improved while keeping tests green:
After each refactor:
/Users/edeno/miniconda3/envs/non_local_detector/bin/pytest -v
git add <test_file> <implementation_file>
git commit -m "feat: add <feature description>
- Add test for <specific behavior>
- Implement <what you implemented>
- All tests passing (<N> tests)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>"
Task: Add new random walk transition with custom variance
1. Read: src/non_local_detector/continuous_state_transitions.py
2. Read: src/non_local_detector/tests/transitions/test_continuous_transitions.py
3. Write test: test_random_walk_custom_variance()
4. Run test: FAIL - "NotImplementedError: custom variance not supported"
5. Implement: Add variance parameter to RandomWalk class
6. Run test: PASS
7. Run full suite: 427 tests passed
8. Run numerical validation: All invariants hold
9. Commit: "feat: add custom variance support to RandomWalk"
Don't:
Do: