mcpField

npm Audit Fix Loop

FeaturedOn demand
Code QualityUp to 10 rounds

About npm Audit Fix Loop

This loop clears high and critical npm vulnerabilities from a project's dependencies. Each round lists the remaining vulnerabilities, applies a low-risk fix to the affected packages, then runs the tests to confirm nothing broke, until the audit comes back clean.

Key features

  1. 01Filters for high severity and above
  2. 02Runs npm test after each fix to catch regressions
  3. 03Manual trigger, capped at 10 rounds
  4. 04Supports Cursor

Use cases

  1. 01Cleaning up high-severity dependency issues before a release
  2. 02Handling a security scan that reports high or critical alerts
  3. 03Routine upkeep of a project's dependency security
Goal
The project has no high or critical npm audit vulnerabilities.
Exit when
Stop when npm audit reports no high or critical issues, or after 10 rounds if some remain.
Between iterations run
npm audit --audit-level=high && npm test

Launch prompt

Paste into Cursor. The agent repeats the steps below until the exit condition is met.

prompt.md
Start the "npm Audit Fix Loop" loop.
Goal: The project has no high or critical npm audit vulnerabilities.
Max iterations: 10.
Step 1: List vulnerabilities — Run npm audit --audit-level=high to see which high and critical vulnerabilities remain and which dependencies they come from. If none are reported, the loop can end. `npm audit --audit-level=high`
Step 2: Apply a safe fix — For the packages in the report, pick the lowest-risk way to resolve them, avoiding major version jumps that are not needed.
Step 3: Run the tests — Run npm test to confirm the fix did not break existing behavior. If tests fail, handle that first in the next round before auditing again. `npm test`
Between iterations run: `npm audit --audit-level=high && npm test`
Exit when: Stop when npm audit reports no high or critical issues, or after 10 rounds if some remain.

Steps

Each round runs in order; if the exit condition isn’t met, another round starts, up to 10.

01
List vulnerabilities

Run npm audit --audit-level=high to see which high and critical vulnerabilities remain and which dependencies they come from. If none are reported, the loop can end.

$npm audit --audit-level=high
02
Apply a safe fix

For the packages in the report, pick the lowest-risk way to resolve them, avoiding major version jumps that are not needed.

03
Run the tests

Run npm test to confirm the fix did not break existing behavior. If tests fail, handle that first in the next round before auditing again.

$npm test
Not met → next roundExits when met

Supported agents

Coding agents that can run this loop directly.

Cursor
Claude Code

Comments

Markdown supported