Querying Dependencies
List, group, and trace a project's dependencies with xgrep deps — flat inventory, per-manifest tree, and go-mod-why-style usage.
xgrep deps answers questions about a project's dependencies, built on the same
offline SBOM as xgrep sbom plus the package-aware
code graph. It has three subcommands:
deps list— a flat, scope-tagged inventory.deps tree— each manifest's root, direct, and transitive sets.deps why— which dependencies your code actually imports, and where.
All queries are offline (file parsing plus graph queries, no network).

deps list
List every dependency as a flat inventory, each tagged direct or transitive:
xgrep deps list .
xgrep deps list --scope direct . # only direct dependencies
xgrep deps list --scope transitive . # only transitive
xgrep deps list --license . # with each dependency's licensedirect go github.com/spf13/cobra@v1.10.2
direct npm react@18.3.1
transitive npm scheduler@0.23.2
3 dependenciesA package declared direct by any manifest is reported as direct (direct-wins
dedup). Add --json for machine-readable output, --ecosystem to restrict, and
--ref to read from a git ref.
Licenses in the inventory
--license adds each dependency's license, resolved the same way deps license resolves it: from the manifest; from package
metadata a package manager wrote to disk, for the ecosystems whose dependency
files cannot state a license at all (requirements.txt, pom.xml); or from the
license file shipped with the vendored source.
$ xgrep deps list --license .
direct go MIT github.com/foo/bar@v1.2.3
direct npm AGPL-3.0-only ! sneaky@1.0.0
direct python BSD-3-Clause python-dotenv@1.0.1
direct npm (undetermined) lodash@4.17.21
4 dependencies
licenses: 2 declared, 1 from package metadata, 0 concluded from the tree, 1 undetermined
! 1 package(s) declare one license and ship another — the more restrictive of the two is shownA ! marks a package whose manifest and shipped source disagree; the column
shows the more restrictive of the two, so a package declaring MIT while
shipping AGPL is listed as AGPL. The column is an inventory field, not a verdict
— deps license is what applies policy and decides
which signal governs.
The licenses: line separates the answers read from the repository from those
read from package metadata on this machine: a clean checkout on another host
resolves the second group only if the same packages are installed there.
Resolving licenses walks the vendored trees, so it is opt-in rather than part of
a plain listing. Add --license-full to also identify a license by matching the
text of its license file, which resolves the dependencies whose LICENSE carries
no SPDX identifier.
deps tree
Show each discovered manifest grouped as Root → Direct → Transitive. In a monorepo, each module's manifest gets its own tree (no cross-manifest dedup):
xgrep deps tree .my-service@1.2.0 [go.mod]
direct (2):
github.com/spf13/cobra@v1.10.2
go.mondoo.com/mql@v13.0.0
transitive (1):
github.com/inconshreveable/mousetrap@v1.1.0This is two-level, not a fully nested tree: parsed manifests expose no
package→package edges to nest by. For the complete transitive set, use
deps list --scope transitive.
deps why
Trace the relationship between your first-party code and a dependency. It works in both directions.
Forward — which dependency packages does the code under a path import directly, and from which files:
xgrep deps why ./cmd./cmd directly imports 1 package(s):
github.com/spf13/cobra@v1.10.2 [go]
via cmd/xgrep/main.goReverse (--package) — which first-party files directly import a given package
(by name or purl). This answers "is this dependency actually used by our code, and
where?":
xgrep deps why --package github.com/spf13/cobragithub.com/spf13/cobra@v1.10.2 [go] is directly imported by 13 file(s):
cmd/xgrep/ci.go
cmd/xgrep/deps.go
cmd/xgrep/main.go
…If a package is in the SBOM but no first-party file imports it directly, deps why --package says so — a hint that it's pulled in transitively.
Direct usage only.
deps whyreports direct code→package imports. Multi-hop import chains and dependency-tree transitivity ("A pulls in B") are not yet tracked. Usedeps list --scope transitivefor the full transitive inventory.
Last updated on
Generating an AIBOM
Produce a CycloneDX 1.6 AI Bill of Materials with xgrep sbom --include aibom — an inventory of the AI/LLM SDKs, frameworks, inference runtimes, and models a codebase uses, across 20 languages, fully offline.
Scanning for vulnerabilities
xgrep scan combines SAST and SCA in one run — it builds an SBOM and matches your open-source dependencies against known CVEs via Mondoo Platform.