# Affected Tests

> Affected Tests

- Skill: `jcdavis131/affected-tests` (Agent Skill)
- Install (CLI): `npx skillmds@latest add jcdavis131/affected-tests`
- Raw SKILL.md: https://api.skillmd.com/api/skills/jcdavis131/affected-tests/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: jcdavis131 (https://skillmd.com/u/jcdavis131)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/jcdavis131/affected-tests

---


# 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

```bash
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

1. What files did you edit? `git status --short` or `git diff --name-only`.
2. Which packages own those files? Map file path → `packages/<pkg>` or `services/<svc>`.
3. 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.
4. 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.

```text
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.

