PostToolUse hook that inspects an edited npm package-lock.json for supply-chain provenance risk rather than known CVEs — dependencies resolved from outside the public npm registry (git, alternate-registry, or insecure transports) and registry tarballs missing an integrity hash.
Runs after every Write, Edit, and MultiEdit and inspects only npm package-lock.json or npm-shrinkwrap.json content; for yarn.lock and pnpm-lock.yaml it prints a one-line reminder to run lockfile-lint., Read-only and advisory - it parses the lockfile JSON, never installs packages, runs npm, or makes a network call, and always exits 0., Uses the resolved-URL and integrity fields to flag provenance risk (sources outside the public registry, missing integrity); it does not assess known vulnerabilities, so pair it with an audit tool.
Privacy notes
Reads only the local lockfile from disk; it makes no network or registry calls., Prints dependency paths and their resolved URLs to local hook stderr; it writes no logs., Resolved URLs shown in output may include internal registry or git host names if your project depends on them.
Author
techforgeworks
Submitted by
techforgeworks
Claim status
unclaimed
Last verified
2026-06-04
Decision playbook
Review trust signals before you adopt
Signals are present but mixed. Use the checklist below to confirm the source and operational safety for your environment.
Compare context
Selected
0
Current score
78
Baseline
—
Delta
No baseline selected
No major trust-signal divergence detected in the current selection.
Source and provenance checks
Complete
Confirm ownership and provenance before trusting install instructions.
Source link availableRequired
Open the canonical repository and verify ownership.
Done
Source provenance statusRequired
Marked as source-backed.
Done
Metadata reviewed
Registry metadata indicates a reviewed listing.
Done
Safety and privacy checks
Complete
Validate risk disclosures before installation or API wiring.
Safety notes presentRequired
Review the listed safety guidance before running commands.
Done
Privacy notes presentRequired
Review data handling notes before connecting accounts or secrets.
Done
Trust level risk gateRequired
Trust level does not block evaluation.
Done
Package and install checks
Needs review
Check package metadata and artifact integrity signals.
Install payload available
Install or copy payload is available for review.
Done
Package verification flag
No package verification flag provided.
Pending
Checksum metadata
No checksum provided for downloaded artifact.
Pending
Compare-driven decision checks
Needs review
Use compare context to validate trade-offs before adoption.
Compare tray has multiple entries
Add at least one more entry to compare trust differences.
Current risk score 16/100. Use staged verification before broader rollout.
Risk 16
Pre-adoption checks
Validate source and review signals before any execution.
Confirm source provenanceRequired
Source URL/provenance metadata is present.
Done
Confirm metadata review state
Listing has review metadata.
Done
Verify install payload
Install/config payload exists and can be inspected.
Done
Security checks
Confirm safety, privacy, and package integrity signals.
Review safety notesRequired
Safety notes are present.
Done
Review privacy notesRequired
Privacy notes are present.
Done
Verify package integrity metadata
No package verification/checksum metadata.
Pending
Rollout
Adopt in controlled steps based on the selected plan.
Run in isolated sandbox firstRequired
Use a constrained sandbox and observe behavior across multiple tasks.
Pending
Roll out graduallyRequired
Roll out to a small cohort before wider usage.
Pending
Set monitoring and fallback
Define rollback path and monitor errors after adoption.
Pending
Evidence readiness
Evidence readiness matrix · balanced
Required evidence gates are covered (5/6 signals complete).
Risk 15
Source provenance
Present
Source repository/provenance is listed.
Required in this preset
Metadata review
Present
Review metadata is present.
Required in this preset
Safety notes
Present
Safety notes are present.
Required in this preset
Privacy notes
Present
Privacy notes are present.
Optional in this preset
Package integrity
Missing
Package integrity metadata is missing.
Optional in this preset
Install payload
Present
Install payload is available.
Required in this preset
Required evidence gates are covered for this preset.
Decision timeline
Decision timeline · balanced
5/6 steps complete with no blocking gaps for this preset.
Risk 14
triage
Confirm source provenanceRequired
Source/provenance metadata is available.
Done
triage
Check metadata review statusRequired
Review metadata is available.
Done
verify
Review safety notesRequired
Safety notes are available.
Done
verify
Review privacy notes
Privacy notes are available.
Done
verify
Validate package integrity metadata
Package integrity metadata is missing.
Pending
rollout
Verify install payload and commandsRequired
Install payload is available.
Done
No required blockers for this timeline preset.
Prerequisite readiness
Prerequisite readiness
2 prerequisites to line up before setup.
0/2 ready
Install & runtime1General1
Safety & privacy surface
Safety & privacy surface
3 safety and 3 privacy notes across 3 risk areas. Review closely: network access.
3 areas
SafetyLocal filesRuns after every Write, Edit, and MultiEdit and inspects only npm package-lock.json or npm-shrinkwrap.json content; for yarn.lock and pnpm-lock.yaml it prints a one-line reminder to run lockfile-lint.
SafetyNetwork accessRead-only and advisory - it parses the lockfile JSON, never installs packages, runs npm, or makes a network call, and always exits 0.
SafetyGeneralUses the resolved-URL and integrity fields to flag provenance risk (sources outside the public registry, missing integrity); it does not assess known vulnerabilities, so pair it with an audit tool.
PrivacyNetwork accessReads only the local lockfile from disk; it makes no network or registry calls.
PrivacyLocal filesPrints dependency paths and their resolved URLs to local hook stderr; it writes no logs.
PrivacyGeneralResolved URLs shown in output may include internal registry or git host names if your project depends on them.
Safety notes
Runs after every Write, Edit, and MultiEdit and inspects only npm package-lock.json or npm-shrinkwrap.json content; for yarn.lock and pnpm-lock.yaml it prints a one-line reminder to run lockfile-lint.
Read-only and advisory - it parses the lockfile JSON, never installs packages, runs npm, or makes a network call, and always exits 0.
Uses the resolved-URL and integrity fields to flag provenance risk (sources outside the public registry, missing integrity); it does not assess known vulnerabilities, so pair it with an audit tool.
Privacy notes
Reads only the local lockfile from disk; it makes no network or registry calls.
Prints dependency paths and their resolved URLs to local hook stderr; it writes no logs.
Resolved URLs shown in output may include internal registry or git host names if your project depends on them.
Prerequisites
Claude Code CLI with hooks enabled.
bash and jq on PATH; the hook fails open and stays silent when jq is missing.
Schema details
Install type
cli
Troubleshooting
No
Source repository stats
Scope
Source repo
Runtime and command metadata
Trigger
PostToolUse
Script language
bash
Script body
#!/usr/bin/env bash
set -u
# Claude Code PostToolUse hook. Inspects an edited npm package-lock.json for
# supply-chain provenance risk (the lockfile-lint check set): dependencies
# resolved from outside the public npm registry and registry tarballs missing
# an integrity hash. Advisory only - it always exits 0, never installs or runs
# anything - and fails open when jq is unavailable.
command -v jq >/dev/null 2>&1 || exit 0
INPUT=$(cat)
FILE=$(printf '%s' "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // ""')
case "$FILE" in
*package-lock.json|*npm-shrinkwrap.json) : ;;
*yarn.lock|*pnpm-lock.yaml)
printf -v SAFE_FILE '%q' "$FILE"
echo "Lockfile changed - run 'npx lockfile-lint --path $SAFE_FILE --validate-https --validate-integrity' to check resolved hosts and integrity." >&2
exit 0 ;;
*) exit 0 ;;
esac
[ -f "$FILE" ] || exit 0
# npm v2/v3 lockfiles use the .packages map; older formats are skipped.
jq -e 'has("packages")' "$FILE" >/dev/null 2>&1 || exit 0
found=0
sanitize_output() {
LC_ALL=C tr -d '\000-\010\013-\037\177'
}
report() {
local lines
lines=$(jq -r "$2" "$FILE" 2>/dev/null | sanitize_output | sed '/^$/d' | head -10)
if [ -n "$lines" ]; then
echo "$1" >&2
printf '%s\n' "$lines" | while IFS= read -r l; do
[ -n "$l" ] && printf ' - %s\n' "$l" >&2
done
found=1
fi
}
# Anything whose resolved URL is not an https public-registry tarball is a
# provenance signal: git sources, alternate registries, and insecure
# transports all fail this test.
report "Dependencies resolved from outside the public npm registry (supply-chain risk):" \
'def clean: gsub("[\u0000-\u001F\u007F]"; ""); .packages | to_entries[] | select(.value.resolved) | select(.value.resolved | test("^https://registry\\.npmjs\\.org/") | not) | "\(.key | clean): \(.value.resolved | clean)"'
report "Registry tarballs missing an integrity hash:" \
'def clean: gsub("[\u0000-\u001F\u007F]"; ""); .packages | to_entries[] | select(.value.resolved) | select(.value.resolved | test("^https://registry\\.npmjs\\.org/")) | select((.value.integrity // "") == "") | (.key | clean)'
if [ "$found" -ne 0 ]; then
echo "Confirm these sources are expected; run lockfile-lint for the full check set and an allowlist." >&2
fi
exit 0
Inspects an edited package-lock.json for supply-chain provenance risk — where a dependency came from — rather than known CVEs.
Detection mirrors the lockfile-lint check set: dependencies resolved from outside the public npm registry (git sources, alternate registries, or insecure transports) and registry tarballs missing an integrity hash.
Advisory only — it always exits 0 and never installs, runs, or fetches anything.
Fails open and makes no network calls; it reads only the local lockfile.
For yarn.lock / pnpm-lock.yaml it prints a one-line reminder to run lockfile-lint, since those formats are not JSON.
How it works
On PostToolUse, the hook checks whether the edited file is an npm lockfile. For package-lock.json (npm v2/v3, the .packages map), it scans each resolved dependency and reports any entry whose resolved URL is not an https public-registry tarball, or that lacks an integrity hash. Findings go to stderr with a reminder to confirm the sources and run lockfile-lint for the full check set.
Why provenance, not CVEs
CVE scanners answer "does this version have a known vulnerability?". This hook answers a different question: "did this dependency come from where I expect?" A swapped registry, a git URL pointing at a fork, an insecure transport, or a missing integrity hash are tampering and dependency-confusion signals that a CVE scan will not catch.
Use cases
Catch a dependency-confusion or registry-swap edit the moment the lockfile changes.
Enforce "public registry + integrity only" provenance locally, ahead of a full lockfile-lint run in CI.
Surface a stray git or alternate-registry dependency introduced during an agentic edit.
Installation
Create the hooks directory: mkdir -p .claude/hooks
Create the hook file: touch .claude/hooks/lockfile-provenance-checker.sh
Paste the script body into that file and make it executable: chmod +x .claude/hooks/lockfile-provenance-checker.sh
Add the configuration below to .claude/settings.json (project) or ~/.claude/settings.json (user).
Targets npm v2/v3 package-lock.json and npm-shrinkwrap.json; for yarn.lock and pnpm-lock.yaml it defers to lockfile-lint.
Non-registry sources can be legitimate (a deliberate git dependency or a private registry); treat findings as items to confirm against an allowlist, not automatic failures.
Show that Lockfile Provenance Checker - Claude Code Hook is listed on HeyClaude. Paste this Markdown into your README — it renders the badge and links back to this page.
[](https://heyclau.de/entry/hooks/lockfile-provenance-checker)
How it compares
Lockfile Provenance Checker - Claude Code Hook side by side with 3 alternatives on trust, install, platform support, and disclosed safety notes — all from reviewed registry metadata.
2 trust signals differ across this comparison (Source provenance, Submitter).
PostToolUse hook that inspects an edited npm package-lock.json for supply-chain provenance risk rather than known CVEs — dependencies resolved from outside the public npm registry (git, alternate-registry, or insecure transports) and registry tarballs missing an integrity hash.
Automatically checks for outdated dependencies and suggests updates with security analysis. This PostToolUse hook triggers when dependency manifest files (package.json, requirements.txt, Gemfile, go.mod, Cargo.toml, pyproject.toml) are modified, providing real-time dependency health monitoring.
✓Runs after every Write, Edit, and MultiEdit and inspects only npm package-lock.json or npm-shrinkwrap.json content; for yarn.lock and pnpm-lock.yaml it prints a one-line reminder to run lockfile-lint.
Read-only and advisory - it parses the lockfile JSON, never installs packages, runs npm, or makes a network call, and always exits 0.
Uses the resolved-URL and integrity fields to flag provenance risk (sources outside the public registry, missing integrity); it does not assess known vulnerabilities, so pair it with an audit tool.
✓Read-only advisory hook; it does not block writes unless you wrap it with strict exit handling.
Does not substitute for npm audit, OSV scans, or CI dependency review.
✓Runs automatically on its configured Claude Code hook event and executes shell logic that can read, modify, or delete files in your project (and may run builds, installs, or network calls); review the script and scope it to expected paths before enabling.
✓Runs after Write, Edit, and MultiEdit and inspects only the edited file path to decide whether a dependency manifest or lockfile changed.
Install this project-relative command only in the trusted project's `.claude/settings.json`; user/global hooks must point to a trusted absolute path outside project directories.
Default mode is advisory, prints the ORT command to run, and always exits 0 without reading dependency contents, creating reports, or contacting registries.
When `ORT_LICENSE_HOOK_RUN=1` is set, it runs `ort analyze` in the project root and writes reports under `.claude/ort-license-checks/` by default.
An opted-in ORT run may invoke package managers, inspect dependency graphs, read project configuration, fetch package metadata, and take several minutes on large repositories.
Strict mode exits 2 only when `ORT_LICENSE_HOOK_STRICT=1` is also set and the opted-in ORT analysis fails.
Privacy notes
✓Reads only the local lockfile from disk; it makes no network or registry calls.
Prints dependency paths and their resolved URLs to local hook stderr; it writes no logs.
Resolved URLs shown in output may include internal registry or git host names if your project depends on them.
✓Lockfile paths and registry hostnames are printed locally to stderr for the active session.
✓Receives Claude Code hook input (session metadata, file paths, and tool output) and reads local project files; review what the script logs or forwards to external services and keep credentials out of its output.
✓Default advisory mode prints only the changed dependency file path and the suggested local ORT command.
Opted-in ORT runs can record dependency names, versions, package metadata, source URLs, license findings, project paths, package-manager output, and configuration details in local report files.
Package managers or ORT integrations may contact configured package registries, VCS hosts, or metadata services during analysis.
Review generated reports before sharing them because internal package names, private registry hostnames, source URLs, and license-policy exceptions can be sensitive.
Prerequisites
Claude Code CLI with hooks enabled.
bash and jq on PATH; the hook fails open and stays silent when jq is missing.
jq available when reviewing npm package-lock.json resolved URLs.
Team policy for allowed npm registries and lockfile update requirements.
— none listed
Claude Code CLI with hooks enabled.
bash available on PATH; jq is recommended for parsing hook input.
OSS Review Toolkit installed and available as `ort` only when `ORT_LICENSE_HOOK_RUN=1` is used.
Java, package managers, and any project-specific ORT requirements prepared before running a real ORT analysis.