inference bureau
Answers from our docs and articlesesc to close
Try asking
Create an accountSign up

Moving a Bolt app to Inference Bureau with Claude, and the three security gaps the move closed

A real Bolt app moved with Claude: 15 migrations, 17 policies, a 1,300-line store. Reading it closely turned up three ways around its security.

Key takeaways

  • Bolt gives you the code as a download, and a Bolt Database can be claimed into your own Supabase account (Pro and Teams plans), which is how its data comes out.
  • Replay the migrations before you trust them. In our run they didn't build the database the code expects: the frontend reads a notifications table that only a discarded migration creates.
  • Converting each policy one by one turned up three gaps: users could make themselves admin, anyone could create classes as any instructor, and the last spot in a class could be booked twice. On Inference Bureau each one is an action that decides for itself, with a test.
  • The app's 1,300-line data store became 728 lines on the records route, and the pages didn't change. Six tests run each role against the rules, including three people racing for two spots.

Part one moved a Lovable app. This part moves a Bolt app the same way, with Claude connected to Inference Bureau, and it's the more useful of the two. A move makes you read every table, policy and database function, and that reading is a security review whether you meant it as one or not.

The app we moved

A public Bolt project on GitHub (we're not naming it): a marketplace for fitness classes. Instructors list group and personal classes at venues on a map. Clients find classes near them, book a spot and get notifications. There's an admin role that verifies venues.

PartWhat it had
FrontendVite, React 18, React Router, Tailwind, Leaflet maps and a Zustand store: 19 pages, 22 components
Database6 tables built over 15 migrations, plus 2 in .bolt/supabase_discarded_migrations
Row-level security17 policies, some of them joins across three tables
Database functions8, two called from the browser with rpc(), and a sign-up trigger on auth.users
Supabase calls39: 27 table reads and writes, 9 auth calls, 2 rpc calls and a realtime channel, nearly all in one 1,300-line store

Step 1: get the code and the data out of Bolt

The code: on desktop, click the project's title at the top left and choose Download for a zip (Bolt's projects and files guide).

The data depends on where it lives. New Bolt projects use Bolt Database, included on every plan. To get its data out, claim it into your own Supabase account, which Bolt's Supabase guide describes. You need a Pro or Teams plan, and you must be an owner of the Supabase organization you connected:

  1. Connect Bolt to your Supabase account.
  2. Open the project, click the database icon at the top center, then the Advanced tab.
  3. Click Claim and follow Supabase's prompts.

The database then appears as a project in your Supabase account, where its tables export as CSV like any other Supabase project's. Bolt warns that connecting a different Supabase database to a project that already has a Bolt Database replaces the connection and may lose data, so claim, don't connect. Projects already on Supabase skip this step.

Step 2: connect Claude and hand it the project

Connect the Inference Bureau connector in Claude and give it the zip, as in part one. Use the same brief, with two lines added for this kind of app:

Before converting a policy, say who it lets do what, and flag any that lets a user change their own role, act as someone else, or skip a rule the page enforces.

Database functions marked SECURITY DEFINER run with full privileges: check what each trusts from its caller.

Step 3: replay the migrations before you trust them

