---
title: "vlt query"
description: "Documentation for the vlt client and the vlt registry."
url: "https://docs.vlt.io/client/commands/query"
image: "https://docs.vlt.io/og/client/commands/query"
lang: "en"
---

# vlt query

Usage:

```bash title="Terminal"
$ vlt query
$ vlt query <query> --view=[human | json | mermaid | svg | png | count]
```

List installed dependencies matching the provided query.

The graph being queried is the one built by `vlt install`. In a project installed by another client (an `npm install` or `pnpm install` `node_modules`) there is no such graph, so the command errors instead of reporting every dependency as missing. Run `vlt install` first. `:host()` queries are the exception, since they load their graph from somewhere else.

## Examples

Query packages with the name "foo"

```bash title="Terminal"
$ vlt query '#foo'
```

Query all peer dependencies of workspaces

```bash title="Terminal"
$ vlt query '*:workspace > *:peer'
```

Query all direct project dependencies with a "build" script

```bash title="Terminal"
$ vlt query ':project > *:attr(scripts, [build])'
```

Query packages with names starting with "@vltpkg"

```bash title="Terminal"
$ vlt query '[name^="@vltpkg"]'
```

Find packages with uncommitted changes

```bash title="Terminal"
$ vlt query ':diff()'
```

Find packages changed since main branch

```bash title="Terminal"
$ vlt query ':diff(main)'
```

Find workspaces changed since last commit

```bash title="Terminal"
$ vlt query ':workspace:diff(HEAD~1)'
```

Check for malware in dependencies

```bash title="Terminal"
$ vlt query ':malware'
```

Find packages with critical security issues

```bash title="Terminal"
$ vlt query ':malware(critical), :cve(*), :eval'
```

## Options

### `--global`, `-g`

Query the [global project](https://docs.vlt.io/client/commands/install.md#global-installs) instead of the current one.

### view

Output format. Defaults to human-readable or json if no tty. Use `svg` or `png` to render the dependency graph as an image and open it automatically.

```
--view=[human | json | mermaid | svg | png | count]
```

### expect-results

Set expected result count for automation and CI/CD pipelines. Exits with error code if expectation is not met.

```
--expect-results=<comparison>
```

**Examples:**

- `--expect-results=0` - Expect no results (useful for security checks)
- `--expect-results=">0"` - Expect at least one result
- `--expect-results="<5"` - Expect fewer than 5 results
- `--expect-results=">=10"` - Expect 10 or more results

```bash title="Terminal"
# Security check that fails if malware is found
$ vlt query ':malware' --expect-results=0

# Ensure at least one workspace exists

$ vlt query ':workspace' --expect-results=">0"
```
