---
source: https://iinventedlight.com/library/notes/pnpm-filtering.md
title: "pnpm --filter selects workspace packages by name, dependency relation, directory or git changes"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (pnpm docs); MIT (pnpm/pnpm.io (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Filtering; pnpm/pnpm.io (GitHub), Filtering (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-18
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-18
as_of: 2026-11-18
confidence: medium
untested: "Not reproduced (2026-11-18). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: pnpm filtering"
tags: [pnpm, filter, monorepo, workspaces, ci]
client: Librarian
sources:
  - id: S1
    title: "Filtering"
    publisher: pnpm docs
    url: https://pnpm.io/filtering
    accessed: 2026-11-18
    license: "MIT"
  - id: S2
    title: "Filtering (source page)"
    publisher: pnpm/pnpm.io (GitHub)
    url: https://github.com/pnpm/pnpm.io/blob/main/docs/filtering.md
    accessed: 2026-11-18
    license: "MIT"
---
# pnpm --filter selects workspace packages by name, dependency relation, directory or git changes
**Answer:** `pnpm --filter <selector> <command>` (or `-F`) restricts a command to a subset of workspace packages. pnpm supports a rich selector syntax for picking packages by name or by relation.

## Selector cheat sheet

| Selector | Selects |
|---|---|
| `"@babel/core"`, `"@babel/*"`, `"*core"` | a package by name, or a set by pattern |
| `foo...` | foo and its dependencies (direct and non-direct) |
| `"foo^..."` | only foo's dependencies |
| `...foo` | foo and the packages dependent on it |
| `"...^foo"` | only the dependents of foo |
| `"{packages/**}"` or `./<glob>` | packages under a directory glob |
| `"[origin/master]"` | packages changed since that commit or branch |

```sh
pnpm --filter foo... test
pnpm --filter "...{packages/**}[origin/master]" test
```

## Details

- The scope is optional: `--filter=core` picks `@babel/core` if `core` is not found. If several packages share the name, such as `@babel/core` and `@types/core`, filtering without scope will pick nothing.
- Directory selectors combine with `...` and with `[<since>]`, so one command can test all changed projects inside a directory plus their dependents.
- The `[<since>]` selector may be suffixed or prefixed with `...` to include dependencies or dependents.

## See also

- [pnpm-workspaces](https://iinventedlight.com/library/notes/pnpm-workspaces/)
- [node-process-and-console](https://iinventedlight.com/library/notes/node-process-and-console/)
- [node-esm](https://iinventedlight.com/library/notes/node-esm/)

## Claims

- id: C1
  claim: Filtering restricts commands to subsets of packages.
  source: S2
  evidence: "Filtering allows you to restrict commands to specific subsets of packages."

- id: C2
  claim: A trailing ellipsis selects a package and its dependencies.
  source: S2
  evidence: "suffix the package name with an ellipsis"

- id: C3
  claim: The since selector picks packages changed since a commit or branch.
  source: S2
  evidence: "Selects all the packages changed since the specified commit/branch."

- id: C4
  claim: Filtering without scope can pick nothing when names collide.
  source: S1
  evidence: "then filtering without scope will pick nothing"

## Sources

- [S1] Filtering. pnpm docs. https://pnpm.io/filtering . License: MIT. Accessed 2026-11-18.

- [S2] Filtering (source page). pnpm/pnpm.io (GitHub). https://github.com/pnpm/pnpm.io/blob/main/docs/filtering.md . License: MIT. Accessed 2026-11-18.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: pnpm docs, Filtering; pnpm/pnpm.io (GitHub), Filtering (source page). MIT (https://raw.githubusercontent.com/pnpm/pnpm.io/main/LICENSE). Copyright pnpm contributors. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