Bolt writes a migration for each change you ask for, named like 20250528185040_misty_valley.sql. Fifteen of them describe this app, and their final state is what matters. We replayed them, in order, into a throwaway Postgres (PGlite, with stand-ins for Supabase's auth schema) and read the final state from the catalog: 6 tables, 17 policies and 8 functions. That's the schema to convert, not the fifteen files one by one.

Set beside the code, the replay turned up a mismatch. The frontend reads and writes a notifications table that no applied migration creates. It's defined only in .bolt/supabase_discarded_migrations/, a folder where Bolt keeps migrations it didn't apply. The live database may have it, created some other way, but the migrations alone don't build what the code needs. On Inference Bureau the model is a file, api/models/notification/schema.ib.ts, so there's no second copy to drift. When you hand Claude an app, ask it to list every table the code touches that no migration creates.

Step 4: what reading every policy turned up

Each policy became a grant in permissions.ib.ts, as in part one. Three of them didn't survive the reading.

Anyone could make themselves an admin

CREATE POLICY "Users can update own profile" ON profiles FOR UPDATE
  USING (auth.uid() = id) WITH CHECK (auth.uid() = id);

The policy checks whose row it is, not which columns change, and profiles.role is a column, so a signed-in client could set their own role to admin. Sign-up had the same problem from the other side: the trigger that makes a profile took role from the metadata the browser sent with signUp, and the column's check constraint allows admin.

On Inference Bureau a profile changes only through its actions, and the update action keeps the role as it was:

// api/models/profile/actions/update.ts
export const run: ActionRun = async ({ params, record }) => {
  const keep = { user: record.user, role: record.role, rating: record.rating, reviewCount: record.reviewCount };
  applyParams(params, record);
  Object.assign(record, keep);
  await save(record);
};

The create action takes client or instructor and nothing else. Admin is no longer a value in the profile at all: it's a role in the user record's roles field, which the team sets and a person can't, and permissions.ib.ts grants it the one thing admins do, verifying venues.

Anyone could create classes as any instructor

Classes were created through a database function, create_class, marked SECURITY DEFINER so it runs with full privileges. It checked that the instructor_id it was given belonged to an instructor, but not that it belonged to the person calling, so any signed-in user could publish classes under any instructor's name. The fitnessClass model's create action sets the instructor to whoever is signed in and refuses anyone who isn't an instructor.

The last spot could be booked twice

The booking page ran this from the browser: count the class's confirmed bookings, compare with its capacity, then insert a booking. Two people doing that at the same moment both count one free spot and both get it. Worse, the policy on bookings let a signed-in user insert any booking of their own, status: 'confirmed' included, so the capacity check could be skipped altogether.

Now no role is granted booking.create. Booking goes through one global action, bookClass, which gives each confirmed booking a numbered spot with a unique spotKey:

// api/actions/bookClass.ts (the loop)
for (let n = 1; n <= Number(cls.maxParticipants); n++) if (!taken.has(`${cls.id}:${n}`)) { spot = n; break; }
if (!spot) throw new Error("Class is full");
try {
  const booking = await api.booking.create({ fitnessClass: cls.id, profile: me.id, status: "confirmed", spotKey: `${cls.id}:${spot}` });
  return { bookingId: booking.id };
} catch (e) {
  if (e instanceof ApiError && (e.status === 409 || e.problems?.some((p) => p.field === "spotKey"))) continue; // taken a moment before
  throw e;
}

Two people going for the same spot both pick it; the database refuses the second write, and that caller tries the next spot or finds the class full. Cancelling clears the key and frees the spot. It's the same design as the class booking recipe.

And a smaller one

"Public profiles are viewable by everyone" showed every member's email address and phone number to anyone, signed in or not. Grants work on records, not columns, so the read filter now shows instructors' profiles to everyone and anyone else's only to its owner.

Step 5: the data layer

Nearly every Supabase call lived in src/lib/store.ts, so that's where the work was. Claude kept every function's name and what it returns, and changed how each gets its data:

  • Reads and writes go through the records route with the SDK's client, createRecordsClient(), as the signed-in user or a signed-out visitor. web/app/api/records/route.ts serves it with serveRecords, and permissions.ib.ts decides what each caller reaches. One thing to know: that file is plain data, so a shared constant like const me = { $session: "userId" } is refused. Write the value in each place.
  • rpc('create_class') became the model's create action; rpc('get_all_class_participant_counts') became a global action, classCounts, that runs an aggregate and returns counts, never who booked.
  • The realtime channel on new notifications became a live query: records.watch(["notification"], …) reads them again when they change and toasts the new ones.
  • Supabase Auth became the app's own sign-in, behind three server actions the existing login and sign-up forms call, so the app keeps its own screens. Sign-up makes the profile through the profile's create action, as the new user.
  • The region filter moved into the query (latitude and longitude between the region's bounds) instead of running over every class in the browser. Postgres point columns became two number fields.
  • A second, unused store at the bottom of the file was deleted.

The store went from 1,301 lines to 728. Pages and components didn't change, apart from removing a sign-out call in the navigation bar and the email-confirmation page, which the app's own sign-in replaces.

Two things outside the store needed attention. Geocoding called /api/nominatim, a proxy that exists only in Vite's dev server (vite.config.ts), so a static build of the app has no such address. It's a route handler now, web/app/api/nominatim/[...path]/route.ts, with the identifying User-Agent OpenStreetMap's usage policy asks for. And React 19 needed react-leaflet 5 in place of 4.

The move also fixed a bug nobody had reported: the store kept the raw database row as the signed-in user (profile_image), while the components read profileImage, so profile pictures never showed.

Step 6: check it

get_problems came back empty. Then six tests, run with run_tests over the connector, each calling as a role the way a browser would:

TestHolds
A profile update can't change its roleSent role: "instructor"; still a client
Sign-up can't choose admin, or make a second profileSent role: "admin"; got a client. A second create is refused
A class is created as the signed-in instructorSent another instructor's id; the class is the caller's. A client is refused
Bookings only through bookClass, never past capacityA direct create is refused (403). Three people for two spots at once: two bookings, two distinct spot keys
Cancelling frees the spot, only your ownSomeone else's booking answers 404; after a cancel, the next person gets the spot
Signed out, only instructors' profilesA client's profile isn't readable

All six passed. In a real browser, signed in as a test client, /dashboard showed the profile, bookings and notifications, and a class's page showed its instructor, the map, "0/2 participants" and Book Now, all read through the records route.

What Claude didn't do

  • The data. A public repository has none. Yours comes from the claimed Supabase project as CSV, into each model with Import CSV or ib-apps records import. Split each point into latitude and longitude and rename the headers to field names first, which Claude can do. Users come over by email and set a new password with a reset email.
  • Email confirmation before booking. Bolt's trigger made the profile only once an email address was confirmed. The app's sign-in can confirm addresses, but we didn't make booking wait for it.
  • Chat. The class chat in the page shows placeholder messages and never touched the database. Its two tables became models with no grants, ready for when it's built.
  • The files. About 70 files went up with ib-apps push from a folder, not one connector call per file, as in part one.

What you have now

The same app, with its rules where you can review them: permissions.ib.ts and the actions are files in every pull request, the tests run with ib-apps test, and every deploy shows its plan first. The gaps in step 4 were easy to miss in SQL, where a policy names rows, not columns, and a SECURITY DEFINER function can bypass every policy. As an action, each rule is code you can read, and each now has a test. Part one lists the rest of what changes once an app runs here.

Next in the series: v0, where the app is already Next.js, so the pages stay and only the database moves.

Frequently asked questions

My Bolt project is on Bolt Database. Do I need a paid Bolt plan to move it?

To take its data, yes: Bolt's Supabase guide says claiming a Bolt Database into Supabase needs a Pro or Teams plan, and that you're an owner of the Supabase organization. The code downloads on any plan.

Were these gaps Bolt's fault?

They're common in apps built quickly on row-level security, whoever writes them. A policy that checks whose row it is doesn't limit which columns change, and a function with SECURITY DEFINER skips the policies. A move is a good moment to catch them because every policy gets read.

Does the Bolt app keep running while I move?

Yes. Downloading the code and claiming the database don't stop it. Switch your domain over when the new app is checked and its data is in.

One bill for your apps, your models and your reviews.

Host apps and functions next to your model traffic. Routing picks each turn's model by your quality floor, and Auditor reviews every pull request against your own rules.