Skip to content
feritcemkahramanPublic

Latest commit

 

History

6 Commits

Folders and files

Repository files navigation

depkill

CI npm version Node >=20 Zero dependencies License: MIT

Delete your dependencies. Prove nothing broke.

Every dependency is code you run but did not write, as the 2026 npm supply-chain attacks on axios, TanStack (Mini Shai-Hulud) and keyv (CHAINDROP) showed. depkill lets your coding agent rewrite small dependencies as a few lines of your own code, then checks the replacement against your real usage, plus fresh nearby inputs answered by a recorded copy of the original, and fails if any compared output differs.

depkill card from a local run on expressjs/express (not an upstream change)

depkill does not call an LLM and never sends your code anywhere. Your own agent (Claude Code, Codex, Cursor, ...) writes the replacement; depkill measures, records, replays and decides whether the removal passes. The only data that leaves your machine is package names and versions, sent to the npm registry for maintainer counts (scan, card), plus the installs your package manager runs for card; --offline turns the registry requests off.

60-second quickstart

In a project with its dependencies installed (Node 20 or newer):

npx depkill init

This installs the agent instructions: a Claude Code skill in .claude/skills/depkill/SKILL.md and a marked section in AGENTS.md (--agent claude|agents|all, default all; re-running replaces the section instead of duplicating it). Then ask your agent:

use depkill to remove my smallest dependencies

It will scan, pick a candidate, record it, write a replacement, and loop on check and gate until the removal passes, then render the card.

Doing it by hand

npx depkill scan                      # rank direct dependencies by payoff / effort
npx depkill record <pkg>              # record how <pkg> behaves in this project
# write src/vendor/<pkg-safe>.ts and .depkill/<pkg-safe>/config.json: { "replacement": "src/vendor/<pkg-safe>.ts" }
npx depkill check <pkg>               # replay the recorded cases against your replacement
# rewire the imports, npm uninstall <pkg>
npx depkill gate <pkg>                # the done rule: every check below must pass
npx depkill verify [pkg]              # re-verify gated removals in CI from pinned cases
npx depkill card                      # measured before/after card, badge and report
Command Options
init --agent claude|agents|all
scan
record <pkg> --max-generated N (default 200), --from-tests, --test-cmd "<cmd>"
check <pkg> --replacement <path> (instead of config.json)
gate <pkg> --test-cmd "<cmd>", --skip-tests
verify [pkg] Re-verifies all gated removals (or <pkg>) against pinned cases.jsonl in CI
card

Global options: --cwd <dir>, --json (machine-readable stdout), --offline (no npm registry requests; the card's installs use the package manager's offline mode). Exit codes: 0 ok, 1 check or gate failed, 2 usage or configuration error. Scoped packages use @scope__name as their .depkill/ directory name.

How the proof works

record runs the original package in an isolated Node child process (independent of your test runner) on inputs from three sources: literal arguments at your call sites, argument lists your agent writes to .depkill/<pkg-safe>/inputs.mjs, and inputs generated from the package's type declarations. It records the return value, the thrown error and any mutation of the arguments; timeouts, nondeterministic results and values it cannot compare are marked unsupported and never count as evidence. It also keeps the original package.json and lockfile (.depkill/baseline/, on the first record), the original source (for copy detection) and a runnable copy of the package with its dependency closure (for the holdout check after the package is gone).

replace: your agent writes one self-contained file, for example src/vendor/<pkg-safe>.ts, and points .depkill/<pkg-safe>/config.json at it.

