Give Claude Code a database
Let the agent run migrations, seed data and test queries against a real Postgres.
Recipe: PostgreSQL
Your project has Prisma, Drizzle or SQL migrations, and you want the agent to check them against a real database instead of reasoning about them.
Setup
Connect Claude Code to briq once: see the Quickstart.
Optionally, state your preferences in CLAUDE.md:
## Databases
Use the briq MCP server for any Postgres you need: the `postgres` recipe, and destroy the briq
when you are done.Ask
Apply our migrations to a fresh Postgres 17 with pgvector and check the schema.
The database is on briq's private network, so the agent works inside it. SQL migrations (Prisma
and Drizzle both write them) go straight to psql in the database briq:
briq_run({ recipe: "postgres", params: { version: "17", extensions: ["pgvector"] } })
→ bq_7kq2m9x1p4ab db (pgvector/pgvector:pg17) running · …internal · cost so far … · sleeps at 18:42 UTC unless used
outputs:
DATABASE_URL=postgres://postgres:…@…internal:5432/app
briq_files_put({ briq: "bq_7kq2m9x1p4ab", path: "/m/001.sql", contentBase64: "…" })
briq_exec({ briq: "bq_7kq2m9x1p4ab", cmd: ["psql", "-U", "postgres", "-d", "app", "-v", "ON_ERROR_STOP=1", "-f", "/m/001.sql"] })
briq_exec({ briq: "bq_7kq2m9x1p4ab", cmd: ["psql", "-U", "postgres", "-d", "app", "-c", "\\dt"] })
briq_destroy({ briq: "bq_7kq2m9x1p4ab" })When the tool must run your code (prisma migrate deploy, prisma db seed), run it from a
node:22 briq in the same stack with the outputs as env; see
Run tests against real services.
Tips
- Keep it while iterating. An unused briq goes to sleep on its own, and the next call wakes it with its data. Destroy it at the end.
- Seed from a dump:
briq_files_putit, thenpsql -f. - Name the stack (
stack: "acme-dev") when the agent runs several services. - Cap the agent with a budget: a runaway loop then costs the cap you set, not a weekend.