---
title: Package filters
description: Flags that limit a Melos command to a chosen set of packages.
---
> ## Documentation Index
> Fetch the complete documentation index at: https://melos.invertase.dev/llms.txt
> Use this file to discover all available pages before exploring further.

Melos commands support the following global filters:

## --no-private

Excludes private packages (`publish_to: none`). They are included by default.

```bash
melos bootstrap --no-private
```

## --published

Filters packages where the current local package version exists on pub.dev.

```bash
melos bootstrap --published
```

Use `--no-published` to filter packages that have not had their current version
published yet.

## --scope

Includes only packages with names matching the given glob. This option can be
repeated.

```bash
# Run `flutter build ios` on all packages with "example" in the package name

melos exec --scope="*example*" -- flutter build ios
```

## --ignore

Excludes packages with names matching the given glob. This option can be
repeated.

```bash
# Run `flutter build ios` on all packages but ignore those whose packages names contain "internal"

melos exec --ignore="*internal*" -- flutter build ios
```

## --category

Filters packages based on categories declared in the root `pubspec.yaml` file.

```bash
# Run `flutter build ios` on all packages in the "examples" category.

melos exec --category="examples" -- flutter build ios
```

## --diff

Filters packages based on whether there were changes between a commit and the
current `HEAD` or within a range of commits.

Specify a range of commits using the git shorthand syntax
`START_COMMIT..END_COMMIT` and `START_COMMIT...END_COMMIT`.

```bash
# Run `flutter build ios` on all packages that are different between current
# branch and the specified commit hash.

melos exec --diff=COMMIT_HASH -- flutter build ios

# Run `flutter build ios` on all packages that are different between remote
# `main` branch and `HEAD`.

melos exec --diff=origin/main...HEAD -- flutter build ios
```

To list the packages that changed since their latest release tag, use the
[`changed`](/reference/commands/changed) command.

## --dir-exists

Includes only packages where a specific directory exists inside the package.

```bash
# Only bootstrap packages with an example directory

melos bootstrap --dir-exists="example"
```

## --file-exists

Includes only packages where a specific file exists in the package.

```bash
# Only bootstrap packages with an README.md file

melos bootstrap --file-exists="README.md"
```

## --flutter

Filters packages that need the Flutter SDK. A package needs the Flutter SDK when
its `pubspec.yaml` file meets any of these conditions:

- depends on a package that is shipped with the Flutter SDK (`sdk: flutter`),
  for example `flutter` or `flutter_test`, in any dependency section,
- declares a Flutter SDK constraint under `environment`, or
- depends, directly or transitively, on another package in the workspace that
  declares a Flutter SDK constraint or that has Flutter in its `dependencies`.
  Melos ignores the `dev_dependencies` and `dependency_overrides` of that
  package, because they do not apply to the packages that depend on it.

```bash
melos exec --flutter -- flutter test
```

Use `--no-flutter` to filter packages that do not need the Flutter SDK.

If a package needs the Flutter SDK only because of a dependency outside the
workspace (for example a hosted package), declare a Flutter SDK constraint:

```yaml
environment:
  sdk: ^3.9.0
  flutter: ">=3.35.0"
```

The same rules decide whether Melos uses the `flutter` or the `dart` tool for a
package in commands such as `melos analyze` and `melos test`.

## --depends-on

Includes only packages that depend on specific dependencies.

```bash
melos exec --depends-on="flutter" --depends-on="firebase_core" -- flutter test
```

Use `--no-depends-on` to filter packages that do not depend on the given
dependencies.

## --include-dependencies

Takes the filtered list of packages, and expands them to include those packages'
transitive dependencies (ignoring filters).

```bash
melos list --scope=some_package --include-dependencies
```

## --include-dependents
Takes the filtered list of packages, and expands them to include those packages'
transitive dependents (ignoring filters).

```bash
melos list --scope=some_package --include-dependents
```

## --post-filter

The packages that are included through `--include-dependencies` and
`--include-dependents` skip all the other filters. Use `--post-filter` to apply
a filter after Melos includes the dependencies and dependents. The value is
any of the other filters, written without the leading dashes. The option can be
repeated.

```bash
# Run `build_runner` in `some_package` and all of its transitive dependencies,
# but only in the packages that depend on `build_runner`.

melos exec --scope=some_package --include-dependencies \
  --post-filter=depends-on=build_runner -- dart run build_runner build

# Run the tests of all changed packages and their transitive dependents, but
# only in the packages that have a `test` directory.

melos exec --diff=origin/main...HEAD --include-dependents \
  --post-filter=dir-exists=test -- dart test
```

Flags are written in the same way, for example `--post-filter=no-private`.

Post filters apply to all packages, including those that matched the other
filters. `include-dependencies` and `include-dependents` cannot be used as post
filters.

In [`packageFilters`](/configuration/scripts#packagefilters), the `postFilters`
option defines the post filters:

```yaml
melos:
  scripts:
    generate:
      exec: dart run build_runner build
      packageFilters:
        scope: some_package
        includeDependencies: true
        postFilters:
          dependsOn: build_runner
```
