Generated banner for Audit And Reduce Dependencies
Generated logo for Audit And Reduce Dependencies

Audit And Reduce Dependencies

Grafana LabsOfficialPublished by Grafana Labs

  • Skill
  • Workflow
  • Software development
  • Apache-2.0
  • Low risk

From the author

Reduces JavaScript dependency footprint with pnpm while preserving lockfile, workspace layout, and dependency range style. Runs /check-npm first, then removes unused deps, dedupes versions, ranks transitive closure, and reports Keep/Replace/Remove triage. Use when cleaning up pnpm dependencies, reducing lockfile size, or shrinking node_modules in Grafana plugins; not for Go modules or full GitHub Actions workflow audits.
— the description by Grafana Labs

AutoGineer summary

Written by AutoGineer from the skill’s own files, not by the author

This skill provides a rigorous, step-by-step procedure to audit and shrink the dependency footprint of JavaScript projects using pnpm. It emphasizes maintaining existing workspace layouts, lockfile integrity, and dependency range styles while identifying unused dependencies, deduplicating versions, and ranking transitive closures. The process includes a mandatory hardening gate via /check-npm, strict adherence to supply-chain security practices like freshness checks, and a structured triage system for dependency management.

What it does

  • Performs a mandatory hardening check using /check-npm before any modifications.
  • Identifies and removes unused direct dependencies across monorepo workspaces.
  • Deduplicates direct dependency versions to ensure consistency.
  • Ranks dependencies by their transitive closure impact to identify optimization candidates.
  • Provides a structured triage framework for keeping, replacing, or removing dependencies.
  • Enforces strict supply-chain safety, including freshness checks and script-blocking policies.

When to use it

  • When cleaning up pnpm dependencies in a JavaScript or TypeScript project.
  • When aiming to reduce lockfile size or shrink node_modules footprint.
  • When optimizing Grafana plugins or similar modular JavaScript architectures.
  • When performing a periodic dependency audit to improve project maintainability.

Advantages

  • Ensures dependency changes are measurable and evidence-based.
  • Prioritizes project stability by requiring focused verification after every change.
  • Maintains supply-chain security through mandatory freshness checks and script-blocking.
  • Provides a clear, standardized reporting format for dependency triage decisions.
  • Prevents accidental breakage by requiring small, reviewable batches.

Usage examples

“Audit my pnpm dependencies and suggest removals for unused packages.”
The agent will run /check-npm, analyze the dependency tree, identify unused packages, and provide a triage report with proposed removals and measured impact.
“Help me reduce the size of my pnpm lockfile.”
The agent will rank dependencies by transitive closure, identify candidates for inlining or removal, and guide you through safe deduplication and cleanup steps.

Install

  1. Download the skill as a ZIP:

    https://autogineer.com/agent-skills/grafana/audit-and-reduce-dependencies/download
  2. Unzip it into the cross-client skills folder of your project:

    mkdir -p .agents/skills && unzip audit-and-reduce-dependencies.zip -d .agents/skills

Documentation by Grafana Labs

Audit and reduce dependencies

Reduce JavaScript dependency footprint. Use pnpm only. Preserve the lockfile, workspace layout, and dependency range style unless there is a concrete reason to change them.

For GitHub Actions workflow triage (action choice, permissions, pinning), use a dedicated workflow audit — not the reporting format below (workflow file + step only when the finding is pnpm install policy).

Workflow

  1. Hardening gate: run /check-npm (read-only). See check-npm.

  2. Establish the baseline.

  3. Remove unused direct dependencies.

  4. Deduplicate direct dependency versions in monorepos.

  5. Rank direct dependencies by transitive lockfile closure.

  6. Use closure data to find low-risk minor/patch upgrades.

  7. Use closure data to find trivial dependencies worth inlining.

  8. Check e18e recommendations for replacements/removals.

  9. Reinstall, verify, and report measured impact.

Step 0: Hardening gate (/check-npm)

