Skip to content
Back to skills

Scoped Checks

ASecurity

Run lint/typecheck/tests only on what the change reaches - the changed-file set, its dependents through the module graph, and when to escalate to the full suite. Use in /flow:implement step 5, /flow:verify step 2, and whenever running the whole suite costs minutes the diff does not justify.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added December 1, 2026
developmentbashnextjsgitapidatabase

Works with

  • api

Security analysis

A100/100

Scanned December 1, 2026

npx -y skills add eusilvio/claude-workflow --skill scoped-checks --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Scoped Checks?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Scoped Checks
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/eusilvio-scoped-checks/badge)](https://www.skillsdirectory.com/skills/eusilvio-scoped-checks)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: scoped-checks
description: "Run lint/typecheck/tests only on what the change reaches - the changed-file set, its dependents through the module graph, and when to escalate to the full suite. Use in /flow:implement step 5, /flow:verify step 2, and whenever running the whole suite costs minutes the diff does not justify."
user-invocable: false
---

# Scoped checks

Running the whole suite on every QA round is the biggest fixed cost of the
pipeline. A 3-file diff does not need 1500 tests to prove it broke nothing -
it needs the tests that **can see** those 3 files.

This skill defines that set and says when it is not enough. Command names
come from the repo (`repo-conventions`): the snippets below show the shape,
with `<pm>` standing for the repo's package manager (`npm`, `pnpm`, `yarn`,
`bun`), detected from its lockfile.

## Step 1 - the changed set

Always derive it from git, never from memory of what you edited:

```bash
git diff --name-only origin/<base>...HEAD        # PR already open / feature branch
git diff --name-only HEAD                        # uncommitted work
git status --porcelain | awk '{print $2}'        # includes new untracked files
```

Union the three. A new test file belongs to the set: it is a target, not just
a trigger. Group by package/workspace - each runner only understands paths
inside its own directory.

## Step 2 - from changed file to the tests that reach it

**Vitest: use `related`.** It resolves the import graph and runs every test
that imports the file, directly or transitively.

```bash
# paths relative to the package root
cd apps/api && npx vitest related --run src/modules/quotes/service.ts src/shared/cache.ts
```

Typical gain: `related` on one service = a handful of files / tens of tests /
seconds, against tens of seconds or minutes for the package suite. If
`related` matches no test it exits green with 0 files - that **is not**
proof of anything, it means the file has no coverage. Report it as
`no coverage`, not as green.

**Jest:** `npx jest --findRelatedTests <files>` is the equivalent.

**Biome / ESLint: pass the files.** Both accept paths.

```bash
npx biome check --diagnostic-level=error src/a.ts src/b.ts
npx eslint src/a.ts src/b.ts
```

**tsc: there is no per-file scope.** `tsc --noEmit` checks the whole project
by design. Scope here is per **package**: typecheck only the packages the
diff touches, plus the packages that depend on them.

```bash
npm run typecheck -w @org/api                       # npm workspaces, one package
pnpm --filter @org/api typecheck                    # pnpm, one package
pnpm turbo run typecheck --filter='...[origin/<base>]'   # turbo: affected + dependents
```

With turbo, `...[origin/<base>]` is the package-level `related`: it takes the
affected packages **and** whoever depends on them. Without turbo, list the
dependents by hand (grep the package name in the other `package.json`s).

**pytest: there is no ready graph.** Without `pytest-testmon`, build the set
by import:

```bash
cd services/<svc>
# changed file: src/<pkg>/analyzers/churn.py -> module <pkg>.analyzers.churn
grep -rl "<pkg>.analyzers.churn\|from .churn\|import churn" tests/ | sort -u
.venv/bin/pytest $(grep -rl "<pkg>.analyzers.churn" tests/ | tr '\n' ' ') -q
```

Always include the homonymous `tests/test_<name>.py` even if grep misses it.
If grep comes back empty, fall back to `-k "<module-name>"` before giving up.

## Step 3 - when to escalate to the full suite

Scope is an optimization, not a rule. Escalate to the **full package suite**
(or the whole repo) when any of these is true:

- The diff touches config, lockfile, tsconfig, test config, `package.json`,
  ORM schema, a migration, or an example `.env`. Those change everyone's
  world and the import graph does not see it.
- The diff touches a shared package (`packages/*`) - typecheck and test its
  dependents too.
- The change uses dynamic loading, string-based injection, registration by
  file name, code generation, or a shared fixture/snapshot. The static graph
  reaches none of that.
- `related` returned 0 test files.
- It is the **last round before opening the PR** and the diff is above ~15
  files. Scoping stopped paying here.

## What the scope does not prove - say it in the report

A green scoped run proves: no test that sees the diff broke. It does not
prove absence of global regression. Report literally:

```
Tests (scoped to the diff): 3 files, 57 tests, green.
Scope: vitest related on quotes/service.ts, cache.ts.
Not covered: full API suite (1482 tests) did not run this round.
```

Never write "all tests passed" when only the subset ran. That sentence is the
difference between a useful report and a false green.

## Shared database - take the lock

Under `/flow:run` several issues run checks at the same time. When the repo's
tests, migrations or seeds use one shared database (a fixed test DB whose
global setup resets the schema, for example), two runs at once wipe each
other's data and fail at random. Wrap those commands:

```bash
FLOW_ISSUE=<N> ${CLAUDE_PLUGIN_ROOT}/scripts/flowctl.py locked testdb -- pnpm --filter @org/api test -- related ...
```

It waits while another issue holds `testdb` (printing who), runs the command
and returns its exit code. Lint and typecheck do not touch the database:
no lock.

## Keep green output out of context

A green run is thousands of tokens saying "nothing happened". Redirect, read
the exit code, and only look at the output when it is red:

```bash
LOG=$(mktemp -p "${FLOW_TMP:-/tmp}"); <check cmd> >"$LOG" 2>&1; rc=$?
[ $rc -eq 0 ] && tail -3 "$LOG" || tail -60 "$LOG"
```

When the red tail is not enough and the log runs past ~200 lines, hand the
log path to the `flow:log-reader` subagent (haiku) and work from its
one-line-per-failure summary instead of reading the whole file.

## Execution order

Cheap -> expensive, stop at the first red:

1. Lint/format on the changed files (milliseconds)
2. `related` tests / pytest of the set (seconds)
3. Typecheck of the affected packages (tens of seconds)
4. Build - only when the diff touches a web app whose build catches what
   `tsc --noEmit` does not (Next.js, Vite with type-aware plugins), or when
   everything above passed and the PR is about to open

Rule 0 for any repo with pre-existing debt: cross the failing file against
the diff before calling it a regression. A red check in a file the diff does
not touch, that is also red on the base, is debt - report it, do not fix it,
do not let it block. The repo's own checks skill (in `.claude/skills/`), when
it has one, overrides the commands above.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.