Installation

Install as Agent Plugin Recommended
copilot plugin marketplace add samueltauil/skills-hub
copilot plugin install check-npm@skills-hub

Works with GitHub Copilot CLI and VS Code (enable chat.plugins.enabled). Plugin check-npm v1.0.0 follows the Agent Plugins spec.

Install with the gh extension
gh skills-hub install check-npm

Don't have the extension? Run gh extension install samueltauil/skills-hub first.

Download and extract to your repository:

.github/skills/check-npm/

Extract the ZIP to .github/skills/ in your repo. The folder name must match check-npm for Copilot to auto-discover it.

Skill Files (4)

SKILL.md 5.1 KB
---
name: check-npm
license: Apache-2.0
disable-model-invocation: false
description: >-
  Audit a JavaScript/TypeScript repo's npm, yarn, or pnpm configuration for
  supply-chain hardening: tool version, lifecycle scripts, unsafe dependency
  protocols, and minimum release age ≥3 days. Use when the user invokes
  /check-npm or asks to audit package manager security, lifecycle scripts, git
  dependencies, ignore-scripts, min-release-age, allow-git,
  approvedGitRepositories, strictDepBuilds, or blockExoticSubdeps in a Grafana
  plugin or JS/TS project.
---

# npm / yarn / pnpm supply-chain audit

Read-only audit of the workspace root. Do not modify any files.

## 0. Detect package manager

```bash
test -f package.json || { echo "STOP: no package.json at workspace root"; exit 1; }
jq -r '.packageManager // "unset"' package.json
ls -1 yarn.lock package-lock.json pnpm-lock.yaml 2>/dev/null || true
```

If no `package.json`, stop. Priority: `packageManager` → lockfile → default npm.

## 1. Tool version

```bash
npm --version    # required ≥ 11.15.0
yarn --version   # required ≥ 4.14.0
pnpm --version   # required ≥ 11.0.0
```

Use semver comparison. Verify pinned `packageManager` meets threshold.

| Manager | Minimum |
|---------|---------|
| npm | 11.15.0 |
| yarn | 4.14.0 |
| pnpm | 11.0.0 |

## 2. Lifecycle scripts disabled

```bash
grep -E '^ignore-scripts=' .npmrc 2>/dev/null
grep -E 'enableScripts:' .yarnrc.yml 2>/dev/null
grep -E 'strictDepBuilds:|dangerouslyAllowAllBuilds:|allowBuilds:' pnpm-workspace.yaml 2>/dev/null
```

| Manager | PASS | FAIL |
|---------|------|------|
| npm | `.npmrc` has `ignore-scripts=true` | missing or `false` |
| yarn | `enableScripts: false` or key absent | `enableScripts: true` |
| pnpm ≥ 11 | `strictDepBuilds` unset/`true`, `dangerouslyAllowAllBuilds` unset/`false`, and `allowBuilds` unset/`[]` | `strictDepBuilds: false`, `dangerouslyAllowAllBuilds: true`, or `allowBuilds` non-empty |
| pnpm 10 | `.npmrc` `ignore-scripts=true` OR `strictDepBuilds: true` | neither |

pnpm 11+ ignores script settings in `.npmrc` and `package.json#pnpm`. pnpm 10 / yarn edge cases: [references/managers.md](references/managers.md).

## 3. Unsafe dependency protocols

Registry:

```bash
grep -E '^allow-git=' .npmrc 2>/dev/null
grep -E 'approvedGitRepositories:' .yarnrc.yml 2>/dev/null
grep -E 'blockExoticSubdeps:' pnpm-workspace.yaml 2>/dev/null
```

Scan workspace `package.json` files (`dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`). Prefer workspace-member discovery (pnpm-workspace.yaml / root workspaces / lerna / rush) per [references/protocols.md](references/protocols.md), then scan only those manifests. Fallback (may overmatch non-workspace manifests):

    find . -name package.json -not -path '*/node_modules/*'

**Safe values only:** semver range, `workspace:`, `patch:`, `npm:` alias to semver. Flag everything else (git URLs, tarballs, `user/repo` shorthand, `file:`, `link:`, `exec:`, …) as `path → name → value (protocol)`.

| Manager | PASS | FAIL |
|---------|------|------|
| npm | `allow-git=none` or `root` | missing or `all` |
| yarn | `approvedGitRepositories: []` or grafana-scoped list, or omitted with policy comment + clean scan | unsafe entries or broad allow-list |
| pnpm ≥ 11 | `blockExoticSubdeps` unset/`true` | `false` |
| pnpm 10.x | `blockExoticSubdeps: true` | unset (default `false`) or `false` |

Protocol detection order and yarn posture details: [references/protocols.md](references/protocols.md).

