Build Your Data Context
Import your database schema and enrich it with AI-generated descriptions, quality checks, and tags — so the agent actually understands your data.
Why this step matters
An AI agent with access to a database but no context about what's in it will produce mediocre results. It'll guess that cust_id is a customer ID (probably right) but won't know that gmv stands for Gross Merchandise Value, that status = 3 means "refunded," or that timestamps are stored in UTC but your business runs on EST.
This step fixes that. You'll import your database schema into Bruin — turning each table into a local asset file with column names and types — and then use AI to enrich those files with meaningful descriptions, data quality checks, and tags. The result is a structured knowledge base that any AI agent can read to understand your data before writing a single query.
This is what separates a useful AI analyst from one that constantly gets things wrong.
What you'll do
- Import your database tables as Bruin asset files
- Enhance those assets with AI-generated metadata
Instructions
1. Import your database schema
Run the import command, pointing at your project folder and the connection you set up in the previous step. Replace <connection-name> with the name you used (e.g. gcp-default, redshift-default, postgres-default, or clickhouse-default), and <schema> with the database schema you want to analyze:
bruin import database --connection <connection-name> --schema <schema> my-analyst
For BigQuery, --schema corresponds to a dataset name. If you want to import multiple schemas, run the command once per schema or use --schemas schema1,schema2.
This creates an .asset.yml file for each table under assets/<schema>/. Each file contains the table name, type, and column metadata pulled directly from your database.
2. Enhance with AI
Now let the AI fill in what raw schema can't tell you — descriptions, quality checks, and tags:
bruin ai enhance my-analyst
This command connects to your database to gather column statistics (null counts, distinct values, min/max ranges), then uses an AI model to:
- Write descriptions for each table and column based on their names and data patterns
- Add quality checks like
not_nullon primary keys,accepted_valueson status columns, and range checks on numeric fields - Apply tags that group related assets by domain
The AI is conservative — it only adds metadata it's confident about, and existing content is never overwritten. If you've already written descriptions for some columns, they'll stay as-is.
Which AI provider? The command uses Claude Code by default. If you have multiple AI CLIs installed, specify one explicitly with
--claude,--opencode, or--codex. See the ai enhance docs for all options.
3. Review what was generated
Open one of the asset files to see what Bruin created:
cat my-analyst/assets/<schema>/<table>.asset.yml
You'll see something like:
type: pg.source
description: "Customer orders with purchase details and fulfillment status"
tags:
- ecommerce
- orders
columns:
- name: order_id
type: INTEGER
description: "Unique identifier for the order"
checks:
- name: not_null
- name: unique
- name: status
type: VARCHAR
description: "Current fulfillment status"
checks:
- name: accepted_values
value: ["pending", "shipped", "delivered", "refunded"]
This is the context your AI agent will read. The better these descriptions are, the better the agent's queries will be. Feel free to edit any file — add business context, fix descriptions, or tighten quality checks. These are your files, version-controlled and human-readable.
What just happened
Your project now contains asset files that map every table and column in your database, enriched with AI-generated descriptions and quality checks. This metadata is the foundation for everything that comes next — it's what turns a generic AI into one that actually understands your data.