Why an install command deserves a review step#
An install command looks harmless because it is short, but it changes your dependency tree, your lockfile, and sometimes your build scripts. When an AI assistant proposes a command, treat it as a draft from an untrusted source rather than an instruction. The goal is not to distrust every suggestion; it is to make the suggestion pass the same checks you would apply to a package a colleague recommended.
The npm documentation describes audit as a command that submits a description of your configured dependencies to your default registry and asks for a report of known vulnerabilities. That framing is useful: your dependency set is data you are choosing to send and to install, so it should be deliberate. A short pause before execution is cheaper than unwinding a bad tree later.
- Read the full command, not just the package name
- Identify which registry and scope the install targets
- Decide whether the dependency belongs in production or dev
Confirm the package identity and scope#
Start by separating the package name from the rest of the command. Check spelling, scope, and whether the package is the one you actually mean. Typosquatting and lookalike names are a common reason a plausible-looking command is wrong. If the assistant invented a package name, the install will either fail or, worse, resolve to something unrelated that happens to exist.
Also check where the dependency is being added. The npm audit documentation notes that omit options such as production or dev shorthands affect which packages are included in the audit payload. That is a reminder that dependency type matters: a tool used only for local builds should not quietly become a production dependency. Confirm the flag that controls this before running the command.
- Verify the exact package name and scope
- Check whether the command adds a dev, optional, or peer dependency
- Confirm the registry the command will use
Use the lockfile and dependency graph as evidence#
A lockfile is the record of what will actually be installed. The npm audit documentation states that by default npm requires a package-lock or shrinkwrap file to run the audit, and that bypassing the lock with --no-package-lock can produce different results on every run because npm rebuilds the dependency tree. That is a strong argument for keeping the lockfile in place and reviewing its diff after any install.
The GitHub dependency graph offers a complementary view. It summarizes manifest and lock files in a repository and, for each dependency, shows the version, license, manifest file, and whether it has known vulnerabilities. It also supports showing the transitive path that brought a dependency in. When an AI suggests a package, use the graph to see whether it is already present, what it pulls in, and whether it is flagged.
- Keep package-lock.json committed and review its diff
- Use the dependency graph to inspect transitive paths
- Check whether the suggested package already exists in the tree
Run an audit before and after the change#
Run npm audit on the current tree first so you have a baseline. Then apply the install, and run it again. The audit command exits with a non-zero code if vulnerabilities are found, and the --audit-level option changes the failure threshold without filtering the report output. In a CI context, that threshold is useful for making the pipeline fail on moderate or higher findings while still showing the full report.
Be careful with automatic remediation. The documentation notes that some vulnerabilities cannot be fixed automatically and require manual intervention, and that npm audit fix runs a full install under the hood, so installer configuration applies. A dry run with --dry-run --json is a reasonable way to see what a fix would do before letting it change anything.
- Capture a baseline audit before installing
- Re-run the audit after the install and compare
- Use --audit-level to set a CI failure threshold
- Preview fixes with --dry-run before applying them
npm audit --json > audit-before.json
npm install <package>
npm audit --json > audit-after.jsonVerify signatures where the registry supports them#
For packages from the public npm registry, or any registry that supports signatures, the npm CLI can verify registry signatures. The documentation describes npm audit signatures, which also verifies provenance attestations of downloaded packages. Because attestation formats are relatively new and may change, the docs recommend running a recent npm CLI version, which may mean updating beyond the version bundled with Node.js.
Signature verification is not a substitute for reading the command, but it adds an integrity check on what you downloaded. If a package lacks signatures or the verification fails, treat that as a reason to pause rather than a formality to skip.
- Run npm audit signatures after installing
- Keep the npm CLI reasonably current for attestation support
- Investigate failures instead of ignoring them
npm audit signaturesA worked example: reviewing a suggested install#
Suppose an assistant suggests installing a small formatting helper. First, read the command and confirm the package name and scope. Second, check whether the package already appears in your lockfile or dependency graph; if it does, you may only need a version change. Third, decide whether it is a dev dependency. Fourth, run the install and inspect the lockfile diff. Fifth, run npm audit and compare against your baseline. Finally, run npm audit signatures if the registry supports it.
If any step produces an unexpected transitive dependency, a new vulnerability, or a signature failure, stop and investigate before committing. The point is not to reject AI suggestions wholesale; it is to make each one pass a short, repeatable review that leaves evidence in your repository.
- Confirm name, scope, and dependency type
- Check the graph and lockfile for existing entries
- Inspect the lockfile diff after install
- Compare audits before and after
- Verify signatures when available
Verification checklist#
Use this checklist each time an AI-generated install command appears in your workflow. It is intentionally short so it can be applied consistently rather than skipped under time pressure.
Keep the checklist in your repository or team notes so the review is visible and repeatable, and so the evidence from each step is easy to find later.
- The package name and scope match what you intend to install
- The dependency type is correct for how the package will be used
- The lockfile is present and its diff has been reviewed
- The dependency graph shows no unexpected transitive paths
- A baseline audit was captured before the install
- The post-install audit shows no new high or critical findings
- Signature verification was attempted where supported
- Any failure was investigated before committing
Sources & methodology
These references were selected by the editorial team. Verify examples against current documentation and your project before using them.
- npm-audit | npm DocsAdded: 2026-11-22
- Dependency graph - GitHub DocsAdded: 2026-11-22
Turn the idea into reviewable work.
Bring your models, editor, terminal and browser together in Devura.
Get Devura


