Know Your Aggregate Command's Scope
Type: Open-source — client-agnostic methodology, no project-specific detail.
Created by akbarsha — https://github.com/iamakbarsha1
Distilled from cases where a wrapper script exited 0 while checking only part
of what was assumed, and where a test filter silently ran the whole cached
suite.
Licence: Released under CC BY 4.0 — share and adapt for any purpose with
credit. Full text: LICENSE at the repository root.
Feedback & Support: If a rule here proves wrong or needs sharpening,
open an issue on the repository or contact the author at the profile link
above. If the problem is the agent not following a rule below rather than
the rule itself, that's an execution failure — acknowledge and correct it.
The core rule
A named aggregate command (npm run type-check, lint, test, build) is a
wrapper, and its exit code means only "what this wrapper actually ran passed" —
which is often less, or more, than you assume. Before citing a green as proof,
open the script and confirm three things: WHICH targets it covers, HOW it
forwards your arguments, and WHETHER it caches. A pass over the wrong scope is
not evidence about the code you changed.
Checks
- Confirm which targets it covers. In a monorepo/workspace, a top-level
script may check only one project, or only the ones it lists, not everything
you touched. (Illustrative: A
type-check script exited 0 but only ran against one of the
three packages the change modified; the other two were never type-checked.)
Read the script and confirm it spans everything your change affects.
- Confirm how it forwards your args. Wrapper scripts mangle or drop
arguments. A filter you pass may be ignored, applied to the wrong runner, or
widened. (A
--testPathPattern passed through a wrapper was dropped, so the
command silently ran the entire suite from cache instead of the one file
intended.) Verify the flag reached the underlying tool as intended.
- Confirm whether it caches, and whether the cache is stale. A cached
runner can report a green that reflects a previous state, not your current
code. (Illustrative: A lint runner's incremental cache kept a file's previous clean
result because its modification time hadn't changed after a rebase, so a
newly introduced rule violation in that file was never re-linted and the
run stayed green.) Know if the command caches and force a clean run when
the result must reflect the latest change.
- Gate on new failures over a nonzero baseline. If the aggregate already
has errors, exit code is meaningless; gate on "zero new failures referencing
the changed code" (see
measure-the-delta-not-the-absolute), not on green.
(A test suite already had failing tests unrelated to the change; the run's
exit code was nonzero before and after, so citing "the tests are red" said
nothing until the failing test names were diffed and one new failure traced
to the change turned up.)
Pre-flight check — before you cite an aggregate command as proof
If any box is unchecked, the green describes the wrapper, not your change — go
read what the command runs.
1---2name: know-your-aggregate-command-scope3description: Use before trusting a named aggregate command — a `test`, `lint`, `type-check`, or `build` script that wraps a tool. Open it and confirm what it actually runs, how it forwards args, and whether it caches, because a green only means what the command covered. Triggers on "npm run test", "type-check passes", "lint is clean", "the build is green", "run the tests", "--testPathPattern", monorepo/workspace scripts, and citing a script's exit code as proof.4---56# Know Your Aggregate Command's Scope78**Type:** Open-source — client-agnostic methodology, no project-specific detail.910**Created by akbarsha — https://github.com/iamakbarsha1**1112Distilled from cases where a wrapper script exited 0 while checking only part13of what was assumed, and where a test filter silently ran the whole cached14suite.1516**Licence:** Released under CC BY 4.0 — share and adapt for any purpose with17credit. Full text: `LICENSE` at the repository root.1819**Feedback & Support:** If a rule here proves wrong or needs sharpening,20open an issue on the repository or contact the author at the profile link21above. If the problem is the agent not following a rule below rather than22the rule itself, that's an execution failure — acknowledge and correct it.2324## The core rule2526A named aggregate command (`npm run type-check`, `lint`, `test`, `build`) is a27wrapper, and its exit code means only "what this wrapper actually ran passed" —28which is often less, or more, than you assume. Before citing a green as proof,29open the script and confirm three things: WHICH targets it covers, HOW it30forwards your arguments, and WHETHER it caches. A pass over the wrong scope is31not evidence about the code you changed.3233## Checks3435- **Confirm which targets it covers.** In a monorepo/workspace, a top-level36 script may check only one project, or only the ones it lists, not everything37 you touched. *(Illustrative: A `type-check` script exited 0 but only ran against one of the38 three packages the change modified; the other two were never type-checked.)*39 Read the script and confirm it spans everything your change affects.40- **Confirm how it forwards your args.** Wrapper scripts mangle or drop41 arguments. A filter you pass may be ignored, applied to the wrong runner, or42 widened. *(A `--testPathPattern` passed through a wrapper was dropped, so the43 command silently ran the entire suite from cache instead of the one file44 intended.)* Verify the flag reached the underlying tool as intended.45- **Confirm whether it caches, and whether the cache is stale.** A cached46 runner can report a green that reflects a previous state, not your current47 code. *(Illustrative: A lint runner's incremental cache kept a file's previous clean48 result because its modification time hadn't changed after a rebase, so a49 newly introduced rule violation in that file was never re-linted and the50 run stayed green.)* Know if the command caches and force a clean run when51 the result must reflect the latest change.52- **Gate on new failures over a nonzero baseline.** If the aggregate already53 has errors, exit code is meaningless; gate on "zero new failures referencing54 the changed code" (see `measure-the-delta-not-the-absolute`), not on green.55 *(A test suite already had failing tests unrelated to the change; the run's56 exit code was nonzero before and after, so citing "the tests are red" said57 nothing until the failing test names were diffed and one new failure traced58 to the change turned up.)*5960## Pre-flight check — before you cite an aggregate command as proof6162- [ ] You confirmed the command covers ALL targets your change touched.63- [ ] You confirmed your args (filters/flags) reached the underlying tool as64 intended.65- [ ] You know whether it caches, and forced a clean run if the result must be66 current.67- [ ] On a nonzero baseline, you gated on new failures, not on exit code.6869If any box is unchecked, the green describes the wrapper, not your change — go70read what the command runs.