## 4. Minimum release age ≥ 3 days

3 days = 4320 minutes. npm uses **days**; yarn and pnpm use **minutes**.

```bash
grep -E '^min(imum)?-release-age=' .npmrc 2>/dev/null
grep -E 'npmMinimalAgeGate:' .yarnrc.yml 2>/dev/null
grep -E 'minimumReleaseAge:|minimumReleaseAgeStrict:' pnpm-workspace.yaml 2>/dev/null
```

| Manager | PASS | FAIL |
|---------|------|------|
| npm | `min-release-age` ≥ `3` | missing |
| yarn | `npmMinimalAgeGate` ≥ 4320 min | missing or below |
| pnpm ≥ 11 | `minimumReleaseAge` ≥ `4320` | unset (default `1440`) or below |
| pnpm 10 | `minimum-release-age` / `minimumReleaseAge` ≥ `4320` | missing |

Flag `minimumReleaseAgeStrict: false` on pnpm 11.

## 5. Report

| # | Check | Status | Detail |
|---|---|---|---|
| 0 | Package manager | (npm / yarn / pnpm) | version: x.y.z (pinned: y.y.y if set) |
| 1 | Tool version ≥ threshold | PASS / FAIL | `actual` vs `required` |
| 2 | Scripts disabled | PASS / FAIL | config line or "missing" |
| 3 | Unsafe dep protocols | PASS / FAIL | registry state + flagged entries |
| 4 | Min release age ≥ 3 days | PASS / FAIL | config + value |

Use `PASS` / `FAIL` only — no emojis.

For each FAIL, one paste-ready fix:

```ini
# npm — .npmrc
ignore-scripts=true
allow-git=none
min-release-age=3
```

```yaml
# pnpm 11 — pnpm-workspace.yaml
strictDepBuilds: true
dangerouslyAllowAllBuilds: false
allowBuilds: []
minimumReleaseAge: 4320
blockExoticSubdeps: true
```

```yaml
# yarn — .yarnrc.yml
npmMinimalAgeGate: 4320
```

More fixes (tool upgrades, yarn git allow-list, pnpm 10): [references/fix-snippets.md](references/fix-snippets.md).

If all PASS: "All checks passed." and stop.
references/
fix-snippets.md 1.1 KB
# Fix snippets (one per FAIL)

## Tool version

```bash
npm install -g npm@11.15.0
```

```bash
yarn set version 4.14.0
```

```bash
npm install -g pnpm@11.0.0
```

## Lifecycle scripts

`.npmrc`:

```
ignore-scripts=true
```

`pnpm-workspace.yaml` (pnpm 11 — do not use `.npmrc` for this):

```yaml
strictDepBuilds: true
dangerouslyAllowAllBuilds: false
allowBuilds: []
```

```bash
yarn config set enableScripts false
```

## Unsafe dependency protocols

`.npmrc`:

```
allow-git=none
```

`.yarnrc.yml` (block all git deps):

```yaml
approvedGitRepositories: []
```

`.yarnrc.yml` (Grafana internal repos):

```yaml
approvedGitRepositories:
  - "https://github.com/grafana/*"
  - "ssh://git@github.com/grafana/*"
  - "git@github.com:grafana/*"
```

`pnpm-workspace.yaml`:

```yaml
blockExoticSubdeps: true
```

## Minimum release age

`.npmrc` (days):

```
min-release-age=3
```

`.yarnrc.yml`:

```yaml
npmMinimalAgeGate: 4320  # or "3d"
```

`pnpm-workspace.yaml` (minutes):

```yaml
minimumReleaseAge: 4320
```

`.npmrc` (pnpm 10, minutes):

```
minimum-release-age=4320
```
managers.md 3.4 KB
# Per-manager pass/fail criteria

## Tool version thresholds

| Manager | Command | Minimum | Notes |
|---------|---------|---------|-------|
| npm | `npm --version` | 11.15.0 | `allow-git` in 11.15; `min-release-age` in 11.10 |
| yarn | `yarn --version` | 4.14.0 | `approvedGitRepositories` in 4.14 |
| pnpm | `pnpm --version` | 11.0.0 | pnpm 11 defaults `minimumReleaseAge`, `strictDepBuilds`, `blockExoticSubdeps` on |

If `packageManager` is pinned in root `package.json`, verify the pin meets the threshold. Use semver comparison.

## Lifecycle scripts

