Affected Tests
Running the whole suite on every change is slow and floods context with green. Run only the affected package test dirs, quietly, tailed.
The shape
uv run --no-sync python -m pytest packages/<pkg-a>/tests packages/<pkg-b>/tests services/<svc>/tests -q 2>&1 | tail -n 6
Why each piece earns its place:
--no-sync — skip dependency resolution; tests run against the current tree.
- Named package test dirs only — never the repo root. If you touched
packages/data-ingest, run packages/data-ingest/tests, not packages/.
-q — quiet. A passing run should produce a few lines, not a wall of dots.
2>&1 | tail -n 6 (POSIX) or 2>&1 | Select-Object -Last 6 (PowerShell) — even a failing run gives you the summary + the last failures, not 500 lines of traceback. The tail is the part that actually decides pass/fail.
How to pick the affected set
- What files did you edit?
git status --short or git diff --name-only.
- Which packages own those files? Map file path →
packages/<pkg> or services/<svc>.
- Add the test dir for each. If a change crosses a package boundary (e.g. editing a shared client used by two services), include both services' tests.
- If you edited a test fixture or conftest shared across packages, run the broader set — the cheap rule fails here.
When to run the full suite instead
- Pre-merge / pre-deploy gate.
- A change to shared infra (conftest, CI config, lockfile, base image).
- You can't map the blast radius — run wide.
Parallel independent commands (folded in)
If you have 2+ commands with no data dependency between them (independent test packages, independent builds, independent linters), dispatch them in one batch, not serially. Free wall-clock. Only serialize when command B needs command A's output.
Good: [run pkg-a tests] [run pkg-b tests] [lint] # one batch
Bad: [run pkg-a tests] → [run pkg-b tests] → [lint] # serialized for no reason
Anti-patterns
pytest with no path args from repo root — runs everything, slow, noisy.
- No
-q — context fills with dots.
- No tail — a single failing test dumps the full traceback into context.
- Serial-running independent commands "to be safe" — safety isn't increased, only latency.
1---2name: affected-tests3description: Affected Tests4---56# Affected Tests78Running the whole suite on every change is slow and floods context with green. Run only the affected package test dirs, quietly, tailed.910## The shape1112```bash13uv run --no-sync python -m pytest packages/<pkg-a>/tests packages/<pkg-b>/tests services/<svc>/tests -q 2>&1 | tail -n 614```1516Why each piece earns its place:17- `--no-sync` — skip dependency resolution; tests run against the current tree.18- Named package test dirs only — never the repo root. If you touched `packages/data-ingest`, run `packages/data-ingest/tests`, not `packages/`.19- `-q` — quiet. A passing run should produce a few lines, not a wall of dots.20- `2>&1 | tail -n 6` (POSIX) or `2>&1 | Select-Object -Last 6` (PowerShell) — even a failing run gives you the summary + the last failures, not 500 lines of traceback. The tail is the part that actually decides pass/fail.2122## How to pick the affected set23241. What files did you edit? `git status --short` or `git diff --name-only`.252. Which packages own those files? Map file path → `packages/<pkg>` or `services/<svc>`.263. Add the test dir for each. If a change crosses a package boundary (e.g. editing a shared client used by two services), include both services' tests.274. If you edited a test fixture or conftest shared across packages, run the broader set — the cheap rule fails here.2829## When to run the full suite instead3031- Pre-merge / pre-deploy gate.32- A change to shared infra (conftest, CI config, lockfile, base image).33- You can't map the blast radius — run wide.3435## Parallel independent commands (folded in)3637If you have 2+ commands with **no data dependency** between them (independent test packages, independent builds, independent linters), dispatch them in one batch, not serially. Free wall-clock. Only serialize when command B needs command A's output.3839```text40Good: [run pkg-a tests] [run pkg-b tests] [lint] # one batch41Bad: [run pkg-a tests] → [run pkg-b tests] → [lint] # serialized for no reason42```4344## Anti-patterns4546- `pytest` with no path args from repo root — runs everything, slow, noisy.47- No `-q` — context fills with dots.48- No tail — a single failing test dumps the full traceback into context.49- Serial-running independent commands "to be safe" — safety isn't increased, only latency.