dedupe-and-prune-deps
Skill1 starsChanged 3 months agoMITView on GitHub
Find duplicate, unused, and phantom dependencies, remove them safely, regenerate the lockfile, and verify CI. Use whenever the user asks to dedupe, prune unused packages, clean up package.json, remove phantom or undeclared imports, or slim the dependency tree. Also triggers on /dedupe-and-prune-deps.
- Deletes or force-pushes
- Commits and pushes
In this repository79 other files it gives its agents.
- add-i18nSkill
- add-missing-testsSkill
- align-minimum-release-ageSkill
- architecture-mapSkill
- audit-licensesSkill
- audit-vulnerabilitiesSkill
- audit-web-vitalsSkill
- build-landing-pageSkill
- claim-all-unassigned-prsSkill
- claim-unassigned-prsSkill
- driftSkill
- expert-accessibilitySkill
- expert-appsecSkill
- expert-backendSkill
- expert-dxSkill
- expert-frontend-performanceSkill
- expert-gas-optimizationSkill
- expert-qaSkill
- expert-smart-contract-securitySkill
- expert-tokenomicsSkill
- expert-uiSkill
- expert-uxSkill
- expert-web3-dappSkill
- extract-design-systemSkill
- fix-all-issuesSkill
- fix-dependabot-alertSkill
- fix-dependabot-prSkill
- fix-failing-ciSkill
- fix-flaky-testsSkill
- fix-issueSkill
- fix-renovate-prSkill
- fleet-health-dashboardSkill
- isometric-stack-mapSkill
- nudge-stale-prsSkill
- optimize-all-github-actionsSkill
- optimize-github-actionsSkill
- optimize-imagesSkill
- optimize-pwaSkill
- optimize-seo-aeoSkill
- panel-accessibilitySkill
- panel-architecture-scalabilitySkill
- panel-dapp-uxSkill
- panel-developer-experienceSkill
- panel-qa-release-readinessSkill
- panel-smart-contract-securitySkill
- panel-tokenomicsSkill
- panel-ui-designSkill
- panel-ux-reviewSkill
- panel-web3-integrationSkill
- panel-web-app-securitySkill
- panel-web-performanceSkill
- persona-accessibility-userSkill
- persona-crypto-newcomerSkill
- persona-designerSkill
- persona-developerSkill
- persona-gen-zSkill
- persona-grandmaSkill
- persona-growth-hackerSkill
- persona-investorSkill
- persona-mobile-commuterSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
8 rules. About 0 are common, 5 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 18
Do not skip any of the three.
- Distinctive: line 29
Prefer collapsing to a single supported version that satisfies every declared range.
- Distinctive: line 43
If not already inside a clone of the repo, clone it first.
- Very specific: line 56
Keep changes scoped to dependency hygiene: no drive-by refactors, no formatting sweeps, and no audit fix across the whole tree as a side …
- Distinctive: line 64
Commit the lockfile if it changed.
- Distinctive: line 72
Commit with a conventional message, e.g.:
- Very specific: line 80
Never force-push and never skip hooks (--no-verify).
- Very specific: line 94
If a check fails, pull the failing job's logs (gh run view <run-id> --log-failed), diagnose, fix (usually: restore a removal that CI proved …
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Dedupe and Prune Dependencies
Goal: make the dependency tree honest and minimal, collapse duplicate versions, declare phantom imports, remove genuinely unused packages, then reinstall, verify with the repo's own CI commands, commit, push to a new branch, and open a PR. Do not merge.
1. Detect the package manager and layout
- Detect the package manager from the lockfile (
pnpm-lock.yaml,yarn.lock,package-lock.json) and use only that one for every install, dedupe, and lockfile operation. Never mix package managers. - Detect workspaces/monorepo layout (
workspacesinpackage.json,pnpm-workspace.yaml). Operate per-package: each workspacepackage.jsongets its own unused/phantom analysis, not just the repo root.
2. Inventory three classes of waste
Do not skip any of the three.
Duplicates: the same package resolved at multiple versions:
# see which versions exist and who pulls them in
npm ls <package> --all # or: yarn why <package> / pnpm why <package>
# find the worst offenders wholesale
npm dedupe --dry-run # yarn dedupe --check (berry) / pnpm dedupe --checkPrefer collapsing to a single supported version that satisfies every declared range. If ranges conflict, prefer aligning the declared ranges over forcing with overrides/resolutions.
Unused: declared in dependencies/devDependencies but never referenced. Run a depcheck-style pass (npx depcheck, or npx knip where configured) and confirm each candidate with a grep across source, npm scripts, and config files, depcheck output alone is not evidence. Treat these as used even when no source file imports them:
- CLI tools invoked from
package.jsonscripts, CI workflows, Dockerfiles, or git hooks - Plugins loaded by name from config (ESLint, Prettier, Jest, Vite, Rollup, Babel, PostCSS, Tailwind, Next, etc.)
@types/*packages for untyped dependencies still in use- Packages required by codegen, migrations, or seed scripts
- Peer dependencies the app must provide for another dependency to work
Phantoms: imported or required in source but missing from the declaring package's package.json (they resolve only because a parent hoisted them). Find them by cross-checking each workspace's imports against its own declared dependencies (depcheck/knip report these as "missing"). Each phantom must become a direct dependency of the package that imports it, at a version compatible with what the tree already resolves, do not leave code relying on hoisting.
3. Create a working branch
If not already inside a clone of the repo, clone it first. Then:
git fetch origin
git checkout -b chore/dedupe-and-prune-deps origin/<default-branch>4. Apply changes in a safe order
- Declare phantoms first so the tree is honest before anything is removed.
- Dedupe / align versions (
npm dedupe,yarn dedupe,pnpm dedupe, plus range alignment in manifests). Do not cross a major version just to collapse a duplicate unless the migration is trivial and verified; otherwise keep the duplicate and note it in the report. - Remove unused packages last, one logical group per pass. Never remove a package solely "because depcheck said so", check scripts, CI workflows, Docker, codegen, and config first. When genuinely unsure, leave it in and list it under "reviewed, kept" with the reason.
Keep changes scoped to dependency hygiene: no drive-by refactors, no formatting sweeps, and no audit fix across the whole tree as a side effect of this skill.
5. Reinstall cleanly
rm -rf node_modules && <pm> install # plus workspace node_modules in a monorepoCommit the lockfile if it changed. Note the lockfile delta (lines or resolved-package count) for the report.
6. Verify with the repo's own CI commands
Read .github/workflows/*.yml for the exact commands CI runs (install, build, lint, typecheck, test) and run them locally in the same order. These commands are the definition of done. If something breaks, revert that specific removal or dedupe rather than papering over it, a package that turned out to be used goes back in and onto the "reviewed, kept" list.
7. Commit, push, and open a PR
- Commit with a conventional message, e.g.:
Never force-push and never skip hooks (chore(deps): dedupe lodash, declare phantom imports, remove unused packages - collapse lodash to a single 4.x resolution - declare dayjs in packages/api (was hoisting-only) - remove unused gulp toolchain from root devDependencies--no-verify). - Push and open the PR against the default branch:
In the PR body: what was collapsed, declared, and removed, and the packages reviewed but kept.git push -u origin chore/dedupe-and-prune-deps gh pr create --title "..." --body "..."
8. Watch CI, iterate until green
gh pr checks <number> --watchIf a check fails, pull the failing job's logs (gh run view <run-id> --log-failed), diagnose, fix (usually: restore a removal that CI proved was used), and push again. Do not merge the PR.
9. Report
End with a short summary: duplicates collapsed (package and versions before → after), unused packages removed, phantoms declared and where, packages reviewed-and-kept with why, the lockfile delta, the commit(s) and PR link, and final CI status.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

