darnit

Your API integrations, invisibly mended.

Vendors change their APIs. Your code keeps calling them the old way. darnit finds the exact lines, rewrites them, runs your tests, and opens the pull request.

npm install -g darnit

Or skip the install: npx darnit check. Needs Node 22.12 or newer.

RevDescriptionStatus
Amax_tokens on OpenAI chat completionsSuperseded
Bmax_completion_tokens
rewritten by darnit
Tests passed

A real run, verbatim.

One repo, one OpenAI change. check finds it, fix mends it, your tests approve it.

chat.ts
$ npx darnit check
openai 2024-09-12: Rename max_tokens to max_completion_tokens on chat completions
chat.ts:10:3 max_tokens: 256the file and line
1 call site in 1 file
https://developers.openai.com/api/docs/api-reference/chat/createthe vendor's own notice
Scanned 1 JavaScript, TypeScript or Python file against 4 change records.
Not checked: request options built elsewhere and passed in as a variable.it says what it skipped
$ npx darnit fix
- max_tokens: 256,
+ max_completion_tokens: 256,revised
✓ Rename max_tokens to max_completion_tokens on chat completions: 1 file
tests: npm test passedyour tests, not ours

No change: the same file also calls anthropic.messages.create({ max_tokens: 1024 }). darnit leaves it alone. That one is correct.

How it works

  1. Find

    darnit check lists every call site a vendor change affects, with the file, the line and the vendor's own announcement.

  2. Fix

    darnit fix rewrites them with rules proven in CI, then shows you the diff. Add --pr for one pull request per change.

  3. Prove

    It runs your build and your tests. If either breaks, your files go back and it tells you which one.

Why you can trust the pull request

  • Every rewrite is a rule proven in CI before it ships. Same rule, same result, in every repo.
  • Checks your SDK version before touching anything. Too old: it stops and names the upgrade.
  • Runs your build and tests, and puts the files back if either breaks.
  • Lists what it couldn't fix as needs a human: file:line instead of pretending.
  • One pull request per change. Never force-pushes, never pushes to your default branch.

What it covers today

Fixes 1 OpenAI change, reports more, watches weekly. Small on purpose: a change gets a rewrite only when the rewrite is proven.

VendorStatusWhat that means
OpenAISupportedChange records and rewrites
Anthropic, Stripe, TwilioRecognizeddarnit init finds them; no change records yet

Reads JavaScript, TypeScript and Python. Runs on macOS and Linux. Want one covered? Open an issue.

Try it on your repo.

npx darnit check

Read-only. It lists what it finds and changes nothing. Install for good with npm install -g darnit.