# Codemods

A codemod is a program that edits your source files for you. `@vite-hub/codemods` moves an app to ViteHub, or to a newer ViteHub API. Each codemod edits the files that it can change safely. It ends with a report: the files that it changed, and a numbered list of manual follow-ups with `file:line` where it applies.

```bash [Terminal]
npx @vite-hub/codemods --dry-run
```

The command finds every module in the app that a codemod supports and runs those codemods, one after another. `--dry-run` prints the edits as diffs and writes nothing. The package requires Node.js 22.18 or newer.

## Move from a Nuxt module

| Codemod | Moves |
| --- | --- |
| [`nuxt-safe-runtime-config`](https://vitehub.dev/docs/codemods/nuxt-modules#nuxt-safe-runtime-config) | A Nuxt app from the `nuxt-safe-runtime-config` module to ViteHub [Env](https://vitehub.dev/docs/env) |
| [`t3-env`](https://vitehub.dev/docs/codemods/nuxt-modules#t3-env) | A Nuxt app from `@t3-oss/env-nuxt` `createEnv()` to ViteHub Env |
| [`resend`](https://vitehub.dev/docs/codemods/nuxt-modules#resend) | `nuxt-resend` and Resend SDK `emails.send()` calls to ViteHub [Email](https://vitehub.dev/docs/email) |
| [`nuxt-cron`](https://vitehub.dev/docs/codemods/nuxt-modules#nuxt-cron) | `nuxt-cron` jobs to ViteHub [Schedule](https://vitehub.dev/docs/schedule) Definitions |

## Upgrade ViteHub

`vitehub migrate [dir]` runs every upgrade codemod that applies, in one run. See [Upgrade ViteHub](https://vitehub.dev/docs/codemods/upgrade-vitehub).

| Codemod | Moves |
| --- | --- |
| [`define-forms`](https://vitehub.dev/docs/codemods/upgrade-vitehub#define-forms) | The former define forms of Schedule, Sandbox Task, Content, and Database to the one form of each |
| [`vitehub-options`](https://vitehub.dev/docs/codemods/upgrade-vitehub#vitehub-options) | The options that moved in `vitehub()`: `preset` to `host`, `logs` into `observability`, Env declarations into `vitehub({ env })`, and `devtools` and `contentImportBase` removed |
| [`queue-workflow-verbs`](https://vitehub.dev/docs/codemods/upgrade-vitehub#queue-workflow-verbs) | The old Queue and Workflow verbs to `sendQueue`, `useQueue`, `startWorkflow`, and `resumeWorkflow` |
| [`one-entry-imports`](https://vitehub.dev/docs/codemods/upgrade-vitehub#one-entry-imports) | Imports of subpaths that moved into one entry per concept, and `vite-hub/task` to `nitro/task` |
| [`agent-surface`](https://vitehub.dev/docs/codemods/upgrade-vitehub#agent-surface) | The old Agent names to `invoker`, `loadAgent()`, `agentWorkflow()`, `extends`, and the merged Agent entries |
| [`driver-key`](https://vitehub.dev/docs/codemods/upgrade-vitehub#driver-key) | The old keys that select a backend (`provider`, `authority`) and the old driver names, such as `cloudflare-kv-binding` and `d1`, to `driver` and the host name |
| [`tsconfig-paths`](https://vitehub.dev/docs/codemods/upgrade-vitehub#tsconfig-paths) | `#vitehub/*` entries of tsconfig `paths` that point into `.vitehub/` or `.nuxt/`, which ViteHub now types itself |
| [`shell-driver`](https://vitehub.dev/docs/codemods/upgrade-vitehub#shell-driver) | The Shell `provider` names to `driver`: `createShellRuntime({ driver })`, `ShellDriver`, and `createJustBashDriver()` |

The codemods do not upgrade Nuxt or install packages. ViteHub supports Nuxt 5 and Nitro 3 only.

::card-group
  :::card{title="Get started" icon="i-lucide-rocket" to="/docs/codemods/get-started"}
  Preview a migration, run it, and work through the report.
  :::

  :::card{title="Reference" icon="i-lucide-book-open" to="/docs/codemods/reference"}
  CLI options, exit codes, the Node API, and how to add a codemod.
  :::
::

<!-- vitehub-docs:section-links -->
## In this section

- [Overview](https://vitehub.dev/raw/docs/codemods.md) (this page)
- [Get started](https://vitehub.dev/raw/docs/codemods/get-started.md)
- [Upgrade ViteHub](https://vitehub.dev/raw/docs/codemods/upgrade-vitehub.md)
- [Move from a Nuxt module](https://vitehub.dev/raw/docs/codemods/nuxt-modules.md)
- [Reference](https://vitehub.dev/raw/docs/codemods/reference.md)

Next: [CODEMODS_BLOCKED](https://vitehub.dev/raw/docs/codemods/diagnostics/codemods_blocked.md)

All pages: [llms.txt](https://vitehub.dev/llms.txt)
