---
name: Run Tests on Save
description: Run relevant tests when service or frontend files are saved
version: "2.0"
trigger:
  type: onSave
  filePattern: "{services/**/*.py,frontend/src/**/*.{ts,tsx}}"
---

When a file is saved:

1. If it's a Python file under `services/`:
   - Identify the service module (e.g. `services/ingestion/worker.py` → `ingestion`)
   - Look for corresponding tests in `tests/` matching the service name
   - Run `python -m pytest tests/test_{service_name}*.py -x --tb=short -q` if test files exist
   - If no specific test file exists, run lint check only
   - Report results concisely

2. If it's a TypeScript/React file under `frontend/src/`:
   - Run `npx vitest --run` from the `frontend/` directory
   - Report results concisely — only show failures or a one-line success
