guardrail by neatproxy join discord
tool: Claude Code env: Prisma ORM Schema

How to Stop Claude Code Loops in Prisma ORM Schema: Fix 'Endless refactor loop chasing cascading TypeScript strict-mode errors'

avg. estimated token loss per run: $$5–$75 per incident (depending on schema size, migration history, and retry depth) usd

what is happening

Claude Code can enter recursive `prisma migrate dev` loops when repeated migration failures trigger continuous shadow database resets. Instead of identifying the underlying schema, migration history, or database state issue, the agent repeatedly recreates the shadow database and retries the same migration, consuming tokens without making progress. Validating the migration manually, resolving the root schema conflict, and limiting automatic retries prevents runaway migration loops.

manual fix

Inspect the first Prisma migration error, verify the shadow database configuration and migration history, and fix the underlying schema or migration conflict before rerunning `prisma migrate dev`. If Claude Code repeatedly resets the shadow database and executes the same migration without reaching a new state, stop the session, reset context, and restart with a narrowly scoped migration task.

check configuration: .claude/settings.local.json & CLAUDE.md

capping calls & killing loops automatically

if you want to prevent runaway background processes from burning through API credits, you can set budget caps and loop limits directly in terminal using guardrail.

npx @neatproxy/guardrail --preset claude-code --target prisma --max-budget 15.00 --loop-cap 3

running into a different edge case? join us at neat to share logs or ask the team.

→ join the neat discord community