Recipes
Seven patterns that show what PerSQL is for. Each is ≤20 lines of code and works
against new PerSQL({ local: ":memory:" }) or a real psql_live_… token.
| Recipe | When you reach for it |
|---|---|
| Per-agent sandbox | Every agent run gets a fresh DB or branch. Idempotent, auto-deletes. |
| Agent memory | Durable, queryable memory in plain SQL — facts, working scratch, episodes. Keyword recall, no vector DB. |
| Shared agent context | One store many agents share — local, cloud, third-party — via SDK or the Context MCP. |
| Sub-agent handoff | Delegate a scoped, single-use token to a sub-agent. |
| Cost-aware loop | Self-throttle on meta.costUsd instead of a usage endpoint. |
| PR-preview DB | Idempotent branch per pull request, auto-clean. |
| MCP quickstart | Add PerSQL to Claude Desktop / Cursor in 30 seconds. |
Each recipe ends with a one-line “next step” — usually db.describe(),
db.search(), or db.doctor() — so you can keep building without leaving
the agent loop.
Every recipe here — plus the framework and ORM adapter recipes — has a complete, runnable version in the PerSQL cookbook, re-tested against the live API on every SDK release.