Shim is an upgrade agent for TypeScript apps: when an API you depend on changes, it opens one tested pull request that updates your code before it breaks.
npx getshim scan .Needs Node 22 or later. Site and live PR list: getshim.dev. Questions: hello@getshim.dev
The first migration is Vercel AI SDK 6 -> 7. The official codemod handles renames. Shim handles the changes that still compile but behave differently. For example, on a multi-step call result.usage now counts every step, and result.response.messages holds only the last step's messages.
- Baseline. Install with
--ignore-scripts, then run the repo's type check and tests. Only gates that pass at baseline count. - Upgrade. Bump
aito ^7 and@ai-sdk/*to their latest majors, then runnpx @ai-sdk/codemod v7. - Find. Scan the code with ts-morph (
src/rules/ai-sdk-v7.ts). This finds calls imported fromai, follows their result variables andonFinish/onEndevents, and flags reads whose meaning changed. - Fix. Deterministic rewrites keep the v6 behavior, for example
result.usagebecomesresult.finalStep.usage. With--agent, the remaining sites go to a headless Claude Code run with a narrow brief. - Check. Run the gates again. Any regression, or an unresolved breaking finding, produces an issue instead of a PR.
- Report. Write
report.jsonandpr-body.md.
npx getshim scan path/to/repo
npx getshim migrate path/to/repo --agent --repo owner/name # --agent needs the claude CLIFrom a clone: npm install, then npx tsx src/cli.ts scan path/to/repo.
Shim runs on your machine or your CI. Nothing is sent to a Shim server.
scanandfixneed no model and no API key. They're static analysis and deterministic rewrites.- The fix agent (
migrate --agent,finish) and the judge (finish --judge) need a model you provide. By default Shim runs theclaudeCLI (Claude Code), which uses your own Claude login orANTHROPIC_API_KEY, and you pay for what it uses. Before a run, Shim prints the backend, the auth source (never its value) and the models, and stops if the backend isn't installed. - Commands in the target repo never see your keys. Installs use
--ignore-scripts, and tests and builds run with API keys and tokens stripped from the environment (src/exec.ts).
| Variable | Purpose | Default |
|---|---|---|
SHIM_AGENT_BACKEND |
claude-cli or dsh (DeepSeek Harness, for open-source models) |
claude-cli |
SHIM_FIXER_MODEL, SHIM_REVIEWER_MODEL, SHIM_JUDGE_MODEL |
Model id for each agent role (claude-cli only; dsh uses its own profile) | built-in Claude ids |
ANTHROPIC_API_KEY |
Pay per use instead of your Claude login | unset |
ANTHROPIC_BASE_URL (+ ANTHROPIC_AUTH_TOKEN) |
Any Anthropic-compatible provider. Cost is then recorded as null (unpriced) |
unset |
SHIM_SANDBOX=1 |
Required for dsh, which has no command allowlist: set it only in a throwaway container or VM with no credentials |
unset |
report.json records the backend and models each run used, and cost in USD when it is priced.
| Rule | Severity | Fix |
|---|---|---|
multi-step-result: usage, toolCalls, content, and similar reads on multi-step results |
silent | auto (generateText), agent (streamText, destructuring) |
typed-multi-step-result: the same reads on a parameter, variable, or property declared as GenerateTextResult, StreamTextResult, or Awaited<ReturnType<typeof generateText>>, where the producing call can't be seen |
silent | agent |
multi-step-end-event: the same reads on onFinish/onEnd events |
silent | auto / agent |
response-messages: result.response.messages now holds only the final step |
silent | auto (generateText) / agent |
telemetry-needs-otel: traces stop unless @ai-sdk/otel is registered |
silent | manual |
system-in-messages: role: 'system' in messages/prompt is rejected at runtime; Shim sets allowSystemInMessages: true on the call or ToolLoopAgent unless the messages are provably system-free |
break | auto (agent when the options are built elsewhere) |
esm-only: require('ai') throws |
break | agent |
node-22: engines.node below 22 |
break | manual |
ci-node-version: PR/push-triggered CI runs on Node below 22; rewrites the scalar/inline-matrix node-version to 22 (and a same-job matrix list it feeds), and flags a node-version-file below 22 |
break | auto (node-version) / manual (node-version-file) |
total-usage: totalUsage becomes usage |
deprecated | auto |
data/prs.csv records every PR opened: state, merge time, and comments. The merge rate is the number that matters.
