---
title: Clean command
description: Remove temporary pub files and generated Melos IDE files from the workspace.
---
> ## 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.

<Info>Supports all [Melos filtering](/filters) flags.</Info>

This command cleans the current workspace and all its packages of temporary pub
and generated Melos IDE files.

```bash
melos clean
```

Melos deletes the following files and directories:

- `{packageRoot}/.packages`
- `{packageRoot}/.flutter-plugins`
- `{packageRoot}/.flutter-plugins-dependencies`
- `{packageRoot}/.dart_tool` (the whole directory)
- `{workspaceRoot}/.idea/runConfigurations/melos_*.xml`

Melos also removes the dependency overrides that it manages from
`pubspec_overrides.yaml`, at the workspace root and in each package. Entries
that you added yourself are kept, and the file is deleted if no entries are
left.

To remove temporary files and reinstall dependencies, run:

```bash
melos clean
melos bootstrap
```

## Combine with filters

Clean supports all package filtering options. To clean only a subset of your
packages:

```bash
# Only clean Flutter packages or apps.

melos clean --flutter
```

## Add a postclean lifecycle script

Melos supports various command lifecycle hooks that you can define in your
root `pubspec.yaml` file.

For example, to remove generated files from `build_runner` after you run
`melos clean`, add a `post` hook script.

```yaml
# root pubspec.yaml
# ...

melos:
  command:
    clean:
      hooks:
        post: rm packages/my_package/lib/src/generated_file.g.dart
# ...

```

Another common use case is to run `flutter clean` in all Flutter packages;

```yaml
# root pubspec.yaml
# ...

melos:
  command:
    clean:
      hooks:
        # Runs "flutter clean" in all Flutter packages (`--flutter`)
        # with a concurrency of 3 at a time (`--concurrency=3`).
        post: melos exec --flutter --concurrency=3 -- "flutter clean"
# ...

```
