Hoc npm install scripts

From openreachtech/hora-skills-ort-core · View interactive version

Hoc npm install scripts is an AI agent skill from the GitHub repository openreachtech/hora-skills-ort-core. How to handle the install scripts npm would run while installing dependencies. Use this skill when an install reports scripts not yet covered by `allowScripts`, when deciding whether a dependency's install script may be denied, when turning the gate on in a project, or when judging whether an upgrad

How to use this skill

Skill file

npm Install Scripts

A package's install script runs on the machine doing the install, with that machine's

permissions, before anybody has looked at it. npm can gate this: an install script runs

only for a package the project has approved, recorded in allowScripts. This skill covers

the gate — how it is switched on, how each package is decided, and the order those two

have to happen in.

The gate is the defence, not the registry

A version found to be malicious does not leave the registry. A publish older than the

grace period is not removed, because removing it breaks every dependent. What gets applied

instead is a deprecation notice, and a deprecation notice **prints a warning and installs

anyway**.

Measured on a widely used package whose 1.x line carried a compromise, years after the

fact: every version inside the advisory's range still had its tarball, none had been

unpublished, and a dist-tag still pointed into the affected line.

where dangerous versions expire.

install script is what hands over the machine. The gate governs the second, and only the

second is the project's to govern.

after somebody notices; a package that was never approved was never running, notice or no

notice.

Deny is the default

An install script is denied unless there is a demonstrated need for it. Denial is the

resting state. Approval is the exception that has to earn itself.

its lint, its tests, whatever it runs to know it works. If those pass, the denial stands.

platform package, the script has nothing left to do: check that the platform package's

.node file is present, that no build directory was produced, and that the module loads

when required.

by something the project needs are all true of packages whose install scripts do nothing

this project uses. The question is not whether the package is trustworthy; it is whether

the script is needed, and only running without it answers that.

Turn the list into a recommendation, package by package

npm reports the scripts it did not cover as a list of names:

npm warn install-scripts 2 packages have install scripts not yet covered by allowScripts:
npm warn install-scripts   alpha-package@2.3.3 (install: (install scripts present))
npm warn install-scripts   beta-package@1.12.2 (install: (install scripts present))
npm warn install-scripts
npm warn install-scripts Run `npm install-scripts ls` to review, or `npm install-scripts approve <pkg>` to allow.

Names alone are not a decision. **Turn the list into a per-package recommendation with its

reason attached** — denied because the checks pass without it, approved because this

specifically failed. Whoever reads the commit should not have to derive it again.

Do not keep a second copy of the list anywhere else, this skill included: a list that is

not the one being enforced goes stale with nothing to reveal it.

in the boilerplate's own package.json, already recorded, so a new project starts gated.

An approval records a version; a denial records a name

approve writes <pkg>@<version>, pinned to what is installed. deny writes the bare name.

being replaced. A denial names no version, so it is decided on its own and in any order.

`--dry-run` answers "does this upgrade add a script?"

Before committing to an upgrade, the question is whether it introduces an install script

not already covered. A dry-run install answers exactly that and changes nothing.

npm install <pkg>@<version> --dry-run

Measured: no node_modules is created, package.json and package-lock.json are

untouched, and no script runs — while the warning listing uncovered scripts is still

printed.

set for a fresh tree, not the delta against the tree that exists. Read it as "the scripts

this dependency set has", and compare that against what is already covered.

Configure the gate first; install afterwards

The settings go in before the install they govern. Not the other way round.

  1. Turn on strict-allow-scripts, which upgrades the warning into a stop. Do not

install.

  1. Record npm install-scripts deny <pkg> for each package, against the tree already

present.

  1. Install once, with the gate in place.

tree, so with a tree present it succeeds even under the strict setting. The two appear to

deadlock only in a directory that has never been installed — and a project in that state

has nothing to gate yet.

conclusion is wrong. Where a measurement about ordering is taken decides its answer;

take it in a tree shaped like the one the rule will be applied to.

setting, then the denials — with no lockfile commit between them.

commit.** The order is the raise convention's: the lockfile commit comes last, whatever the

commits before it touched, so nobody has to know whether recording a denial moves the

lockfile.

install into a single run at the end of a release.

Write `allowScripts` with the install-scripts command, never with `npm pkg`

approve and deny edit package.json in place, and **the change they make is the

allowScripts lines and nothing else.** Read the diff before staging it: deny has been seen

to respell an empty object written across two lines as {}, and a line like that is not part

of the change, so only the allowScripts lines are staged.

**npm pkg set and npm pkg delete go further: they silently drop the dependency fields that

are empty**, so one line added to allowScripts arrives as a diff that also deletes lines

nobody asked it to.

`strict-allow-scripts` is a line of `.npmrc`

belongs to /hoc-npm-npmrc. What the setting does, and that it goes in before the install,

are this skill's.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.