| Manager | Read | PASS | FAIL |
|---------|------|------|------|
| yarn | `.yarnrc.yml` | `enableScripts: false`, or key absent (yarn 4 default `false`) | `enableScripts: true` |
| npm | `.npmrc` | `ignore-scripts=true` | missing or `ignore-scripts=false` |
| pnpm ≥ 11 | `pnpm-workspace.yaml` | `strictDepBuilds` unset/`true` AND `dangerouslyAllowAllBuilds` unset/`false` AND `allowBuilds` unset/`[]` | `strictDepBuilds: false` or `dangerouslyAllowAllBuilds: true` or `allowBuilds` non-empty |
| pnpm 10.x | `.npmrc`, `pnpm-workspace.yaml`, `package.json#pnpm` | `.npmrc` has `ignore-scripts=true` OR `strictDepBuilds: true` | neither, or `ignore-scripts=false`, or `strictDepBuilds: false` |
| pnpm < 10 | `.npmrc` | `ignore-scripts=true` | otherwise |

pnpm 11+ ignores build-script settings in `package.json#pnpm` and non-auth `.npmrc` entries.

Detail column: if `allowBuilds` (pnpm 11) or `onlyBuiltDependencies` (pnpm 10) lists packages, list them (these are explicit build-script exemptions and should be treated as a FAIL per the criteria above).

## Unsafe dependency protocols

| Manager | Read | PASS | FAIL |
|---------|------|------|------|
| npm | `.npmrc` | `allow-git=none` or `allow-git=root` | missing, `allow-git=all` |
| yarn | `.yarnrc.yml` + `package.json` scan | Posture A: `approvedGitRepositories: []` or all entries scoped to `grafana` org (three URL forms). Posture B: key omitted with explicit "do not add" comment AND scan clean | Offending `approvedGitRepositories` entries, or missing key + no policy comment + scan finds unsafe deps |
| pnpm ≥ 11 | `pnpm-workspace.yaml` | `blockExoticSubdeps` unset/`true` | `blockExoticSubdeps: false` |
| pnpm 10.x | `pnpm-workspace.yaml`, `package.json#pnpm` | `blockExoticSubdeps: true` | unset (default `false`) or `false` |

npm < 11.15.0: `allow-git` in `.npmrc` is not enforced — call out in detail.

Grafana yarn allow-list URL forms (same repos, different patterns):

- `https://github.com/grafana/*`
- `ssh://git@github.com/grafana/*`
- `git@github.com:grafana/*`

## Minimum release age

3 days = **4320 minutes**. npm uses **days** (integer); yarn and pnpm use **minutes** (integer).

| Manager | Read | PASS | FAIL |
|---------|------|------|------|
| npm | `.npmrc` | `min-release-age` ≥ `3` | missing (default off) |
| yarn | `.yarnrc.yml` | `npmMinimalAgeGate` ≥ 4320 min (accepts `4320`, `"3d"`, `"72h"`) | missing or below threshold (default `0`) |
| pnpm ≥ 11 | `pnpm-workspace.yaml` | `minimumReleaseAge` ≥ `4320` | unset (default `1440`) or below; also flag `minimumReleaseAgeStrict: false` |
| pnpm 10.x | `.npmrc`, `pnpm-workspace.yaml`, `package.json#pnpm` | `minimum-release-age` / `minimumReleaseAge` ≥ `4320` | otherwise (default `0`) |
| pnpm < 10 | — | — | setting unavailable; recommend upgrade |

Detail column: list `npmPreapprovedPackages` (yarn) or `allowBuilds` exemptions when set.
protocols.md 1.0 KB
# Dependency protocol allow-list

## Safe protocols

- Valid **semver range** (`^1.2.3`, `~1.0`, `1.x`, `*`, exact `1.2.3`)
- `workspace:` (`workspace:^`, `workspace:*`)
- `patch:` (`patch:left-pad@1.0.0#~/patches/left-pad.patch`)
- `npm:` alias resolving to semver (`npm:lodash@^4`)

Everything else is unsafe — including yarn bare GitHub shorthand `user/repo` or `user/repo#commit`.

## Workspace scan

Scan root `package.json` and every workspace member. Discover members from `pnpm-workspace.yaml`, npm/yarn `workspaces`, `lerna.json`, or `rush.json`.

Sections: `dependencies`, `devDependencies`, `optionalDependencies`, `peerDependencies`.

Flag format:

```
path/to/package.json → name → value (protocol)
```

## Detection order

1. Explicit `<scheme>:` prefix (`git:`, `git+https:`, `github:`, `link:`, `file:`, `exec:`, `jsr:`, …)
2. `git@…` SSH URLs
3. `http://` / `https://` tarball URLs
4. Bare `user/repo` or `user/repo#…` (yarn GitHub shorthand)
5. Not matching 1–4 and not valid semver → `(unknown)`

Full yarn protocol list: <https://yarnpkg.com/protocols>

License (Apache-2.0)

View full license text
Licensed under the Apache License, Version 2.0. See https://github.com/grafana/skills/blob/main/LICENSE