---
url: https://edgefit.kitdev.space/reference/cli.md
description: >-
  edgefit CLI reference: every command, flag, output format and exit code for
  check, compare, diff, package and targets.
---

# CLI

```
edgefit <command> [options]
```

| Command               | What it does                                                |
| --------------------- | ----------------------------------------------------------- |
| [`check`](#check)     | Scan a project from its entry point                         |
| [`compare`](#compare) | Show the reached APIs side by side across targets           |
| [`package`](#package) | Check a published package or a local one                    |
| [`diff`](#diff)       | Show what changed between two `check --format json` reports |
| [`targets`](#targets) | List the supported targets and the data behind each         |
| `help`                | Show the help text                                          |

## check

```sh
edgefit check [options]
```

| Option              | Description                                                                                                                                                          |
| ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--target <name>`   | Target runtime: `workerd`, `bun`, `deno`, `deno-deploy`, `netlify-edge`, `vercel-edge`. Repeat it for more than one. Default: the config's `targets`, then `workerd` |
| `--entry <file>`    | Entry point or glob. Repeat it for more than one. Default: the config's `entry`, then each target's own, such as wrangler's `main`                                   |
| `--built <path>`    | Scan build output instead of source: its entry file or directory. See [build output](/guide/built-output)                                                            |
| `--root <dir>`      | Project root. Default: the current directory                                                                                                                         |
| `--config <file>`   | Config file. Default: `edgefit.config.{ts,mts,js,mjs}` in the root                                                                                                   |
| `--format <format>` | `text`, `json` or `github`. Default: `text`                                                                                                                          |
| `--verbose`         | List every finding in full: [guarded](/guide/findings#guarded-usages) ones and the `unknown` warnings that are otherwise folded                                      |
| `--no-color`        | Disable colors                                                                                                                                                       |

`--entry` and `--built` cannot be combined.

```sh
edgefit check
edgefit check --entry src/index.ts --target workerd --target bun
edgefit check --built .output/server
edgefit check --format json > report.json
```

## compare

```sh
edgefit compare [target...] [options]
```

| Option              | Description                                           |
| ------------------- | ----------------------------------------------------- |
| `[target...]`       | Targets to compare. Default: `workerd`, `bun`, `deno` |
| `--all`             | Include APIs that every target supports               |
| `--verbose`         | List the packages and findings behind each row        |
| `--format <format>` | `text` or `json`. Default: `text`                     |

`--entry`, `--root`, `--config` and `--no-color` work as for `check`. See [Comparing targets](/guide/compare).

## diff

```sh
edgefit diff <base.json> <head.json> [options]
```

| Option              | Description                                                                           |
| ------------------- | ------------------------------------------------------------------------------------- |
| `--fail-on <when>`  | `new-errors`, `errors` or `never`. Default: `new-errors`                              |
| `--format <format>` | `text`, `json` or `github`. `github` annotates only the new findings. Default: `text` |
| `--no-color`        | Disable colors                                                                        |

Both files must be written by `edgefit check --format json` with the same edgefit version. See [Pull request checks](/guide/ci).

## package

```sh
edgefit package <name[@version]|directory|file.tgz> [options]
```

Installs the package into a temporary project with `npm install --ignore-scripts`, then checks each public entry point with every export used. `name`, `name@1.2.3`, `name@^1`, `@scope/name` and `@scope/name@tag` are accepted. A directory is packed with `npm pack` first, from a copy without its `prepare` script. The files are the ones you would publish, but no script of the package runs, so build the package before you check it. See [Check an npm package's compatibility](/guide/packages) for what a result means.

| Option               | Description                                                       |
| -------------------- | ----------------------------------------------------------------- |
| `--target <name>`    | Target runtime, repeatable. Default: `workerd`, `bun`, `deno`     |
| `--export <subpath>` | Check only this `exports` subpath, such as `./client`. Repeatable |
| `--skip <subpath>`   | Leave out a subpath. Repeatable                                   |
| `--badge <file>`     | Also write a badge SVG                                            |
| `--registry <url>`   | npm registry to install from                                      |
| `--keep`             | Keep the temporary project and print where it is                  |
| `--format <format>`  | `text` or `json`. Default: `text`                                 |

Exits with 1 if any target fails or could not be checked.

## targets

```sh
edgefit targets
```

Prints every target with its export conditions and data, then every data source with its version and license.

## Version

```sh
edgefit --version   # or -v
```

Prints the installed version and exits with `0`. With `pnpm dlx` or `npx`, pin a version (`pnpm dlx edgefit@0.2.0 check`) when you need to be sure which one runs, since the package manager may reuse a cached copy of `latest`.

## Output formats

| Format   | Use it for                                                                                 |
| -------- | ------------------------------------------------------------------------------------------ |
| `text`   | Reading in a terminal                                                                      |
| `json`   | Tools and `edgefit diff`. The shape is versioned, see [JSON reports](/reference/json)      |
| `github` | GitHub Actions. Prints `::error` and `::warning` workflow commands that become annotations |

## Colors

Colors are on when stdout is a terminal. They are off when `--no-color` is passed or the `NO_COLOR` environment variable is set to a non-empty value.

## Tracing exports

To see why a finding reaches an export, set the `EDGEFIT_DEBUG_TRACE` environment variable. edgefit then prints to stderr, for each run of the trace, the files that it loads. For each file, it prints what is asked of it, the file that first asked for all of it, and the units that are live: the count of the units that run at load, then the name of each declared unit that something uses, such as a function, a class, a variable or an imported name. A file that edgefit cannot trace is marked `opaque` and counts in full. Set the variable to `*` for every run, or to an export name for the runs of `package` that ask for that export alone:

```sh
EDGEFIT_DEBUG_TRACE=errors edgefit package undici --target workerd
```

`check` traces the whole graph, so it prints with `*` only.

## Exit codes

| Code | Meaning                                                                                                                    |
| ---- | -------------------------------------------------------------------------------------------------------------------------- |
| `0`  | No error-level findings (for `diff`: nothing that matches `--fail-on`)                                                     |
| `1`  | Error-level findings (for `diff`: findings that match `--fail-on`)                                                         |
| `2`  | Invalid arguments or config, a project that could not be resolved, or a target that could not be checked while others were |
