> ## Documentation Index
> Fetch the complete documentation index at: https://docs.custoden.com/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI

> Check packages before installing them, and scan local projects, workflows and public repositories from your terminal.

The [Custoden CLI](https://github.com/Custoden/cli) calls this API from your terminal. It needs Node.js 20 or later, and no account or API key.

```bash theme={null}
npx custoden check express lodash@4.17.21 requests==2.32.3
```

## Commands

| Command | Endpoint |
| - | - |
| `custoden check <package...>` | [Check multiple packages](https://docs.custoden.com/api-reference/check-multiple-packages.md) |
| `custoden install <package...>` | [Check multiple packages](https://docs.custoden.com/api-reference/check-multiple-packages.md), then your package manager |
| `custoden scan [dir]` | Packages, [Analyze a workflow](https://docs.custoden.com/api-reference/analyze-a-workflow.md) and [Analyze CI files](https://docs.custoden.com/api-reference/analyze-ci-files.md) for a local project |
| `custoden lockfile [file...]` | [Scan a lockfile](https://docs.custoden.com/api-reference/scan-a-lockfile.md) |
| `custoden workflow [file...]` | [Analyze a workflow](https://docs.custoden.com/api-reference/analyze-a-workflow.md) |
| `custoden repo <owner/repo>` | [Scan a repository](https://docs.custoden.com/api-reference/scan-a-repository.md) |
| `custoden runs <owner/repo>` | [Scan recent runs](https://docs.custoden.com/api-reference/scan-recent-runs.md) |

Packages are npm by default. Use `pypi:name`, `name==1.2.3` or `--pypi` for PyPI.

## Install packages safely

`custoden install` checks each package first. If one is malicious, suspicious or does not exist, nothing is installed. Otherwise it installs the exact versions that were checked, so a release published in between cannot slip in.

```bash theme={null}
npx custoden install axios
npx custoden install -D vitest -- --ignore-scripts
```

The package manager is detected from the nearest lockfile (npm, pnpm, Yarn, Bun, pip, uv or Poetry), or set with `--pm`.

## Scan a project

`custoden scan` reads lockfiles and manifests locally and sends only package names and versions. Workflows and CI files (package manifests, build and test setup, Makefiles, shell scripts) are sent for analysis.

| Option | Effect |
| - | - |
| (default) | Direct dependencies, at their locked versions |
| `--changed` | Only what changed since `--base` (default `HEAD`), including uncommitted files |
| `--all` | Every locked package, including transitive dependencies |
| `--only packages,workflows,files` | Limit what is checked |
| `--max-packages <n>` | Most packages to check (default 50) |
| `--verbose` | Also list packages without findings |

## Check a whole lockfile

`custoden lockfile` sends each lockfile in the project (or the files you name) to [Scan a lockfile](https://docs.custoden.com/api-reference/scan-a-lockfile.md), which checks every package, including transitive dependencies, for known malware and vulnerabilities. It costs 5 units per file instead of 1 per package. Unlike `scan`, it sends the whole file, including any registry URLs in it.

```bash theme={null}
npx custoden lockfile
npx custoden lockfile poetry.lock
```

## Pre-commit hooks

With [pre-commit](https://pre-commit.com), add the hook to `.pre-commit-config.yaml`:

```yaml theme={null}
repos:
  - repo: https://github.com/Custoden/cli
    rev: v0.2.0
    hooks:
      - id: custoden
```

With Husky or another hook manager, run the same command:

```bash theme={null}
# .husky/pre-commit
npx custoden scan --changed
```

The hook checks new and updated dependencies, workflows and CI files, and blocks the commit when something is at or above the thresholds below.

## Exit codes

| Code | Meaning |
| - | - |
| `0` | Nothing at or above the thresholds |
| `1` | A package or finding at or above the thresholds |
| `2` | Usage error, or the check could not complete |

`--fail-on` sets the package threshold (`malicious`, `suspicious`, `review`, `never`; default `suspicious`). `--fail-on-severity` sets the threshold for findings (`critical`, `high`, `medium`, `low`, `never`; default `high`). `--json` prints the API results.

## Rate limits

The CLI shares the API's [rate limits](https://docs.custoden.com/getting-started/rate-limits.md) for your IP address. When it reaches the per-minute limit, it waits and continues. For pull requests, the [GitHub Action](https://docs.custoden.com/guides/github-action.md) is a better fit.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.