Run /check-npm before mutating manifests or lockfiles.

  • If any check FAILs: report the table and fix snippets; do not weaken pnpm-workspace.yaml, .npmrc, CI install flags, or Renovate age gates during cleanup.

  • Do not paste full hardening config into this workflow — /check-npm owns version thresholds, script policy, git-dep protocols, and min release age.

  • If the user only asked for hardening (not reduction), stop after /check-npm unless they also want cleanup.

pnpm 11+: script and release-age policy live in pnpm-workspace.yaml, not .npmrc or package.json#pnpm (pnpm 11 no longer reads the package.json#pnpm field). Verify each key against the installed pnpm major before suggesting config. Never add unsupported keys. Do not lower an existing minimumReleaseAge (or org equivalent) during cleanup.

Dependency triage

For each non-trivial direct dependency (especially after Steps 4–7), assign one label:

LabelMeaning
KeepRequired; worthwhile transitive cost; well maintained.
Replace-with-BetterRequired; better-maintained or safer alternative exists.
Replace-with-InternalRequired; external risk warrants internal implementation.
RemoveCan drop or inline (Step 6).
Needs-user-reviewAmbiguous usage, policy tradeoff, or change needing human verification.

Replacements and new direct deps

  • No new direct dependencies (including swaps) without explicit user approval.

  • Prefer Remove (inline/native APIs) over Replace-with-Better when equivalent.

  • For Replace-with-Better: state why (maintenance, security, smaller tree); prefer actively maintained, widely adopted packages from trusted maintainers.

  • Respect repo minimumReleaseAge / Renovate gates; command-level 72h freshness is a floor, not permission to bypass stricter config.

pnpm & supply-chain

Confirm the repo uses pnpm: pnpm-lock.yaml, pnpm-workspace.yaml, and/or packageManager / devEngines.packageManager.name set to pnpm in root package.json. If not on pnpm, stop — do not migrate package managers as part of cleanup.

Respect repo install policy when present (e.g. pnpm install --frozen-lockfile --ignore-scripts).

ActionCommand
Install/update lockfilepnpm install --ignore-scripts (+ repo flags, e.g. --frozen-lockfile)
Remove direct dependencypnpm remove <pkg> --ignore-scripts
Add/update direct dependencypnpm add <pkg>@<version> --ignore-scripts
Explain dependencypnpm why <pkg>
Dedupe lockfilepnpm dedupe (then pnpm install --ignore-scripts if lockfile changed)
Outdated / version infopnpm outdated <pkg>
One-off toolspnpm --config.ignore-scripts=true dlx <pkg>@<version> <args...> (pin version; prefer pnpm exec when in lockfile)

Lifecycle scripts: Always --ignore-scripts on pnpm install, pnpm add, and pnpm remove unless the user explicitly writes allow scripts in the same message (state which scripts would run and the risk). For pnpm dlx, dlx does not accept --ignore-scripts directly — use pnpm --config.ignore-scripts=true dlx (flags after dlx are forwarded to the executed binary). If a dependency legitimately needs a build script (native modules, etc.), finish without scripts, then ask whether to run a specific manual rebuild (e.g. pnpm rebuild <pkg>).

Freshness check (≥ 72 hours) — required before any command that adds or upgrades a named package version (pnpm add, pnpm dlx with new/upgraded direct version). Not required for plain pnpm install / pnpm remove with no new package argument.

