Safeguard
Product•

How do you check an npm or pip package before install from the terminal?

The Safeguard CLI has a one shot package check that exits 1 on a block, plus a local proxy mode. Here are the documented commands and their limits.

Safeguard Security Team
4 min read

Use the Safeguard CLI's package firewall command to check one npm or pip package and read its JSON verdict, which exits with code 1 on a block. The same binary runs the local runner, but the runner docs describe scan jobs, not package checks, so treat them as separate features.

Which command checks one package?

The Package Firewall docs give this example for a single check:

safeguard pkgfw check --ecosystem npm --name left-pad --version 1.3.0

It returns JSON and exits 1 on a block. That makes it usable in a shell script: if the exit code is 1, stop before the install runs. Supported ecosystems are npm and pip. The docs state there is no CLI command yet for fronting an existing repository manager.

Replace the package name and version with the one you are considering. Keep in mind the example is from the docs, and we did not run it against your account.

What does it look for?

Per the docs, the firewall evaluates:

  • typosquatting, meaning names resembling well known packages
  • dependency or namespace confusion
  • known malware and blocklist matches
  • behavioral analysis, a static inspection of the package archive that does not execute code

Decisions are Allow, Warn, which installs but records the decision, and Block. There are also Audit, which records without blocking so you can measure impact, and Quarantine, which holds a flagged package pending review. The docs recommend starting in audit mode, then moving to warn or block.

Can it run as a proxy?

Yes. For a local or CI proxy the docs show:

safeguard pkgfw start --mode quarantine --port 8899

with audit and quarantine as the modes for the local proxy. Package managers fetch through the proxy, so each package, including transitive ones, is evaluated before it reaches your machine or build. The docs say the feature is toggled by an admin feature flag enforced server side, so you may need your administrator to turn it on.

Where does the local runner fit?

The runner is the other thing the CLI does. According to the Local Runner page, it executes the platform's scan jobs and assistant turns on your own machine and uploads just the resulting SBOM and findings, never your source code. You start it with safeguard then /login, or headless with safeguard runner start --workspace and a path.

The runner page does not describe package checks or the firewall. The honest summary is that both live in one binary, and a person at a terminal uses pkgfw for pre install checks and the runner for scan jobs.

Related, safeguard scan --dir . builds an SBOM and matches it against vulnerability databases. That tells you what is already in a project, which is a different question from whether to add a new package.

What are the limits?

  • Protection applies to fetches that go through the proxy. A developer who bypasses it is not covered.
  • Support covers npm and pip, nothing else.
  • The docs do not describe detection accuracy in depth.
  • A one shot check is a point in time verdict on a name and version.

What to do

  1. Install the CLI with curl -fsSL https://cli.safeguard.sh/install | bash, or the PowerShell line on Windows, then run safeguard login.
  2. Ask your admin whether the package firewall flag is on for your tenant.
  3. Run the one shot check on a package you already trust, to learn the output format.
  4. Run it on a misspelled popular name in a scratch project, and confirm it flags it.
  5. Add a pre install step to your scripts that stops on exit code 1.
  6. Start the proxy in audit mode for a week and read the findings.
  7. Move to warn or block once the audit results look sensible.

Quick check

Does the one shot check install anything?

No. It evaluates the named package and returns a JSON verdict. Your script decides whether to continue.

Is this the same as running a scan?

No. A scan inventories what is already in a project. The package check judges a package before you add it.

Sources

Last reviewed: 18 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.