# atmos vendor clean

Remove every vendored file recorded in `vendor.lock.yaml`. Only deletes files the lock actually
owns. It never deletes files another still-selected artifact owns, and never deletes files outside
the lock entirely.

## Usage

```shell
atmos vendor clean [--component <name>] [--tags <a,b>] [--force] [--dry-run]
atmos vendor clean [--stack <stack>] [--labels <k>=<v>]... [--tags <a,b>] [--force] [--dry-run]
```

By default, `vendor clean` preserves any lock-owned file whose content doesn't match its recorded
checksum. It refuses to run and names every such file. Pass `--force` to delete them anyway.
`vendor clean` preserves `vendor.lock.yaml` and all its entries, including recorded versions,
checksums, and provenance. This also applies to selective cleanup and `--force`. A subsequent
`vendor pull` reinstalls a fully cleaned package without missing-file drift warnings, using
the retained lock information. Partially missing or modified files still trigger drift checks; use
`vendor pull --refresh-lock` when you intend to refresh the lock.

At most one base selector may be given: `--component` or `--stack`/`--labels` (a stack-resolved
component set, composable with each other, like
`atmos vendor pull`'s own `--stack`/`--labels`). `--tags`
(vendor.yaml's own declared source tags) is a separate, independent filter that composes with
either base selector, or stands on its own — narrowing the cleaned set to only components whose
declared tags also match; a component with no `vendor.yaml` entry has no tags to match and is
excluded by a non-empty `--tags` filter. Omit every selector to clean everything. A selector that
matches nothing is an error, not a silent "clean everything" fallback.

## Examples

```shell
# Preview what would be removed, without deleting anything.
atmos vendor clean --dry-run

# Remove every vendored artifact recorded in the lock.
atmos vendor clean

# Remove only one component's vendored files.
atmos vendor clean --component vpc

# Remove every component whose vendor.yaml source declares a given tag.
atmos vendor clean --tags networking

# Remove every component in a stack, or matching stack metadata.labels.
atmos vendor clean --stack dev-us-west-2
atmos vendor clean --labels tier=1

# Repeat --labels to combine multiple selectors across occurrences.
atmos vendor clean --labels tier=1 --labels cost-center=platform

# Remove a stack's components, narrowed further by declared vendor.yaml tags.
atmos vendor clean --stack dev-us-west-2 --tags networking

# Delete lock-owned files even if they were modified since vendoring.
atmos vendor clean --force
```

## Flags

- **`--component` / `-c` (string)**
  Clean only this component. Mutually exclusive with 
  `--stack`
  /
  `--labels`
  . Composes with 
  `--tags`
   (narrows to this component only if its declared 
  `vendor.yaml`
   tags also match).
- **`--tags` (string)**
  Clean only components whose 
  `vendor.yaml`
   source declares any of these comma-separated tags (matches any). An independent filter: composes with 
  `--component`
   or 
  `--stack`
  /
  `--labels`
   to narrow further, or stands on its own.
- **`--stack` / `-s` (string)**
  Clean only components belonging to the specified stack. Composes with 
  `--labels`
   to narrow further, and with 
  `--tags`
   to filter by declared source tags. Mutually exclusive with 
  `--component`
  .
- **`--labels` (string, repeatable)**
  Clean only components whose stack 
  `metadata.labels`
   match ALL of these 
  `key=value`
   or 
  `key:value`
   pairs — comma-separated within one occurrence, and/or repeated for more (
  `--labels tier=1 --labels cost-center=platform`
  ). Composes with 
  `--stack`
   and 
  `--tags`
  . Mutually exclusive with 
  `--component`
  .
- **`--type` / `-t` (string, default `terraform`)**
  Component type (
  `terraform`
  , 
  `helmfile`
  , or 
  `packer`
  ). Pass this flag explicitly to scope a 
  `--stack`
  /
  `--labels`
   selection to one component type. When you omit it, every component type is considered.
- **`--file` (string, default `./vendor.yaml`)**
  The vendor manifest to read declared source tags from when resolving 
  `--tags`
  .
- **`--force` (boolean)**
  Delete modified lock-owned files instead of refusing to run.
- **`--dry-run` (boolean)**
  Show which files would be removed without deleting anything.

:::note
A single modified file blocks the entire run unless you pass `--force`. Atmos deletes no files for
that invocation, even unmodified ones, until you resolve the conflict or pass `--force`. Scope with
`--component` to clean only the artifacts you're sure about.
:::
