Why I avoid third-party packages, and how AI helps
TL;DR
My default is to write small pieces of code myself instead of pulling in someone else's package.
Packages can be hijacked. In September 2025 alone, attackers slipped malware into widely used packages, and one self-spreading attack compromised more than 500 of them.
Packages can also change their terms. A tool my coworkers relied on moved to a paid license in 2025, and they had to replace it everywhere.
AI tools sometimes recommend packages that don't exist, which attackers can exploit. They also make writing a small replacement quick, which tips the balance toward writing it yourself.
Why I'd rather vendor a function than add a package
Anecdotally, at my job, other engineers have added hundreds of NuGet packages over the years to do small things. Then they didn't update them for years and years. And now there are security holes decades in the making and license transitions that could potentially cost money.
This might have made sense in the past, but AI tooling has made it trivial to vendor a function. Another win for AI tooling.
Every package I add to a project brings in code I didn't write and can't control. Sometimes that's a good trade, but often it isn't, so I'm fairly strict about which ones I adopt. Better safe than sorry!
Some of that comes from experience. I started building Taproot I/O partly because I took one look at WordPress's bloated ecosystem and wanted to build something better. The same instinct shows up in smaller decisions every day, like whether to install a package or write the twenty lines I actually need.

What does a third-party package actually cost?
The first cost is security. If a vulnerability turns up in a package I depend on, I can't fix it right away. I wait for the maintainer's patch or work around the problem until it ships.
Worse, supply chain attacks go after the packages themselves. In September 2025, an attacker phished the npm account of the maintainer behind chalk, debug, and more than a dozen other popular packages and published versions carrying malware aimed at cryptocurrency wallets. It was caught within a couple of hours, but anyone who installed during that window got the attacker's code. About a week later the self-replicating Shai-Hulud worm used stolen npm credentials to publish infected versions of its victims' other packages, and CISA counted more than 500 compromised packages (opens in a new tab). The xz Utils backdoor (opens in a new tab) in 2024 was slower: someone spent years earning maintainer status on a compression library before slipping a backdoor into it. None of the projects depending on these packages did anything wrong.
Then there's the maintainer. When they stop maintaining a package, I'm the one who has to change my application, on a timeline I didn't choose. In 2016, the author of left-pad, an eleven-line function for padding strings, unpublished it from npm, and builds across the JavaScript ecosystem broke until npm restored it. More often a package just winds down. Moment.js declared itself a legacy project in maintenance mode in 2020 and recommends choosing a different library in most cases.
Even a well-maintained package runs on its own schedule. The maintainer decides when the next major version ships, and my plans end up kowtowing to their release cycle. I either upgrade on their terms or fall further behind until a forced migration catches up with me. None of that shows up when you run the install command.
I've watched this happen up close. At my day job, some of my colleagues used AutoMapper, a popular .NET library for mapping one object to another. In 2025 its maintainer moved new versions to a commercial license (opens in a new tab), and my colleagues had to replace it everywhere they'd used it.
Taproot got burned too. Our API documentation was built on Microsoft's Microsoft.AspNetCore.Grpc.Swagger package, and when Microsoft deprecated it we had to replace it. We moved to Microsoft's newer OpenAPI package plus a small integration we now maintain ourselves, which I walk through in from .proto to a typed TypeScript client.
More than I need, and not quite what I need
Most packages are much bigger than the problem I'm solving. I've seen colleagues reference giant libraries to use one function. When I'm performing surgery, I prefer a scalpel to a Swiss Army knife every time. And that one function usually carries options and edge cases for other people's problems, so I end up bending my code around it.
Write it or vendor it
So my default is to write a small function of my own, or to vendor only the pieces of a package that I actually need. The Go community has a proverb for this, from a 2015 talk by Rob Pike: "A little copying is better than a little dependency."
Dates are where a lot of projects reach for Moment or date-fns. Taproot's static site generator formats the dates on published pages with the Intl support built into JavaScript instead:
export function formatDate(date: Date | undefined): string {
if (!date || isNaN(date.getTime())) return "";
return date.toLocaleDateString("en-US", {
month: "long",
day: "numeric",
year: "numeric",
timeZone: "UTC",
});
}A neighboring parseCalendarDate reads an authored date like 2014-06-01 without passing it through the local time zone, so June 1 stays June 1 wherever the generator runs. That's about thirty lines between them, and no package.
Vendoring has rules of its own. I check the license and keep its notice with the code I copied, and I accept that the copy is now mine. If the original gets a security fix, nobody is going to open a pull request against my repository, so I need to know where the code came from. In exchange, I can test it, add logging, and fix it on my schedule.
How AI changes the build-or-install decision
The main argument for a package used to be that someone else already wrote it. With an AI tool, writing a focused function and its tests, or pulling the few pieces I need out of a larger package, is a quick task instead of a project, so the costs above start to dominate. The narrow version isn't free, though: code an AI tool writes for me is code I own and maintain.
AI can push in the other direction too. In its August 2026 status update (opens in a new tab), the Moment.js team said weekly downloads had more than tripled since 2020, and connected much of that growth to AI coding tools choosing Moment without a person making a deliberate library choice. Left alone, an AI tool tends to reach for whatever it has seen used most often.
AI tools also invent packages. A USENIX Security 2025 study (opens in a new tab) found that on average at least 5.2% of the packages commercial models suggested didn't exist, and 21.7% for open-source models. An attacker can register one of those made-up names and wait for someone to install it, a trick called slopsquatting.
So write down when a new package is acceptable, somewhere your AI tool reads. This is the whole rule in Taproot's AGENTS.md, which Claude Code and Codex both load:
## Dependency philosophy
Avoid third-party dependencies unless critical and hard to do in-house; each is
supply-chain surface and maintenance. Try platform APIs and existing code first;
if a package is warranted, prefer a small library over a framework and explain
the trade-off in the PR.The last line gives review something to check, because an AI tool that adds a package has to say why in the pull request. Checks can back rules like this up, which I covered in how we enforce coding standards.
Even my own packages cost something
Packages I control cost something too. Taproot's web components once lived in a separate package with exactly one consumer, which meant 23 published versions and more than a dozen dependency bumps before we moved them back into the monorepo. WTFM (opens in a new tab), our documentation tooling, is a separate package and one more thing to maintain.
When I publish something, I keep its dependencies few and explicit. The Taproot site authoring CLI (opens in a new tab) has two runtime dependencies, both pinned to exact versions: Espalier (opens in a new tab), so the CLI validates against the same theme contract it was tested with, and mediabunny, which reads video files before they're uploaded.
When is a third-party package worth it?
Sometimes you really do need one. Some packages do so much that rebuilding or vendoring them would be a fool's errand. Taproot I/O uses Entity Framework Core, and Espalier, our design system, uses Lit and nothing else at runtime. Both help me write code faster and more cleanly, and they're too broad to wrap usefully, so I use them directly.
Wrap the smaller ones
When I use a library with a smaller, more specific footprint, I wrap it in a function or interface that describes what my application needs in its own terms, and the rest of the code talks to that. Here's the wrapper around thumbhash, a small library that turns an image into a tiny blurred placeholder, from Taproot's image processor:
import sharp from "sharp";
import { rgbaToThumbHash } from "thumbhash";
/** Generate a ThumbHash placeholder from image bytes. */
export async function generateThumbHash(imageData: Buffer): Promise<string> {
const image = sharp(imageData, SHARP_INPUT_OPTIONS).rotate();
// ... resize to fit within 100×100 and read the raw RGBA pixels ...
const hash = rgbaToThumbHash(info.width, info.height, data);
return Buffer.from(hash).toString("base64");
}That's the only file in the image processor that imports thumbhash. Everything else hands over image bytes and gets back a string to store. The authoring app does the same with mediabunny: the upload component calls prepareVideo(file) and gets back the file and its codecs, and its tests mock that one module instead of the library.
If we replace the package or vendor it later, there's one wrapper to change.
Questions to ask before you add a package
Before I add a package, I ask:
How much of it will I actually use?
Does the platform already do it?
Intl,fetchandcrypto.randomUUID()cover a lot of what people install packages for.Could an AI tool and I write and test that part in less time than I'd spend reading its changelogs over the next year?
If the maintainer disappeared tomorrow, what would I have to change?
Does the package an AI tool suggested actually exist? Check the registry page and repository before installing.
If the answers point toward the package, I add it, and wrap it if it's small enough. If they don't, I write the small version and keep it close to the code that uses it.