Dependency

A dependency is a third-party package or library that your project relies on to function. When AI generates code that uses Stripe, Prisma, or Tailwind, those are dependencies — external code your project needs. Managing dependencies wisely prevents bloat, security vulnerabilities, and maintenance headaches.

Example

Your Next.js project has 25 dependencies listed in package.json: React for UI, Prisma for database, Stripe for payments, Zod for validation, and more. Each one is code someone else wrote that your project depends on to work.

Dependencies are a double-edged sword. They save you from reinventing the wheel but also introduce code you don't control into your project.

Direct vs Transitive Dependencies

  • Direct — Packages you explicitly install (listed in your package.json)
  • Transitive — Packages your dependencies depend on (installed automatically)

A project with 25 direct dependencies might have 500+ transitive dependencies. That's a lot of external code.

The Dependency Tradeoff

BenefitRisk
Save development timeMore code to maintain
Battle-tested solutionsPotential security vulnerabilities
Community supportCan become abandoned
Proven patternsVersion conflicts

AI and Dependencies

AI sometimes adds unnecessary dependencies. Watch for:

  • Overlapping packages — Two libraries that do the same thing
  • Heavy dependencies for simple tasks — A 100KB library for one small function
  • Outdated packages — AI might suggest older, deprecated versions
  • Unnecessary additions — Built-in solutions exist but AI reaches for a library

Best Practices

  1. Review what AI installs — Do you actually need each package?
  2. Prefer popular packages — More users means more maintenance and security fixes
  3. Keep dependencies updated — Security patches matter
  4. Audit regularlynpm audit checks for known vulnerabilities
  5. Use lock files — Ensure consistent versions across environments

When to Add a Dependency

Ask: "Is this complex enough to warrant external code?" If you can write it in 20 lines, maybe you don't need a package for it.

Ad
Favicon