sqlc-gen-moonbit-safety
Installation
SKILL.md
sqlc-gen-moonbit safety gates
Two regression-defense scripts that any sqlc-gen-moonbit + Cloudflare D1 project should run on every codegen and in CI. Both come from real production bugs in mizchi/mnemo that took an afternoon each to debug.
When to invoke
Use when you're:
- Bootstrapping a project that uses
sqlc-gen-moonbitagainst Cloudflare D1. - Investigating a 1101 (Worker threw exception) that may be a D1
.bind()hang. - Adding a
pnpm run db:verifygate (or equivalent) for sqlc codegen output.
What's in here
assets/scripts/patch-int64-binds.ts
Post-sqlc generate patch that wraps every @core.any(params.<Int64-field>) in src/db/gen/sqlc_queries.mbt with int64_bind_safe(...). The wrapper coerces JS BigInt → Number before D1 .bind().
Why this is needed: D1's .bind() does not handle BigInt. Passing a raw BigInt makes .run() / .all() never resolve. After ~30 s Cloudflare kills the worker with a 1101 Worker threw exception. sqlc-gen-moonbit emits Int64 fields as BigInt at the bind boundary by default.