Use this flow when an AI agent or operator needs to set up BaseBuddy against an existing Postgres/Supabase schema without digging through BaseBuddy source code.
The CLI can inspect the connected database, draft mapping JSON, explain that mapping, and save it through the same config APIs the app uses.
pnpm basebuddy agent:setup --json
pnpm basebuddy doctor --json
pnpm basebuddy setup --owner-email owner@example.com --owner-name "Owner" --owner-password "strong-password"
pnpm basebuddy projects:create --actor-email owner@example.com --name "Docs" --slug docs
pnpm basebuddy schema:inspect --schema public --json
pnpm basebuddy mapping:draft --schema public --table posts --json
pnpm basebuddy mapping:explain --input mapping.json --json
pnpm basebuddy mapping:set --project docs --input mapping.json --binding-status ready --jsonUse real values for the owner, project name, slug, schema, table, and mapping file.
Use schema inspection before writing mapping JSON:
pnpm basebuddy schema:inspect --schema public --json
pnpm basebuddy schema:inspect --schema public --table posts,authors,categories --json
pnpm basebuddy schema:inspect --schema public --table posts --no-samples --jsonThe output includes visible tables, columns, primary keys, foreign keys, enum values, row estimates, and sample rows when they can be read safely. It does not print the database URL.
For common schemas:
pnpm basebuddy mapping:draft --schema public --table posts --jsonFor custom table or column names, create a hints file:
{
"postsTable": "public.pages",
"titleColumn": "headline",
"slugColumn": "slug",
"excerptColumn": "summary",
"featuredImageUrlColumn": "hero_image_url",
"contentFields": [
{
"column": "body_md",
"kind": "markdown",
"label": "Body"
}
],
"customFields": [
{
"column": "faq_json",
"kind": "json",
"label": "FAQ"
}
],
"workflow": {
"mode": "published_flag",
"publishedFlagColumn": "is_published",
"publishedAtColumn": "published_at"
}
}Then run:
pnpm basebuddy mapping:draft --schema public --table pages --hints mapping-hints.json --jsonThe draft output includes mappingConfig, summary, and valid. Save only mappingConfig as the JSON file passed to mapping:set.
pnpm basebuddy mapping:explain --input mapping.json --jsonConfirm the source table, editor fields, custom fields, workflow fields, and storage metadata before saving.
Then save:
pnpm basebuddy mapping:validate --input mapping.json --json
pnpm basebuddy mapping:set --project docs --input mapping.json --binding-status ready --json
pnpm basebuddy mapping:get --project docs --json- Prefer CLI output and live schema inspection before reading source files.
- Do not hand-edit app data unless the CLI cannot load it and you are repairing the default local file.
- Do not put database URLs, auth secrets, Supabase keys, S3 keys, or passwords into mapping files, config files, docs, screenshots, commits, or final answers.
- Remember that
mapping:setdoes not rename tables, add columns, or change user content schemas.