Skip to main content

Claude Code Prompt to Audit and Clean Up Dependencies

Audit project dependencies with Claude Code to find unused packages, security vulnerabilities, and license conflicts, plus a safe cleanup plan with rollbacks.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This turns Claude Code into a dependency auditor that works against your real repo, not a generic checklist. It runs four ordered phases: it parses your [manifest_file] and lockfile to enumerate every direct and transitive package, greps [source_directory] to prove which ones are actually imported, then layers on a version and security pass (patch vs minor vs major, CVE and advisory cross-reference, abandonment flags) and a license-compliance pass against [project_license].

The reason it works is the ordering. Usage scanning comes first, so a package flagged "vulnerable" can also be flagged "unused" — and an unused vulnerable dep gets deleted instead of patched, which is the faster and safer fix. The [test_directory] vs production-dep distinction catches the classic mistake of shipping test tooling in prod. Because Claude reads the working directory, the "is this imported anywhere" answer is evidence-based, not guessed from the manifest alone.

The final phase forces a prioritized, executable plan: immediate removals, security patches, safe bumps, breaking upgrades (with what breaks named), and replacements for abandoned packages — each with the exact command, the files that may need edits, and a rollback command. The summary table plus a 1-10 health score give you a defensible before-and-after artifact.

When to use it

  • Inheriting a codebase and you need a fast, honest read on dependency health before touching anything.
  • Pre-release hardening — you want a clean security and license posture before a tagged version ships.
  • Your install times or bundle size crept up and you suspect dead or duplicated packages.
  • A npm audit or composer audit flagged CVEs and you need a prioritized fix order, not a wall of warnings.
  • Compliance review: confirming no GPL/AGPL or unlicensed package snuck into an MIT or proprietary project.
  • Quarterly maintenance where you batch safe patch and minor bumps and schedule the breaking ones deliberately.

Example output

Risk score: 6/10 - 2 unused deps, 1 high CVE, 4 safe bumps. ~45 min.

package    current   latest    status           action
lodash     4.17.19   4.17.21   CVE-2021-23337   PATCH NOW
moment     2.29.1    2.30.1    unmaintained     REPLACE -> date-fns
left-pad   1.3.0     1.3.0     unused           REMOVE
chalk      4.1.2     5.3.0     major ESM-only   HOLD - code change

1. Immediate removals
   npm rm left-pad        rollback: npm i [email protected]
2. Security patches
   npm i [email protected]   files: src/utils/merge.js

Pro tips

  • Be precise with [source_directory] and [test_directory]. In a monorepo, point it at one package per run — a wildcard scan produces noisy "unused" false positives from cross-package imports.
  • The "unused" flag is a strong signal, not gospel. Dynamic requires, plugin auto-loaders, and framework service discovery (Laravel package auto-discovery, for one) import without a literal statement, so sanity-check removals there before deleting.
  • Set [language] deliberately so Phase 2 checks the right footguns: prototype pollution for JS, unsafe deserialization for PHP and Java, pickle for Python. It changes which advisories matter.
  • Pair it with a clean git status and a passing test suite first, so every rollback command actually returns you to a known-good state. Run removals and patches as separate commits.
  • For the breaking-upgrades list, ask it to also draft the codemod or the specific diff per file — the migration is usually where the real time goes, not the version bump.

Frequently Asked Questions

Does this prompt actually run the upgrade commands, or just plan them?
It plans them. The output gives you exact install and remove commands plus a rollback command for each action, but you run them. That separation is intentional, so you review the prioritized plan and execute removals, patches, and breaking upgrades as deliberate, separate steps rather than one risky batch.
How reliable is the security and CVE check?
Treat it as a strong first pass, not a certified scan. It cross-references known CVE, GitHub Advisory, and Snyk patterns and flags unmaintained packages, but advisory databases move fast. For a release gate, run it alongside your native tooling like npm audit or composer audit and confirm any high-severity finding against the source advisory.
Can I use it for any language, or just JavaScript?
Any ecosystem with a manifest and lockfile. Set project_type, manifest_file (package.json, composer.json, requirements.txt, go.mod, and so on) and language accordingly. The language value matters most in Phase 2, where it switches the security patterns it looks for, like deserialization risks in PHP or Java versus prototype pollution in JS.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Claude Code Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support