Regenerate Safely
The second scaffold run is riskier than the first, because generated files now contain
your handler code. Routa tracks a hash of everything it wrote in .routa/manifest.json
and refuses to overwrite a file that no longer matches, so regeneration fails loudly
rather than silently discarding work.
Before You Start
Section titled “Before You Start”- A committed working tree. Review is easier when the only diff is the regeneration.
- The updated OpenAPI document.
.routa/manifest.jsonpresent. Without it, Routa treats every existing file as unmanaged.
-
Preview. Routa requires this or an explicit
--yesonce a manifest exists, so a second run can never be accidental.Terminal window npx routa scaffold openapi.yaml --previewTerminal window pnpm exec routa scaffold openapi.yaml --previewTerminal window yarn exec routa scaffold openapi.yaml --previewTerminal window bunx routa scaffold openapi.yaml --preview -
Read every entry marked
~ update. These are tracked files whose current content still matches the manifest and whose newly generated content would change. A tracked file that you edited instead triggersROUTA_SCAFFOLD_MODIFIED_GENERATED_FILE;--yesnever discards those edits. Move logic into application-owned code or revert the generated-file edits before regenerating. -
Resolve entries marked
! conflict. Routa will not write over a file it does not track. Move your version aside, or restore the manifest if the file really was generated. -
Decide about entries marked
- remove. These correspond to operations no longer in the document. Routa deletes tracked files it generated; anything you created stays. -
Apply.
Terminal window npx routa scaffold openapi.yaml --yesTerminal window pnpm exec routa scaffold openapi.yaml --yesTerminal window yarn exec routa scaffold openapi.yaml --yesTerminal window bunx routa scaffold openapi.yaml --yes -
Validate and review the diff before committing.
Terminal window npm run checkTerminal window pnpm run checkTerminal window yarn run checkTerminal window bun run check
Verify
Section titled “Verify”git diff should contain only files that appeared in the preview. A change to a file the
preview did not mention means the manifest is out of date with reality.
git diff --name-only.routa/manifest.json.routa/openapi-baseline.json.routa/routes.gen.tssrc/routes/users/route.tsHow Routa Decides
Section titled “How Routa Decides”For each file it is about to write, Routa compares three things: whether the file exists, whether the manifest tracks it, and whether its current hash matches the recorded one.
| Exists | Tracked | Hash matches | Result |
|---|---|---|---|
| No | — | — | add |
| Yes | Yes | Yes | update or unchanged |
| Yes | Yes | No | ROUTA_SCAFFOLD_MODIFIED_GENERATED_FILE |
| Yes | No | — | conflict, then ROUTA_SCAFFOLD_UNMANAGED_FILE |
Framework-owned metadata under .routa/ is exempt. Routa always rewrites
routes.gen.ts, manifest.json, and openapi-baseline.json, because those are derived
files with no user content.
Troubleshooting
Section titled “Troubleshooting”| Problem | Fix |
|---|---|
Refusing to overwrite modified generated file |
Move your edits into an application-owned module, then re-run. Handler logic belongs in services, which is what makes routes regenerable. |
Refusing to overwrite unmanaged file |
Rename your file, or restore .routa/manifest.json from version control if it was lost. |
Preview shows everything as conflict |
The manifest is missing. Restore it from git rather than deleting your source. |
| A route you deleted from the document still serves traffic | Regeneration removed the file but metadata is stale. Run routa generate. |