For each directly named package:

  1. curl -s https://registry.npmjs.org/<package-name>

  2. Resolve version: pinned [email protected] → that version; range/latest/unspecified → dist-tags.latest

  3. Read time["<version>"]

  4. If published less than 72 hours ago → stop. Tell the user package, version, and exact age. Suggest an older known-good pin unless they write override freshness check.

  5. @grafana/* scoped packages are exempt from the freshness check; --ignore-scripts still applies.

After a failed freshness check, do not substitute a different version without user approval.

Safety rules

  • Work in small batches so lockfile diffs remain reviewable.

  • Never trust unused-dependency tools blindly; verify imports, config files, scripts, generated code hooks, framework conventions, plugin names, CLIs, and dynamic imports.

  • You may write scripting and parsing to verify package.json and lockfile dependency accounts.

  • Treat peerDependencies, optionalDependencies, package bin usage, test fixtures, and published package manifests as higher risk.

  • Do not remove or inline dependencies used for security, parsing, crypto, Unicode, URL handling, date/time, i18n, or platform compatibility unless the replacement is proven equivalent.

  • Do not switch package managers, delete pnpm-lock.yaml, or rewrite workspace structure as part of cleanup.

  • Treat pnpm dedupe as potentially behavior-changing; inspect lockfile diffs and run focused verification before keeping the result.

  • Measure before and after: direct dependency count, lockfile line count or entry count, package count, and estimated node_modules size when available.

Step 1: Baseline

Collect:

  • All package.json files and workspace boundaries (pnpm-workspace.yaml).

  • pnpm-lock.yaml, pnpm-workspace.yaml security settings (minimumReleaseAge, strictDepBuilds, blockExoticSubdeps, allowBuilds), and install policy in .npmrc / CI flags (e.g. --frozen-lockfile, --ignore-scripts).

  • Direct dependency names by manifest section: dependencies, devDependencies, peerDependencies, optionalDependencies.

  • Existing verification commands from scripts, CI, or repo docs.

  • CI spot-check (.github/workflows or equivalent): installs should use pnpm install --frozen-lockfile and script blocking consistent with workspace config. Flag workflows that regenerate lockfiles on every run.

  • Renovate / Dependabot (if present): note minimumReleaseAge for npm packages; do not reduce it during cleanup.

Record baseline metrics: git status --short, wc -l pnpm-lock.yaml. If node_modules is installed, estimate footprint with platform-appropriate tools. Lockfile reductions are the primary metric — do not depend on node_modules being present.

Step 2: Remove unused direct dependencies

Unsafe direct dependency protocols — scan all workspace package.json dependency sections. Flag values that are not: semver range, workspace:, patch:, or npm: alias to semver. Flag git: / github: / tarball URLs / user/repo shorthand / file: / link: / exec: / etc. (same allow-list as /check-npm). Do not remove flagged entries silently; report for a separate hardening PR unless the user asked to fix them.

Use a static analyzer as a starting point, not as proof (knip, depcheck, or repo-native tooling). Run with pinned pnpm --config.ignore-scripts=true dlx <tool>@<version> <args...> when not installed (freshness-check the pin first).

For each candidate:

  • Search code, configs, package scripts, build tooling, tests, and docs for the package name and known import paths.

  • Check whether required by a published package manifest, peer contract, plugin loader, CLI command, or dynamic require/import.

  • Remove only when no real usage remains.

  • Run pnpm install --ignore-scripts (+ repo flags) and focused verification.

If usage is only in a script or config, consider moving between dependencies and devDependencies instead of removing.

Step 3: Deduplicate monorepo direct versions

Look for the same direct dependency declared with multiple versions/ranges across package manifests. Use existing policy first: exact pins, caret ranges, catalog/protocol usage, workspace protocol, or central constraints.

  • Use syncpack list-mismatches or equivalent for discovery.

  • Standardize direct ranges when packages can share the same compatible version.

  • Prefer manifest-level consistency before adding pnpm.overrides.

  • Use pnpm.overrides only for transitive convergence or security fixes, and document why.

After deduping, run pnpm install --ignore-scripts (+ repo flags) and inspect manifest and lockfile diffs. Then consider pnpm dedupe — apply carefully; may change transitive resolution.

Step 4: Rank transitive lockfile closure

For each important direct dependency, estimate closure: transitive lockfile entries reachable from that dependency.

Report both:

  • Total closure: all packages reachable from the dependency.

  • Exclusive closure: packages that disappear if this dependency is removed and are not retained by other direct dependencies.

Prefer deterministic measurement:

  1. Save baseline lockfile metrics.

  2. Temporarily remove one direct dependency from the owning manifest.

  3. Run pnpm install --ignore-scripts (+ repo flags).

  4. Measure lockfile line/entry reduction and package count reduction.

  5. Revert the manifest and pnpm-lock.yaml (e.g., git checkout -- <manifest> pnpm-lock.yaml) before measuring the next dependency.

Use pnpm why <pkg> for large transitive packages. Rank by impact and risk, not just raw size.

Step 5: Find low-risk high-impact upgrades

Use closure rankings to target direct dependencies whose newer minor/patch versions reduce transitive dependencies.

For each candidate:

  • Check available non-major versions with pnpm outdated.

  • Review changelog/release notes for dependency tree changes.

  • Freshness-check the target version, then upgrade one dependency or tight cluster at a time (pnpm add <pkg>@<version> --ignore-scripts).

  • Run pnpm install --ignore-scripts (+ repo flags) and compare closure metrics.

  • Run focused tests and relevant build/typecheck commands.

Avoid major upgrades unless the user explicitly accepts the migration risk.

Step 6: Inline trivial usage

Use closure rankings to find direct dependencies with small, obvious usage but large transitive cost.

Inline only when all are true:

  • Usage is tiny and easy to fully characterize.

  • Equivalent code is shorter or clearer than retaining the dependency.

  • Behavior is covered by tests or can be covered with small characterization tests.

  • The dependency is not solving cross-platform, security, parsing, Unicode, locale, or spec-compliance edge cases.

Prefer native APIs over new replacement dependencies when the required behavior is simple.

Step 7: Apply e18e guidance

# Pin @e18e/cli@<version> after freshness check; disable scripts on the dlx install
pnpm --config.ignore-scripts=true dlx @e18e/cli@<version> analyze
pnpm --config.ignore-scripts=true dlx @e18e/cli@<version> migrate --dry-run

Also check https://e18e.dev/docs/replacements/. Treat recommendations as candidates, not mandates; verify bundle/runtime behavior and run tests. Map e18e swaps to Replace-with-Better only after user approval.

Reporting

Summarize outcomes with measured impact:

  • /check-npm result (PASS/FAIL summary; link fixes if FAIL).

  • Direct dependencies removed or moved.

  • Direct versions deduplicated.

  • Lockfile line/entry reduction.

  • Estimated package or node_modules reduction when available.

  • High-impact candidates deferred and why (including replacements awaiting approval).

  • Unsafe protocol / CI / Renovate findings from baseline (if any).

  • Verification commands run and results.

  • Supply-chain: versions freshness-checked (or exempted), --ignore-scripts on all installs/adds, --config.ignore-scripts=true on pnpm dlx.

Call out risk explicitly when a removal depends on static analysis rather than runtime coverage.

Reporting format

Use for dependency cleanup findings only — not GitHub Actions workflow triage.

For each finding:

  • Evidence: package name and version/range; manifest path and section; supporting signal (import site, pnpm why, knip/depcheck hit, closure measurement, /check-npm row, or workflow file + step only for pnpm install policy).

  • Decision: one of Dependency triage labels.

  • Proposed change: exact manifest/lockfile command or edit. If not applied yet, state that explicitly.

  • Rationale: footprint (exclusive/total closure), supply-chain, maintenance, or verification risk.

  • User review required: tests/build/typecheck to run; peer/plugin/CLI consumers; published-package or dynamic-import risk; approval before Replace-with-Better or any new direct dependency.

Use one block per package (or per protocol/CI finding), not a single-line summary, when the finding is non-trivial.

Files

LICENSE

                                 Apache License
                           Version 2.0, January 2004
                        http://www.apache.org/licenses/

   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

   1. Definitions.

      "License" shall mean the terms and conditions for use, reproduction,
      and distribution as defined by Sections 1 through 9 of this document.

      "Licensor" shall mean the copyright owner or entity authorized by
      the copyright owner that is granting the License.

      "Legal Entity" shall mean the union of the acting entity and all
      other entities that control, are controlled by, or are under common
      control with that entity. For the purposes of this definition,
      "control" means (i) the power, direct or indirect, to cause the
      direction or management of such entity, whether by contract or
      otherwise, or (ii) ownership of fifty percent (50%) or more of the
      outstanding shares, or (iii) beneficial ownership of such entity.

      "You" (or "Your") shall mean an individual or Legal Entity
      exercising permissions granted by this License.

      "Source" form shall mean the preferred form for making modifications,
      including but not limited to software source code, documentation
      source, and configuration files.

      "Object" form shall mean any form resulting from mechanical
      transformation or translation of a Source form, including but
      not limited to compiled object code, generated documentation,
      and conversions to other media types.

      "Work" shall mean the work of authorship, whether in Source or
      Object form, made available under the License, as indicated by a
      copyright notice that is included in or attached to the work
      (an example is provided in the Appendix below).

      "Derivative Works" shall mean any work, whether in Source or Object
      form, that is based on (or derived from) the Work and for which the
      editorial revisions, annotations, elaborations, or other modifications
      represent, as a whole, an original work of authorship. For the purposes
      of this License, Derivative Works shall not include works that remain
      separable from, or merely link (or bind by name) to the interfaces of,
      the Work and Derivative Works thereof.

      "Contribution" shall mean any work of authorship, including
      the original version of the Work and any modifications or additions
      to that Work or Derivative Works thereof, that is intentionally
      submitted to Licensor for inclusion in the Work by the copyright owner
      or by an individual or Legal Entity authorized to submit on behalf of
      the copyright owner. For the purposes of this definition, "submitted"
      means any form of electronic, verbal, or written communication sent
      to the Licensor or its representatives, including but not limited to
      communication on electronic mailing lists, source code control systems,
      and issue tracking systems that are managed by, or on behalf of, the
      Licensor for the purpose of discussing and improving the Work, but
      excluding communication that is conspicuously marked or otherwise
      designated in writing by the copyright owner as "Not a Contribution."

      "Contributor" shall mean Licensor and any individual or Legal Entity
      on behalf of whom a Contribution has been received by Licensor and
      subsequently incorporated within the Work.

   2. Grant of Copyright License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      copyright license to reproduce, prepare Derivative Works of,
      publicly display, publicly perform, sublicense, and distribute the
      Work and such Derivative Works in Source or Object form.

   3. Grant of Patent License. Subject to the terms and conditions of
      this License, each Contributor hereby grants to You a perpetual,
      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
      (except as stated in this section) patent license to make, have made,
      use, offer to sell, sell, import, and otherwise transfer the Work,
      where such license applies only to those patent claims licensable
      by such Contributor that are necessarily infringed by their
      Contribution(s) alone or by combination of their Contribution(s)
      with the Work to which such Contribution(s) was submitted. If You
      institute patent litigation against any entity (including a
      cross-claim or counterclaim in a lawsuit) alleging that the Work
      or a Contribution incorporated within the Work constitutes direct
      or contributory patent infringement, then any patent licenses
      granted to You under this License for that Work shall terminate
      as of the date such litigation is filed.

   4. Redistribution. You may reproduce and distribute copies of the
      Work or Derivative Works thereof in any medium, with or without
      modifications, and in Source or Object form, provided that You
      meet the following conditions:

      (a) You must give any other recipients of the Work or
          Derivative Works a copy of this License; and

      (b) You must cause any modified files to carry prominent notices
          stating that You changed the files; and

      (c) You must retain, in the Source form of any Derivative Works
          that You distribute, all copyright, patent, trademark, and
          attribution notices from the Source form of the Work,
          excluding those notices that do not pertain to any part of
          the Derivative Works; and

      (d) If the Work includes a "NOTICE" text file as part of its
          distribution, then any Derivative Works that You distribute must
          include a readable copy of the attribution notices contained
          within such NOTICE file, excluding those notices that do not
          pertain to any part of the Derivative Works, in at least one
          of the following places: within a NOTICE text file distributed
          as part of the Derivative Works; within the Source form or
          documentation, if provided along with the Derivative Works; or,
          within a display generated by the Derivative Works, if and
          wherever such third-party notices normally appear. The contents
          of the NOTICE file are for informational purposes only and
          do not modify the License. You may add Your own attribution
          notices within Derivative Works that You distribute, alongside
          or as an addendum to the NOTICE text from the Work, provided
          that such additional attribution notices cannot be construed
          as modifying the License.

      You may add Your own copyright statement to Your modifications and
      may provide additional or different license terms and conditions
      for use, reproduction, or distribution of Your modifications, or
      for any such Derivative Works as a whole, provided Your use,
      reproduction, and distribution of the Work otherwise complies with
      the conditions stated in this License.

   5. Submission of Contributions. Unless You explicitly state otherwise,
      any Contribution intentionally submitted for inclusion in the Work
      by You to the Licensor shall be under the terms and conditions of
      this License, without any additional terms or conditions.
      Notwithstanding the above, nothing herein shall supersede or modify
      the terms of any separate license agreement you may have executed
      with Licensor regarding such Contributions.

   6. Trademarks. This License does not grant permission to use the trade
      names, trademarks, service marks, or product names of the Licensor,
      except as required for reasonable and customary use in describing the
      origin of the Work and reproducing the content of the NOTICE file.

   7. Disclaimer of Warranty. Unless required by applicable law or
      agreed to in writing, Licensor provides the Work (and each
      Contributor provides its Contributions) on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
      implied, including, without limitation, any warranties or conditions
      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
      PARTICULAR PURPOSE. You are solely responsible for determining the
      appropriateness of using or redistributing the Work and assume any
      risks associated with Your exercise of permissions under this License.

   8. Limitation of Liability. In no event and under no legal theory,
      whether in tort (including negligence), contract, or otherwise,
      unless required by applicable law (such as deliberate and grossly
      negligent acts) or agreed to in writing, shall any Contributor be
      liable to You for damages, including any direct, indirect, special,
      incidental, or consequential damages of any character arising as a
      result of this License or out of the use or inability to use the
      Work (including but not limited to damages for loss of goodwill,
      work stoppage, computer failure or malfunction, or any and all
      other commercial damages or losses), even if such Contributor
      has been advised of the possibility of such damages.

   9. Accepting Warranty or Additional Liability. While redistributing
      the Work or Derivative Works thereof, You may choose to offer,
      and charge a fee for, acceptance of support, warranty, indemnity,
      or other liability obligations and/or rights consistent with this
      License. However, in accepting such obligations, You may act only
      on Your own behalf and on Your sole responsibility, not on behalf
      of any other Contributor, and only if You agree to indemnify,
      defend, and hold each Contributor harmless for any liability
      incurred by, or claims asserted against, such Contributor by reason
      of your accepting any such warranty or additional liability.

   END OF TERMS AND CONDITIONS

   APPENDIX: How to apply the Apache License to your work.

      To apply the Apache License to your work, attach the following
      boilerplate notice, with the fields enclosed by brackets "[]"
      replaced with your own identifying information. (Don't include
      the brackets!)  The text should be enclosed in the appropriate
      comment syntax for the file format. We also recommend that a
      file or class name and description of purpose be included on the
      same "printed page" as the copyright notice for easier
      identification within third-party archives.

   Copyright 2026 Grafana Labs

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

Requirements and compatibility

Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta

“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.

Needs: Needs network access, Needs Node.js

Security

What our scanner noticed· Low risk

  • Instructions that use the network

A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.

Attribution and licence

Published by
Grafana Labs
Publisher
Grafana Labs (Official)
Source
grafana/skills · skills/grafana-plugins/audit-and-reduce-dependencies · commit 8fb72a5
Licence
Apache License 2.0 (redistribution allowed)
  • LICENSE (added by AutoGineer from LICENSE)
  • ATTRIBUTION.md (written by AutoGineer)
Synced

AutoGineer is not affiliated with or endorsed by Grafana Labs or Grafana Labs.

Download ZIP

The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download audit-and-reduce-dependencies.zip