check replays every comparable case against the replacement in the same runtime. Exports are looked up strictly (#default must be the default export), a run with zero comparable cases fails ("nothing was proven"), and the replacement must be a project file (not under node_modules or .depkill).

gate is the done rule. Every check must pass or be legitimately skipped (the reason is listed, and the card discloses a skipped tests or holdout check):

  • cases-real: every real-usage case (call sites and inputs.mjs) matches, and every used export has evidence: at least one comparable real case, and no more uncomparable real cases than comparable ones (a plain-value export needs one comparable case of any source). An export that cannot be proven fails the gate.
  • cases-generated: every mismatching generated case is listed in accepted.json with a reason; at most 10% of the compared generated cases.
  • holdout: up to 60 fresh inputs near real usage (one argument nudged), answered by the original snapshot and the replacement, must match.
  • removed: the package is gone from every dependency field of package.json.
  • no-new-deps: no dependency was added since the baseline.
  • no-imports-left: no source file imports or requires the package any more.
  • wired: at least one project source file imports or requires each configured replacement file.
  • ships: when package.json declares files, any replacement imported by a shipped file is also covered by files.
  • self-contained: the replacement imports only allowlisted Node builtins, no eval, no references to .depkill or node_modules.
  • not-copied: the replacement shares under 60% of its 5-token sequences with the original source, raw and with local names normalized.
  • no-embedded-outputs: recorded string outputs are not pasted into the replacement in bulk.
  • typecheck: tsc --noEmit passes (skipped without a tsconfig.json or TypeScript).
  • tests: the project's test script, or --test-cmd, passes (skipped when there is no test script, or with --skip-tests).

The holdout inputs are derived from a hash of the replacement and the recorded cases: the same code always gets the same verdict, and changing the code draws new inputs, so special-casing them does not help. Holdout is skipped (and shown as skipped) when no argument can be varied, when every nearby input is already recorded, or when the original could not be snapshotted (for example, over 50 MB).

Replacements only ever run inside a locked-down child: --disallow-code-generation-from-strings, a builtin allowlist (assert, buffer, crypto, events, fs, os, path, punycode, querystring, stream, string_decoder, timers, url, util, zlib and their subpaths), blocked module loading, network globals and process.binding, and an fs guard that refuses paths under .depkill, node_modules or outside the project. On Node versions with the stable permission model (--permission, Node 22.13+ or 23.5+) file reads are also confined by Node itself; elsewhere the gate prints runtime sandbox: off and the card says unsandboxed run.

What the numbers mean

  • A package counts only when its gate passed and gate.json still matches the replacement files and recorded cases it judged, and the package is still out of package.json and every import. Stale or failed gates are skipped and named.
  • Before and after are measured with clean installs in temporary directories (install scripts off) of .depkill/baseline/ and of the current package.json and lockfile, with your package manager. Nothing is estimated from your own node_modules.
  • A removed package that another dependency still pulls in is marked still via <dep> (dev-only pulls are marked (dev), and differing versions are shown); the savings are what the installs measured, which can be zero.
  • Maintainer counts come from the npm registry and are left out with --offline. The report adds production-only numbers next to the totals.
  • The card footer states the evidence: Proven by N real-usage cases (N call-site, N agent-written) + N generated + N fresh holdout cases, plus N accepted mismatches, unsandboxed run, tests skipped, holdout skipped and typecheck skipped whenever they apply.
  • Dependencies removed after the first record without a gate (for example unused ones you simply uninstalled) are included in the totals and named in a caveat line on the card and in the report.
  • Any package additions, upgrades or removals between the baseline and current graphs outside the removed packages' closures (lockfile drift) are disclosed in a caveat line on the card and listed in the report.

depkill card needs at least one package whose gate passed. It writes .depkill/card.svg, .depkill/badge.svg and .depkill/report.md.

What to commit

depkill record creates .depkill/.gitignore (if missing) to ignore */original/, */runtime/, .build/ and */check.json. Commit your replacement files, package.json, lockfile, and — if you want the proof and evidence checked into the repo — .depkill/baseline/, cases.jsonl, meta.json, inputs.mjs, accepted.json, config.json, gate.json and the generated card/report. If your linter or test runner scans dot-folders (such as ESLint flat config), add .depkill/ to its ignores.

Limits

  • A gate pass means outputs matched on the recorded and holdout inputs, not on every possible input.
  • Values are compared by their own string properties (including non-enumerable properties), property descriptors (writable, enumerable, configurable, getter/setter presence and read value), and null prototypes; symbol properties, getter side effects, and class prototype chains are not compared (class instances compare by class name and own properties/descriptors).
  • v1 covers pure synchronous and async functions and constants. Streams, event emitters, stateful class instances, timers, I/O, callbacks passed in or functions returned, and nondeterministic output are detected at record time and marked unsupported. Native modules, packages over 5 MB exclusive, more than 8 used exports, and packages used only by tooling, CLIs or types are flagged unsupported by scan. Large frameworks, browser-specific behavior and non-JS languages are out of scope.
  • Single-package projects only: npm/yarn workspaces and pnpm-workspace.yaml are refused.
  • Call-site and type-generated inputs need the project's own typescript; without it only inputs.mjs is used.
  • .vue, .svelte and .astro files are scanned with the regex fallback scanner only; dist/, build/, coverage/ and dot-folders are not scanned, so no-imports-left cannot see imports there.
  • The holdout snapshot does not include peer dependencies, pnpm aliases or symlinked files; a package relying on them may not run from the snapshot.
  • The baseline is taken at the first record; a dependency added after that fails no-new-deps.
  • The anti-cheat checks stop shortcuts (copying, importing the original, reading the recorded cases, lookup tables of outputs). They are not tamper-proof against a person who edits .depkill/ by hand (cases, baseline, accepted.json); review those diffs like any other code.
  • The full runtime sandbox needs Node 22.13+ or 23.5+; on other versions the replay is reported as unsandboxed.

Zero dependencies

depkill has zero runtime dependencies. It uses your project's own TypeScript when it is installed.

Credits

  • Inspired by erkamyaman/rust-anything: record behavior, let an agent port it, replay and gate. depkill applies the idea to deleting npm dependencies.
  • Alternative hints in scan come from e18e module-replacements (MIT License, Copyright (c) 2024 James Garbutt), bundled in data/module-replacements.json.

License

MIT

Releases

Packages

Contributors

Languages